Esempio n. 1
0
        // function for testing 3d scatter plot
        public void TestScatterPlot(int nDotNo)
        {
            // 1. set scatter chart data no.
            _m_3DChart = new ScatterChart3D();
            _m_3DChart.SetDataNo(nDotNo);

            // 2. set property of each dot (size, position, shape, color)
            var randomObject = new Random();
            var nDataRange   = 200;

            for (int i = 0; i < nDotNo; i++)
            {
                var plotItem = new ScatterPlotItem
                {
                    w     = 4,
                    h     = 6,
                    x     = randomObject.Next(nDataRange),
                    y     = randomObject.Next(nDataRange),
                    z     = randomObject.Next(nDataRange),
                    shape = randomObject.Next(4)
                };

                var nR = (byte)randomObject.Next(256);
                var nG = (byte)randomObject.Next(256);
                var nB = (byte)randomObject.Next(256);

                plotItem.color = Color.FromRgb(nR, nG, nB);
                ((ScatterChart3D)_m_3DChart).SetVertex(i, plotItem);
            }

            // 3. set the axes
            _m_3DChart.GetDataRange();
            _m_3DChart.SetAxes();

            // 4. get Mesh3D array from the scatter plot
            var meshs = ((ScatterChart3D)_m_3DChart).GetMeshes();

            // 5. display model vertex no and triangle no
            UpdateModelSizeInfo(meshs);

            // 6. display scatter plot in Viewport3D
            var model3D = new Model3D();

            MnChartModelIndex = model3D.UpdateModel(meshs, null, MnChartModelIndex, mainViewport);

            // 7. set projection matrix
            var viewRange = nDataRange;

            _mTransformMatrix.CalculateProjectionMatrix(0, viewRange, 0, viewRange, 0, viewRange, 0.5);
            TransformChart();
        }
Esempio n. 2
0
        // function for set a scatter plot, every dot is just a simple pyramid.
        public void TestSimpleScatterPlot(int nDotNo)
        {
            // 1. set the scatter plot size
            _m_3DChart = new ScatterChart3D();
            _m_3DChart.SetDataNo(nDotNo);

            // 2. set the properties of each dot
            var       randomObject = new Random();
            const int nDataRange   = 200;

            for (var i = 0; i < nDotNo; i++)
            {
                var plotItem = new ScatterPlotItem
                {
                    w     = 2,
                    h     = 2,
                    x     = randomObject.Next(nDataRange),
                    y     = randomObject.Next(nDataRange),
                    z     = randomObject.Next(nDataRange),
                    shape = (int)Chart3D.Shape.Pyramid
                };

                var nR = (byte)randomObject.Next(256);
                var nG = (byte)randomObject.Next(256);
                var nB = (byte)randomObject.Next(256);

                plotItem.color = Color.FromRgb(nR, nG, nB);
                ((ScatterChart3D)_m_3DChart).SetVertex(i, plotItem);
            }
            // 3. set axes
            _m_3DChart.GetDataRange();
            _m_3DChart.SetAxes();

            // 4. Get Mesh3D array from scatter plot
            var meshs = ((ScatterChart3D)_m_3DChart).GetMeshes();

            // 5. display vertex no and triangle no.
            UpdateModelSizeInfo(meshs);

            // 6. show 3D scatter plot in Viewport3d
            var model3D = new Model3D();

            MnChartModelIndex = model3D.UpdateModel(meshs, null, MnChartModelIndex, mainViewport);

            // 7. set projection matrix
            var viewRange = nDataRange;

            _mTransformMatrix.CalculateProjectionMatrix(0, viewRange, 0, viewRange, 0, viewRange, 0.5);
            TransformChart();
        }
        public void plotAnalytic(Plate p)
        {
            int nXNo = p.U.GetLength(0);
            int nYNo = p.U.GetLength(1);

            //Устанавливаем сетку
            m_3dChart = new UniformSurfaceChart3D();
            ((UniformSurfaceChart3D)m_3dChart).SetGrid(nXNo, nYNo, 0, (float)p.a, 0, (float)p.b, p.solutionU);
            m_3dChart.GetDataRange();

            int    nVertNo = m_3dChart.GetDataNo();
            double zMin    = p.MinZ;
            double zMax    = p.MaxZ;

            for (int i = 0; i < nVertNo; i++)
            {
                Vertex3D vert = m_3dChart[i];
                double   h    = (vert.z - zMin) / (zMax - zMin);

                Color color = WPFChart3D.TextureMapping.PseudoColor(h);
                m_3dChart[i].color = color;
            }


            ArrayList meshs = ((UniformSurfaceChart3D)m_3dChart).GetMeshes();

            // 5. display vertex no and triangle no of this surface chart
            UpdateModelSizeInfo(meshs);

            // 6. Set the model display of surface chart
            WPFChart3D.Model3D model3d      = new WPFChart3D.Model3D();
            Material           backMaterial = new DiffuseMaterial(new SolidColorBrush(Colors.Gray));

            m_nChartModelIndex = model3d.UpdateModel(meshs, backMaterial, m_nChartModelIndex, this.mainViewport);

            // 7. set projection matrix, so the data is in the display region
            float xMin = m_3dChart.XMin();
            float xMax = m_3dChart.XMax();

            m_transformMatrix.CalculateProjectionMatrix(xMin, xMax, xMin, xMax, zMin, zMax, 0.5);
            TransformChart();
        }
