public void RepresentDensityField3D()
        {
            ILScene scene = new ILScene();

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

            ILInArray <double> ilaDataMeshToShow = dmDensityMesh.ToArray();
            ILInArray <double> ilaXvalues        = dmDensityMeshXcoord.Row(0).ToArray();
            ILInArray <double> ilaYvalues        = dmDensityMeshYcoord.Column(0).ToArray();

            ILSurface surf = new ILSurface(ilaDataMeshToShow, ilaXvalues, ilaYvalues);

            surf.UseLighting = true;
            surf.Colormap    = Colormaps.ILNumerics;
            //surf.Children.Add(new ILColorbar());

            currSurfPlotCube.Children.Add(surf);
            currSurfPlotCube.Rotation = Matrix4.Rotation(new Vector3(1, 0, 0), 1.2f) *
                                        Matrix4.Rotation(new Vector3(0, 0, 1), Math.PI);
            currSurfPlotCube.Projection = Projection.Perspective;

            scene.Add(currSurfPlotCube);

            ilPanel1.Scene = scene;
        }
        private static void InitPanel(ILPanel panel, NeuralNetwork ann)
        {
            panel.Scene.Remove(panel.Scene.First <ILPlotCube>());
            int xmin = (int)ann.Instance.Samples[0].Variables[0];
            int xmax = (int)ann.Instance.Samples[ann.Instance.NumSamples - 1].Variables[0];
            int ymin = (int)ann.Instance.Samples[0].Variables[1];
            int ymax = (int)ann.Instance.Samples[ann.Instance.NumSamples - 1].Variables[0];

            ILArray <double> positions = ILMath.zeros <double>(3, ann.Instance.NumSamples);

            int index = 0;

            foreach (var sample in ann.Instance.Samples)
            {
                positions[0, index] = sample.Variables[0];
                positions[1, index] = sample.Variables[1];
                positions[2, index] = sample.Value;
                index++;
            }

            ILPlotCube cube = new ILPlotCube(twoDMode: false)
            {
                // rotate plot cube
                Rotation = Matrix4.Rotation(new Vector3(-1, 1, .1f), 0.4f),
                // perspective projection
                Projection = Projection.Perspective,
                Children   =
                {
                    new ILSurface((x,   y) => 0,
                                  xmin, xmax,                                                       50,
                                  ymin, ymax,                                                       50,
                                  (x,   y) => x * y,
                                  colormap: Colormaps.Autumn)
                    {
                        UseLighting = true
                    },
                    new ILSurface((x,   y) => (float)Convert(ann.Instance.OriginalFunction.ValueAt,x,  y),
                                  xmin, xmax,                                                       50,
                                  ymin, ymax,                                                       50,
                                  (x,   y) => x * y,
                                  colormap: Colormaps.Hsv)
                    {
                        UseLighting = true
                    },
                    // add line plot, provide data as rows
                    new ILPoints {
                        Positions = ILMath.tosingle(positions),
                        Color     = Color.Red
                    }
                }
            };

            panel.Scene.Add(cube);
            panel.Scene.First <ILPlotCube>().Rotation = Matrix4.Rotation(Vector3.UnitX, .8f) * Matrix4.Rotation(Vector3.UnitZ, .6f);
            panel.Refresh();
        }
        public ILPlotCubeWrapper(ILPlotCube source, ILPanelEditor editor, string path, string name = null, string label = null)
            : base(source, editor, path, BuildName(name, editor.Panel, source, ILPlotCube.DefaultTag),
                   String.IsNullOrEmpty(label) ? GetPlotCubeLabel(source, editor.Panel) : label)
        {
            this.source = source;

            // Subscribe mouse events on SceneSyncRoot (instead of Scene)
            sourceSync = GetSyncNode(source);
            sourceSync.MouseClick += OnMouseClick;
        }
