Exemple #1
0
        void Apply(SurfacePlotModel model)
        {
            var nx      = model.Nx;
            var ny      = model.Ny;
            var surface = new UniformSurfaceChart3D();

            _3dChart = surface;
            _3dChart.SetDataNo(nx * ny);
            surface.SetGrid(nx, ny);
            _wireframes.Thickness = model.Data.Thickness;
            _wireframes.Color     = model.Data.Color.Convert();

            var x      = model.Data.Xs;
            var y      = model.Data.Ys;
            var z      = model.Data.Zs;
            var length = x.Length;

            for (var i = 0; i < length; i++)
            {
                _3dChart[i] = new Vertex3D
                {
                    X = (Single)x[i],
                    Y = (Single)y[i],
                    Z = (Single)z[i]
                };
            }

            SetView(model.XAxis, model.YAxis, model.ZAxis);
            SetColors(model.ZAxis, model.Colors);

            var meshs        = ((UniformSurfaceChart3D)_3dChart).GetMeshes();
            var backMaterial = new DiffuseMaterial(new SolidColorBrush(Colors.Gray));

            _model3d.UpdateModel(meshs, backMaterial);
            Project(model.XAxis, model.YAxis, model.ZAxis);
            TransformChart();

            if (model.IsWireframeShown)
            {
                _wireframes.MakeWireframe(_model3d.Content);
            }
            else
            {
                _wireframes.Points.Clear();
            }

            if (!model.IsSurfaceShown)
            {
                MainViewport.Children.Remove(_model3d);
            }
            else if (!MainViewport.Children.Contains(_model3d))
            {
                MainViewport.Children.Add(_model3d);
            }

            if (IsAxisShown)
            {
                ShowAxis();
            }
        }
Exemple #2
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();
        }
Exemple #3
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();
        }
Exemple #5
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();
            }
        }