Esempio n. 4
0
        // function for testing 3d scatter plot
        public void DrawScatterPlot(List <Rgb> rgbList)
        {
            if (rgbList == null)
            {
                throw new ArgumentNullException(nameof(rgbList));
            }
            // 1. set scatter chart data no.
            _m_3DChart = new ScatterChart3D();
            _m_3DChart.SetDataNo(rgbList.Count);

            // 2. set property of each dot (size, position, shape, color)
            var nDataRange = 200;

            var zArray = GenZList(rgbList);
            //------------------------------------------------------------------------------------------------//

            var zMax = zArray.Max();
            var zMin = zArray.Min();

            var onePercent = zMax / 100;

            var percents = StaticInterfaceHandler.GetSplitterArray(this);
            var diffs    = ToDiffArray(percents, onePercent);


#warning zArray = SortByDiffs(zArray, diffs, int.Parse(splitterBackage.Text), new[]
            //           {
            //               CheckBoxInvisible.IsChecked != null && CheckBoxInvisible.IsChecked.Value,
            //               CheckBoxInvisible1.IsChecked != null && CheckBoxInvisible1.IsChecked.Value,
            //               CheckBoxInvisible2.IsChecked != null && CheckBoxInvisible2.IsChecked.Value,
            //               CheckBoxInvisible3.IsChecked != null && CheckBoxInvisible3.IsChecked.Value
            //           });

            //------------------------------------------------------------------------------------------------//

            var rgbCortage = new RgbCortage();
            for (var i = 0; i < rgbList.Count; i++)
            {
                // ReSharper disable once CompareOfFloatsByEqualityOperator
                if (zArray[i] == 0)
                {
                    continue;
                }

                var plotItem = new ScatterPlotItem
                {
                    w = 1,
                    h = 1
                };

                var r = rgbList[i].R;
                var g = rgbList[i].G;
                var b = rgbList[i].B;

                plotItem.x = (float)rgbList[i].X;
                plotItem.y = (float)rgbList[i].Y;
                plotItem.z = zArray[i] - 500;
#warning
                //   plotItem.shape = randomObject.Next(4);

                plotItem.shape = (int)Chart3D.Shape.Cylinder;

                plotItem.color = Color.FromRgb(r, g, b);
                ((ScatterChart3D)_m_3DChart).SetVertex(i, plotItem);
            }

            for (var i = 0; i < diffs.Count; i++)
            {
                rgbCortage.RegisterNewContainer(GetBordersLine(zArray, rgbList, diffs[i].From, diffs[i].To,
                                                               new Color()
                {
                    A = diffs[i].Color.A, R = diffs[i].Color.R, G = diffs[i].Color.G, B = diffs[i].Color.B
                }));
            }

            foreach (var container in rgbCortage.Container)
            {
                foreach (var rad in container)
                {
                    var plotItem = new ScatterPlotItem
                    {
                        w     = 1,
                        h     = 1,
                        x     = (float)rad.X,
                        y     = (float)rad.Y,
                        z     = (float)rad.Z - 500,
                        shape = (int)Chart3D.Shape.Cylinder,
                        color = Color.FromArgb(rad.A, rad.R, rad.G, rad.B)
                    };
                    ((ScatterChart3D)_m_3DChart).SetVertex(rad.Possition, plotItem);
                }
            }

            _m_3DChart.GetDataRange();
            _m_3DChart.SetAxes();

            var meshs = ((ScatterChart3D)_m_3DChart).GetMeshes();

            UpdateModelSizeInfo(meshs);

            var model3D = new Model3D();
            MnChartModelIndex = model3D.UpdateModel(meshs, null, MnChartModelIndex, mainViewport);

            var viewRange = (float)nDataRange;
            _mTransformMatrix.CalculateProjectionMatrix(0, viewRange, 0, viewRange, 0, viewRange, 0.5);
            TransformChart();

            SetEditedPicture(rgbCortage, rgbList);
        }
        private void InitChart()
        {
            m_3dChart = new ScatterChart3D();
            m_3dChart.SetDataNo(dataN);

            // 2. set the properties of each dot
            Random randomObject = new Random();
            int    nDataRange   = 1;

            ((ScatterChart3D)m_3dChart).Clear();

            ScatterPlotItem plotItem  = new ScatterPlotItem();
            ScatterPlotItem plotItem1 = new ScatterPlotItem();
            ScatterPlotItem plotItem2 = new ScatterPlotItem();

            plotItem.rotmatrix = plotItem1.rotmatrix = plotItem2.rotmatrix = new double[9] {
                1, 0, 0, 0, 1, 0, 0, 0, 1
            };

            plotItem.w = plotItem1.w = plotItem2.w = 1;
            plotItem.h = plotItem1.h = plotItem2.h = 30;

            plotItem.x = plotItem1.x = plotItem2.x = 0;
            plotItem.y = plotItem1.y = plotItem2.y = 0;
            plotItem.z = plotItem1.z = plotItem2.z = 0;

            plotItem.shape = plotItem1.shape = plotItem2.shape = (int)Chart3D.SHAPE.CYLINDER;

            plotItem.type  = 1;
            plotItem1.type = 2;
            plotItem2.type = 3;

            plotItem.color = Color.FromRgb((Byte)0, (Byte)0, (Byte)255);
            ((ScatterChart3D)m_3dChart).SetVertex(dataN, plotItem);
            plotItem1.color = Color.FromRgb((Byte)0, (Byte)255, (Byte)0);
            ((ScatterChart3D)m_3dChart).SetVertex(dataN, plotItem1);
            plotItem2.color = Color.FromRgb((Byte)255, (Byte)0, (Byte)0);
            ((ScatterChart3D)m_3dChart).SetVertex(dataN, plotItem2);

            // 3. set axes
            m_3dChart.GetDataRange();
            m_3dChart.SetAxes();

            // 4. Get Mesh3D array from scatter plot
            ArrayList meshs = ((ScatterChart3D)m_3dChart).GetMeshes();

            // 5. display vertex no and triangle no.
            //UpdateModelSizeInfo(meshs);

            // 6. show 3D scatter plot in Viewport3d
            WPFChart3D.Model3D model3d = new WPFChart3D.Model3D();
            m_nChartModelIndex = model3d.UpdateModel(meshs, null, m_nChartModelIndex, this.mainViewport);

            // 7. set projection matrix
            if (!_lock)
            {
                float viewRange = (float)nDataRange;
                m_transformMatrix.CalculateProjectionMatrix(-200, 200, -200, 200, -100, 200, 2);
                TransformChart();
            }
        }
        // function for set a scatter plot, every dot is just a simple pyramid.


        public void plot_next(float[] xIMU1_Acc, float[] xIMU2_Acc, int i, double[] xIMU1_rotmatrix, double[] xIMU2_rotmatrix)
        {
            dataN++;
            m_3dChart.SetDataNo(dataN);

            // 2. set the properties of each dot
            Random randomObject = new Random();
            int    nDataRange   = dataN;

            ((ScatterChart3D)m_3dChart).Clear();

            //xIMu1
            ScatterPlotItem xIMU1_plotItem1 = new ScatterPlotItem();
            ScatterPlotItem xIMU1_plotItem2 = new ScatterPlotItem();
            ScatterPlotItem xIMU1_plotItem3 = new ScatterPlotItem();

            xIMU1_plotItem1.rotmatrix = xIMU1_plotItem2.rotmatrix = xIMU1_plotItem3.rotmatrix = xIMU1_rotmatrix;

            xIMU1_plotItem1.w = xIMU1_plotItem2.w = xIMU1_plotItem3.w = 1;
            xIMU1_plotItem1.h = xIMU1_plotItem2.h = xIMU1_plotItem3.h = 30;

            xIMU1_plotItem1.x = xIMU1_plotItem2.x = xIMU1_plotItem3.x = xIMU1_Acc[0];
            xIMU1_plotItem1.y = xIMU1_plotItem2.y = xIMU1_plotItem3.y = xIMU1_Acc[1];
            xIMU1_plotItem1.z = xIMU1_plotItem2.z = xIMU1_plotItem3.z = xIMU1_Acc[2];

            xIMU1_plotItem1.shape = xIMU1_plotItem2.shape = xIMU1_plotItem3.shape = (int)Chart3D.SHAPE.CYLINDER;

            xIMU1_plotItem1.type = 1;
            xIMU1_plotItem2.type = 2;
            xIMU1_plotItem3.type = 3;

            xIMU1_plotItem1.color = Color.FromRgb((Byte)0, (Byte)0, (Byte)255);
            ((ScatterChart3D)m_3dChart).SetVertex(dataN, xIMU1_plotItem1);
            xIMU1_plotItem2.color = Color.FromRgb((Byte)0, (Byte)255, (Byte)0);
            ((ScatterChart3D)m_3dChart).SetVertex(dataN, xIMU1_plotItem2);
            xIMU1_plotItem3.color = Color.FromRgb((Byte)255, (Byte)0, (Byte)0);
            ((ScatterChart3D)m_3dChart).SetVertex(dataN, xIMU1_plotItem3);

            //xIMU2
            ScatterPlotItem xIMU2_plotItem1 = new ScatterPlotItem();
            ScatterPlotItem xIMU2_plotItem2 = new ScatterPlotItem();
            ScatterPlotItem xIMU2_plotItem3 = new ScatterPlotItem();

            xIMU2_plotItem1.rotmatrix = xIMU2_plotItem2.rotmatrix = xIMU2_plotItem3.rotmatrix = xIMU2_rotmatrix;

            xIMU2_plotItem1.w = xIMU2_plotItem2.w = xIMU2_plotItem3.w = 1;
            xIMU2_plotItem1.h = xIMU2_plotItem2.h = xIMU2_plotItem3.h = 30;

            xIMU2_plotItem1.x = xIMU2_plotItem2.x = xIMU2_plotItem3.x = xIMU2_Acc[0];
            xIMU2_plotItem1.y = xIMU2_plotItem2.y = xIMU2_plotItem3.y = xIMU2_Acc[1];
            xIMU2_plotItem1.z = xIMU2_plotItem2.z = xIMU2_plotItem3.z = xIMU2_Acc[2];

            xIMU2_plotItem1.shape = xIMU2_plotItem2.shape = xIMU2_plotItem3.shape = (int)Chart3D.SHAPE.CYLINDER;

            xIMU2_plotItem1.type = 1;
            xIMU2_plotItem2.type = 2;
            xIMU2_plotItem3.type = 3;

            xIMU2_plotItem1.color = Color.FromRgb((Byte)0, (Byte)0, (Byte)255);
            ((ScatterChart3D)m_3dChart).SetVertex(dataN, xIMU1_plotItem1);
            xIMU2_plotItem2.color = Color.FromRgb((Byte)0, (Byte)255, (Byte)0);
            ((ScatterChart3D)m_3dChart).SetVertex(dataN, xIMU1_plotItem2);
            xIMU2_plotItem3.color = Color.FromRgb((Byte)255, (Byte)0, (Byte)0);
            ((ScatterChart3D)m_3dChart).SetVertex(dataN, xIMU1_plotItem3);
            // 3. set axes
            m_3dChart.GetDataRange();
            m_3dChart.SetAxes();

            // 4. Get Mesh3D array from scatter plot
            ArrayList meshs = ((ScatterChart3D)m_3dChart).GetMeshes();

            // 5. display vertex no and triangle no.
            //UpdateModelSizeInfo(meshs);

            // 6. show 3D scatter plot in Viewport3d
            WPFChart3D.Model3D model3d = new WPFChart3D.Model3D();
            m_nChartModelIndex = model3d.UpdateModel(meshs, null, m_nChartModelIndex, this.mainViewport);

            // 7. set projection matrix
            if (!_lock)
            {
                float viewRange = (float)nDataRange;
                m_transformMatrix.CalculateProjectionMatrix(0, 200, 0, 200, 0, 200, 1);
                TransformChart();
            }
        }