Exemple #4
0
        public void preparePlotCube()
        {
            plotCube = new ILPlotCube(null, twoDMode: true);

            Random random = new Random();

            drawOnlyPoints(random);
            //drawPointsAndLines(random);



            Debug.WriteLine("PlotCube przygotowany");
        }
Exemple #5
0
        public Field3Drepresentation(DenseMatrix dmDataToRepresent, Dictionary <string, object> properties, string description = "")
        {
            InitializeComponent();

            strDataDescription = description;
            ThreadSafeOperations.SetText(lblDescription, strDataDescription, false);

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

            dmData = dmDataToRepresent.Copy();


            ILScene scene = new ILScene();

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

            ILInArray <double> ilaDataMeshToShow = dmData.ToArray();

            if ((dmDataXcoord != null) && (dmDataYcoord != null))
            {
                ILInArray <double> ilaXvalues = dmDataXcoord.Row(0).ToArray();
                ILInArray <double> ilaYvalues = dmDataYcoord.Column(0).ToArray();
                surf = new ILSurface(ilaDataMeshToShow, ilaXvalues, ilaYvalues);
            }
            else
            {
                surf = new ILSurface(ilaDataMeshToShow);
            }

            surf.UseLighting = true;
            surf.Colormap    = Colormaps.ILNumerics;
            surf.Children.Add(new ILColorbar());

            currSurfPlotCube.Children.Add(surf);
            currSurfPlotCube.Rotation = Matrix4.Rotation(new Vector3(1, 0, 0), 1.2f) *
                                        Matrix4.Rotation(new Vector3(0, 0, 1), Math.PI);
            currSurfPlotCube.Projection = Projection.Perspective;

            scene.Add(currSurfPlotCube);

            ilPanel1.Scene = scene;
        }
Exemple #6
0
        public View3DControl()
        {
            InitializeComponent();
            var cm = new ContextMenu();

            cm.MenuItems.Add(new MenuItem("Clear", Clear_Clicked));
            this.ilPanel1.ContextMenu = cm;
            _ILScene  = new ILScene();
            _PlotCube = new ILPlotCube(twoDMode: false);
            _ILScene.Add(_PlotCube);
            ilPanel1.Scene            = _ILScene;
            cmbColorMap.SelectedIndex = 9;
            checkedListBox1.Items.Clear();
            ((ListBox)this.checkedListBox1).DisplayMember = "ID";
            cmbColorMap.SelectedIndexChanged += cmbColorMap_SelectedIndexChanged;
        }
Exemple #7
0
        public Form1()
        {
            InitializeComponent();
            E = new Electric(3, wind, samp);
            H = new Magnetic(3, wind, samp);

            ilPanel1.Scene = scene;
            plotCube = scene.Add(new ILPlotCube());

            plotCube.Limits.Set(new Vector3(0f,-1f,0f), new Vector3(200f,1f,0f));
            plotCube.AllowRotation = false;
            plotCube.AllowZoom = false;
            plotCube.AllowPan = false;
            ilPanel1.Scene = scene;
            backgroundWorker1.RunWorkerAsync();
        }
        public static List <ILSurfaceMeta> ToList(ILPlotCube cube)
        {
            List <ILSurfaceMeta> list = new List <ILSurfaceMeta>();
            int i = 1;

            foreach (var il in cube.Children)
            {
                var meta = new ILSurfaceMeta()
                {
                    Name    = "Series" + i,
                    Owner   = il as ILSurface,
                    Visible = il.Visible
                };
                list.Add(meta);
                i++;
            }
            return(list);
        }
 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;
 }
Exemple #10
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);
        }
Exemple #11
0
        public Form1()
        {
            InitializeComponent();
            InitFunctionsComboBox();
            _evolveTimer = new Timer {
                Interval = 100
            };
            InitEventListeners();
            _population = new Population(_functions[(string)functionsComboBox.SelectedItem], maxPopulationCount: 50, dimensions: 2);

            _plotCube = new ILPlotCube();
            var scene = new ILScene {
                _plotCube
            };
            var panel = new ILPanel {
                Scene = scene
            };

            renderContainer.Controls.Add(panel);
            RenderFunction();
        }
