コード例 #1
0
        // selection
        public override void Select(ViewportRect rect, TransformMatrix matrix, Viewport3D viewport3d)
        {
            int nDotNo = GetDataNo();

            if (nDotNo == 0)
            {
                return;
            }

            double xMin = rect.XMin();
            double xMax = rect.XMax();
            double yMin = rect.YMin();
            double yMax = rect.YMax();

            for (int i = 0; i < nDotNo; i++)
            {
                ScatterPlotItem plotItem = Get(i);
                Point           pt       = matrix.VertexToViewportPt(new Point3D(plotItem.x, plotItem.y, plotItem.z),
                                                                     viewport3d);

                if ((pt.X > xMin) && (pt.X < xMax) && (pt.Y > yMin) && (pt.Y < yMax))
                {
                    m_vertices[i].selected = true;
                }
                else
                {
                    m_vertices[i].selected = false;
                }
            }
        }
コード例 #2
0
        // convert the 3D scatter plot into a array of Mesh3D object
        public ArrayList GetMeshes()
        {
            int nDotNo = GetDataNo();

            if (nDotNo == 0)
            {
                return(null);
            }
            ArrayList meshs = new ArrayList();

            int nVertIndex = 0;

            for (int i = 0; i < nDotNo; i++)
            {
                ScatterPlotItem plotItem = Get(i);
                int             nType    = plotItem.shape % Chart3D.SHAPE_NO;
                float           w        = plotItem.w;
                float           h        = plotItem.h;
                Mesh3D          dot;
                m_vertices[i].nMinI = nVertIndex;
                switch (nType)
                {
                case (int)SHAPE.BAR:
                    dot = new Bar3D(0, 0, 0, w, w, h);
                    break;

                case (int)SHAPE.CONE:
                    dot = new Cone3D(w, w, h, 7);
                    break;

                case (int)SHAPE.CYLINDER:
                    dot = new Cylinder3D(w, w, h, 7);
                    break;

                case (int)SHAPE.ELLIPSE:
                    dot = new Ellipse3D(w, w, h, 7);
                    break;

                case (int)SHAPE.PYRAMID:
                    dot = new Pyramid3D(w, w, h);
                    break;

                default:
                    dot = new Bar3D(0, 0, 0, w, w, h);
                    break;
                }
                nVertIndex         += dot.GetVertexNo();
                m_vertices[i].nMaxI = nVertIndex - 1;


                TransformMatrix.Transform(dot, new Point3D(plotItem.x, plotItem.y, plotItem.z), plotItem.type, plotItem.rotmatrix);


                dot.SetColor(plotItem.color);
                meshs.Add(dot);
            }
            AddAxesMeshes(meshs);

            return(meshs);
        }
コード例 #3
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();
        }
コード例 #4
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)
            Random randomObject = new Random();
            int    nDataRange   = 200;

            for (int i = 0; i < nDotNo; i++)
            {
                ScatterPlotItem plotItem = new ScatterPlotItem();

                plotItem.w = 4;
                plotItem.h = 6;

                plotItem.x = (float)randomObject.Next(nDataRange);
                plotItem.y = (float)randomObject.Next(nDataRange);
                plotItem.z = (float)randomObject.Next(nDataRange);

                plotItem.shape = randomObject.Next(4);

                Byte nR = (Byte)randomObject.Next(256);
                Byte nG = (Byte)randomObject.Next(256);
                Byte 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
            ArrayList meshs = ((ScatterChart3D)m_3dChart).GetMeshes();

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

            // 6. display scatter plot in Viewport3D
            WPFChart3D.Model3D model3d = new WPFChart3D.Model3D();
            m_nChartModelIndex = model3d.UpdateModel(meshs, null, m_nChartModelIndex, this.mainViewport);

            // 7. set projection matrix
            float viewRange = (float)nDataRange;

            m_transformMatrix.CalculateProjectionMatrix(0, viewRange, 0, viewRange, 0, viewRange, 0.5);
            TransformChart();
        }
コード例 #5
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();
        }
コード例 #6
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);
        }
コード例 #7
0
ファイル: Window1.xaml.cs プロジェクト: Ayushbandil/FAMSim
        public void TestSimpleScatterPlot(double[,] coordinates, int numberOfPointsInCuttingRegion)
        {
            distance++;
            mygrid.UpdateLayout();
            int nDotNo = coordinates.GetLength(0);

            // 1. set the scatter plot size
            m_3dChart = new ScatterChart3D();
            m_3dChart.SetDataNo(nDotNo);

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

            for (int i = 0; i < nDotNo; i++)
            {
                ScatterPlotItem plotItem = new ScatterPlotItem();

                plotItem.x = (float)coordinates[i, 0];
                plotItem.y = (float)coordinates[i, 1];
                plotItem.z = (float)coordinates[i, 2];

                if (numberOfFlutes == 0)
                {
                    label.Content = "Distance travelled by tool = " + distance + " mm.";
                    if (i < numberOfPointsInCuttingRegion)
                    {
                        plotItem.w     = 0.25f;
                        plotItem.h     = 0.10f;
                        plotItem.shape = (int)Chart3D.SHAPE.BAR;
                        plotItem.color = Color.FromArgb(200, (byte)(160), (byte)(5), (byte)(5));
                    }
                    else
                    {
                        plotItem.w     = 0.05f;
                        plotItem.h     = 0.1f;
                        plotItem.shape = (int)Chart3D.SHAPE.BAR;
                        plotItem.color = Color.FromArgb(200, (byte)(160), (byte)(160), (byte)(160));
                    }
                }
                else
                {
                    label.Content = ("");
                    if (((int)(i / Lp)) % (Kp / numberOfFlutes) == 0)
                    {
                        int n = (int)(((int)(i / Lp)) / (Kp / numberOfFlutes));
                        plotItem.w     = 0.8f;
                        plotItem.h     = 0.20f;
                        plotItem.shape = (int)Chart3D.SHAPE.PYRAMID;
                        //plotItem.color = Color.FromArgb(200, (byte)(80), (byte)(80), (byte)(60));
                        plotItem.color = Color.FromArgb(1, (byte)(60 + 20 * n), (byte)(60 + 20 * n), (byte)(30 + 40 * n));
                    }
                    else
                    {
                        plotItem.w     = 0.2f;
                        plotItem.h     = 0.10f;
                        plotItem.shape = (int)Chart3D.SHAPE.BAR;
                        plotItem.color = Color.FromArgb(1, (byte)(160), (byte)(160), (byte)(160));
                    }
                }
                ((ScatterChart3D)m_3dChart).SetVertex(i, plotItem);
            }
            // 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
            float viewRange = (float)nDataRange;

            m_transformMatrix.CalculateProjectionMatrix(0, viewRange, 0, viewRange, 0, viewRange, 0.5);
            TransformChart();
            mainViewport.UpdateLayout();
        }
コード例 #8
0
 public void SetVertex(int n, ScatterPlotItem value)
 {
     MVertices[n] = value;
 }