Exemple #12
0
        public Form1()
        {
            InitializeComponent();
            InitFunctionsComboBox();
            _evolveTimer = new Timer {
                Interval = 100
            };
            InitEventListeners();

            _population = GetPopulation((string)algorithmsComboBox.SelectedItem, (string)functionsComboBox.SelectedItem);

            _plotCube = new ILPlotCube();
            var scene = new ILScene {
                _plotCube
            };
            var panel = new ILPanel {
                Scene = scene
            };

            renderContainer.Controls.Add(panel);
            RenderFunction();
        }
        public static void FillResults(ILPanel panel, Panel panelFuzzySets, NeuralNetwork ann)
        {
            SetFuzzySets(panelFuzzySets, ann);
            int xmin = (int)ann.Instance.Samples[0].Variables[0];
            int xmax = (int)ann.Instance.Samples[ann.Instance.NumSamples - 1].Variables[0];
            int ymin = (int)ann.Instance.Samples[0].Variables[1];
            int ymax = (int)ann.Instance.Samples[ann.Instance.NumSamples - 1].Variables[0];

            ErrorFunction er   = new ErrorFunction(ann.Instance.Samples, ann);
            ILPlotCube    cube = new ILPlotCube(twoDMode: false)
            {
                // rotate plot cube
                Rotation = Matrix4.Rotation(new Vector3(-1, 1, .1f), 0.4f),
                // perspective projection
                Projection = Projection.Perspective,
                Children   =
                {
                    new ILSurface((x,   y) => (float)Convert(er.ValueAt, x,               y),
                                  xmin, xmax,                            xmax - xmin + 1,
                                  ymin, ymax,                            ymax - ymin + 1,
                                  (x,   y) => x * y,
                                  colormap: Colormaps.Hsv)
                    {
                        UseLighting = true
                    }
                }
            };

            panel.Scene.Remove(panel.Scene.First <ILPlotCube>());
            panel.Scene.Add(cube);
            panel.Scene.Screen.Add(new ILLabel("Error per sample")
            {
                Position = new Vector3(1, 0, 0),
                Anchor   = new PointF(1, 0)
            });
            panel.Refresh();
        }
        /// <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();
        }
        private static string GetPlotCubeLabel(ILPlotCube source, ILPanel panel)
        {
            if (panel.Scene.Find<ILPlotCube>().Count() == 1)
                return ILPlotCube.DefaultTag;

            return BuildDefaultName(panel, source, ILPlotCube.DefaultTag);
        }
Exemple #16
0
        private void RepresentData()
        {
            ThreadSafeOperations.SetText(lblFileName, dataFileName, false);

            ILInArray <double> dataValues = dmDataToShow.ToArray();

            ILScene    scene            = new ILScene();
            ILPlotCube currSurfPlotCube = new ILPlotCube();

            currSurfPlotCube.TwoDMode = false;

            ILSurface surf = new ILSurface(dataValues);

            surf.UseLighting = true;
            surf.Colormap    = Colormaps.Jet;
            surf.Children.Add(new ILColorbar());

            currSurfPlotCube.Children.Add(surf);
            currSurfPlotCube.Rotation = Matrix4.Rotation(new Vector3(1, 0, 0), 1.2f) *
                                        Matrix4.Rotation(new Vector3(0, 0, 1), Math.PI);
            currSurfPlotCube.Projection = Projection.Perspective;

            scene.Add(currSurfPlotCube);



            //scene.First<ILSurface>().MouseClick += (s, arg) =>
            //{
            //    // we start at the mouse event target -> this will be the
            //    // surface group node (the parent of "Fill" and "Wireframe")
            //    var group = arg.Target.Parent;
            //    if (group != null)
            //    {
            //        // walk up to the next camera node
            //        Matrix4 trans = group.Transform;
            //        while (!(group is ILCamera) && group != null)
            //        {
            //            group = group.Parent;
            //            // collect all nodes on the path up
            //            trans = group.Transform * trans;
            //        }
            //        if (group != null && (group is ILCamera))
            //        {
            //            // convert args.LocationF to world coords
            //            // The Z coord is not provided by the mouse! -> choose arbitrary value
            //            var pos = new Vector3(arg.LocationF.X * 2 - 1, arg.LocationF.Y * -2 + 1, 0);
            //            // invert the matrix.
            //            trans = Matrix4.Invert(trans);
            //            // trans now converts from the world coord system (at the camera) to
            //            // the local coord system in the 'target' group node (surface).
            //            // In order to transform the mouse (viewport) position, we
            //            // left multiply the transformation matrix.
            //            pos = trans * pos;
            //            // view result in the window title
            //            //Text = "Model Position: " + pos.ToString();
            //            ThreadSafeOperations.SetText(lblStatus, pos.ToString(), false);
            //        }
            //    }
            //};



            ilPanel1.Scene = scene;
        }
Exemple #17
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);
        }
Exemple #18
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();
        }
Exemple #20
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;
        }
Exemple #21
0
        public Field4Drepresentation(
            DenseMatrix dmListOfData,
            Dictionary <string, object> properties,
            Dictionary <string, int> valuesColumnsIndeces = null,
            SlicingVariable varSliceBy = SlicingVariable.z,
            string description         = "")
        {
            InitializeComponent();

            variableSliceBy = varSliceBy;

            if (valuesColumnsIndeces == null)
            {
                valuesColumnsIndeces = new Dictionary <string, int>();
                valuesColumnsIndeces.Add("x", 0);
                valuesColumnsIndeces.Add("y", 1);
                valuesColumnsIndeces.Add("z", 2);
                valuesColumnsIndeces.Add("values", 3);
            }

            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;



            List <List <DenseMatrix> > lDataMatricesForSurfices = ReshapeDataToMatrices(dmDataList, variableSliceBy);



            foreach (List <DenseMatrix> currSurfMatricesList in lDataMatricesForSurfices)
            {
                ILInArray <double> ilaXvalues = currSurfMatricesList[0].ToArray();
                ILInArray <double> ilaYvalues = currSurfMatricesList[1].ToArray();
                ILInArray <double> ilaZvalues = currSurfMatricesList[2].ToArray();

                MathNet.Numerics.LinearAlgebra.Single.DenseMatrix floatDMcolors =
                    MathNet.Numerics.LinearAlgebra.Single.DenseMatrix.Create(currSurfMatricesList[0].RowCount,
                                                                             currSurfMatricesList[0].ColumnCount, 0.0f);
                currSurfMatricesList[3].MapConvert <Single>(dval => Convert.ToSingle(dval), floatDMcolors,
                                                            MathNet.Numerics.LinearAlgebra.Zeros.Include);
                ILInArray <float> ilaForColorValues = floatDMcolors.ToArray();


                ILSurface currSurf = new ILSurface(ilaZvalues, ilaXvalues, ilaYvalues);
                currSurf.ColorMode = ILSurface.ColorModes.RBGA;

                ColorScheme newCS = new ColorScheme("");
                //ColorSchemeRuler newCSR = new ColorSchemeRuler(newCS, dataMinVal, dataMaxVal);
                double[,] dmRvalues = DenseMatrix.Create(floatDMcolors.RowCount, floatDMcolors.ColumnCount,
                                                         (r, c) =>
                {
                    Bgr currColor = newCS.GetColorByValueAndRange(currSurfMatricesList[3][r, c], dataMinVal, dataMaxVal);
                    return(currColor.Red / 255.0d);
                }).ToArray();
                double[,] dmGvalues = DenseMatrix.Create(floatDMcolors.RowCount, floatDMcolors.ColumnCount,
                                                         (r, c) =>
                {
                    Bgr currColor = newCS.GetColorByValueAndRange(currSurfMatricesList[3][r, c], dataMinVal, dataMaxVal);
                    return(currColor.Green / 255.0d);
                }).ToArray();
                double[,] dmBvalues = DenseMatrix.Create(floatDMcolors.RowCount, floatDMcolors.ColumnCount,
                                                         (r, c) =>
                {
                    Bgr currColor = newCS.GetColorByValueAndRange(currSurfMatricesList[3][r, c], dataMinVal, dataMaxVal);
                    return(currColor.Blue / 255.0d);
                }).ToArray();
                float[, ,] rgbaArrData = new float[4, dmRvalues.GetLength(0), dmRvalues.GetLength(1)];
                for (int i = 0; i < dmRvalues.GetLength(0); i++)
                {
                    for (int j = 0; j < dmRvalues.GetLength(1); j++)
                    {
                        rgbaArrData[0, i, j] = Convert.ToSingle(dmRvalues[i, j]);
                        rgbaArrData[1, i, j] = Convert.ToSingle(dmGvalues[i, j]);
                        rgbaArrData[2, i, j] = Convert.ToSingle(dmBvalues[i, j]);
                        rgbaArrData[3, i, j] = 0.3f;
                    }
                }

                currSurf.UpdateRGBA(null, rgbaArrData);

                currSurf.UseLighting = true;

                currSurfPlotCube.Children.Add(currSurf);

                //if (currSurfPlotCube.Children.Count() > 4)
                //{
                //    currSurfPlotCube.Children.Add(new ILColorbar());
                //}


                //if (currSurfPlotCube.Children.Count() > 4)
                //{
                //    break;
                //}
            }

            // surf.Children.Add(new ILColorbar());

            //currSurfPlotCube.Children.Add(new ILColorbar());

            //currSurfPlotCube.Rotation = Matrix4.Rotation(new Vector3(1, 0, 0), 1.2f) *
            //                    Matrix4.Rotation(new Vector3(0, 0, 1), Math.PI);

            currSurfPlotCube.Projection = Projection.Orthographic;

            currSurfPlotCube.Plots.Reset();

            scene.Add(currSurfPlotCube);

            ilPanel1.Scene = scene;
        }
Exemple #22
0
        private void PlotByIsolines(
            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;

            List <List <DenseMatrix> > llDataMatricesSlicedByZ = ReshapeDataToMatrices(dmDataList, SlicingVariable.z);
            DenseMatrix dmXvalues = llDataMatricesSlicedByZ[0][0].Copy();
            DenseMatrix dmYvalues = llDataMatricesSlicedByZ[0][1].Copy();

            List <List <DataValuesOver3DGrid> > lDataVectorsForSurfices = Group_DVOG_DataByValues(dmDataList);

            foreach (List <DataValuesOver3DGrid> currSurfVectorsList in lDataVectorsForSurfices)
            {
                //ILInArray<float> ilaXvalues =
                //    currSurfVectorsList.ConvertAll<float>(dvog => Convert.ToSingle(dvog.x)).ToArray();
                //ILInArray<float> ilaYvalues =
                //    currSurfVectorsList.ConvertAll<float>(dvog => Convert.ToSingle(dvog.y)).ToArray();
                //ILInArray<float> ilaZvalues =
                //    currSurfVectorsList.ConvertAll<float>(dvog => Convert.ToSingle(dvog.z)).ToArray();
                //ILSurface currSurf = new ILSurface(ilaZvalues, ilaXvalues, ilaYvalues);
                // не катит - надо, чтобы сетка z была m*n, сетка x = m*[1|n], сетка y - [1|m]*n
                // поэтому просто список точек, которые должны составить поверхность, - не катят
                //  => или отрисовывать множества точек, без привязки именно к понятию поверхности. Это пока не получилось
                //  => или переформировать список точек так, чтобы они составили m*n поверхность

                // скомпоновать матрицу значений Z, соответствующих значениям x и y
                DenseMatrix dmZvalues = DenseMatrix.Create(dmXvalues.RowCount, dmXvalues.ColumnCount, (r, c) =>
                {
                    double x = dmXvalues[r, c];
                    double y = dmYvalues[r, c];
                    int idx  = currSurfVectorsList.FindIndex(dvog => ((dvog.x == x) && (dvog.y == y)));
                    if (idx == -1) // ничего нужного нет
                    {
                        return(double.NaN);
                    }
                    else
                    {
                        return(currSurfVectorsList[idx].z);
                    }
                });
                ILArray <double> arrXvalues = (ILArray <double>)(dmXvalues.ToArray());
                ILArray <double> arrYvalues = (ILArray <double>)(dmYvalues.ToArray());
                ILArray <double> arrZvalues = (ILArray <double>)(dmZvalues.ToArray());

                // сформируем colors array
                ColorScheme newCS    = new ColorScheme("");
                DenseMatrix dmValues = DenseMatrix.Create(dmXvalues.RowCount, dmXvalues.ColumnCount, (r, c) =>
                {
                    double x = dmXvalues[r, c];
                    double y = dmYvalues[r, c];
                    int idx  = currSurfVectorsList.FindIndex(dvog => ((dvog.x == x) && (dvog.y == y)));
                    if (idx == -1) // ничего нужного нет
                    {
                        return(double.NaN);
                    }
                    else
                    {
                        return(currSurfVectorsList[idx].values[0]);
                    }
                });

                double[,] dmRvalues = DenseMatrix.Create(dmValues.RowCount, dmValues.ColumnCount,
                                                         (r, c) =>
                {
                    Bgr currColor = newCS.GetColorByValueAndRange(dmValues[r, c], dataMinVal, dataMaxVal);
                    return(currColor.Red / 255.0d);
                }).ToArray();
                double[,] dmGvalues = DenseMatrix.Create(dmValues.RowCount, dmValues.ColumnCount,
                                                         (r, c) =>
                {
                    Bgr currColor = newCS.GetColorByValueAndRange(dmValues[r, c], dataMinVal, dataMaxVal);
                    return(currColor.Green / 255.0d);
                }).ToArray();
                double[,] dmBvalues = DenseMatrix.Create(dmValues.RowCount, dmValues.ColumnCount,
                                                         (r, c) =>
                {
                    Bgr currColor = newCS.GetColorByValueAndRange(dmValues[r, c], dataMinVal, dataMaxVal);
                    return(currColor.Blue / 255.0d);
                }).ToArray();
                float[, ,] rgbaArrData = new float[4, dmRvalues.GetLength(0), dmRvalues.GetLength(1)];
                for (int i = 0; i < dmRvalues.GetLength(0); i++)
                {
                    for (int j = 0; j < dmRvalues.GetLength(1); j++)
                    {
                        rgbaArrData[0, i, j] = Convert.ToSingle(dmRvalues[i, j]);
                        rgbaArrData[1, i, j] = Convert.ToSingle(dmGvalues[i, j]);
                        rgbaArrData[2, i, j] = Convert.ToSingle(dmBvalues[i, j]);
                        rgbaArrData[3, i, j] = 0.3f;
                    }
                }



                ILSurface currSurf = new ILSurface(ILMath.convert <double, float>(arrZvalues),
                                                   ILMath.convert <double, float>(arrXvalues), ILMath.convert <double, float>(arrYvalues), rgbaArrData);

                currSurf.UseLighting = true;

                currSurfPlotCube.Children.Add(currSurf);
            }

            currSurfPlotCube.Projection = Projection.Orthographic;

            currSurfPlotCube.Plots.Reset();

            scene.Add(currSurfPlotCube);

            ilPanel1.Scene = scene;
        }
Exemple #23
0
        private void CreatePlot()
        {
            Scene = new ILScene();

            Scene.Add(Space = new ILPlotCube(twoDMode: true));
        }
        /// <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;
        }