Esempio n. 1
0
 public Chart3D()
 {
     InitializeComponent();
     this.SetStyle(ControlStyles.ResizeRedraw, true);
     cs = new ChartStyle(this);
     cs2d = new ChartStyle2D(this);
     dc = new DrawChart(this);
     ds = new DataSeries();
     ax = new Axes(this);
     va = new ViewAngle(this);
     gd = new Grid(this);
     cl = new ChartLabels(this);
     gd.GridStyle.LineColor = Color.LightGray;
     this.BackColor = Color.White;
     cm = new ColorMap();
     dc.CMap = cm.Jet();
 }
Esempio n. 2
0
        private void AddSlice(Graphics g, DataSeries ds, ChartStyle cs,
            ChartStyle2D cs2d, Axes ax, ViewAngle va, ChartLabels cl)
        {
            Pen aPen = new Pen(ds.LineStyle.LineColor, ds.LineStyle.Thickness);
            aPen.DashStyle = ds.LineStyle.Pattern;
            SolidBrush aBrush = new SolidBrush(Color.Black);
            Point4[, ,] pts = ds.Point4Array;
            PointF[] pta = new PointF[4];
            Matrix3 m = Matrix3.AzimuthElevation(va.Elevation, va.Azimuth);

            // Find the minumum and maximum v values:
            float vmin = ds.VDataMin();
            float vmax = ds.VDataMax();

            // Perform transformation on points:
            for (int i = 0; i < pts.GetLength(0); i++)
            {
                for (int j = 0; j < pts.GetLength(1); j++)
                {
                    for (int k = 0; k < pts.GetLength(2); k++)
                    {
                        pts[i, j, k].point3.Transform(m, chart3d, ax, cs, cl);
                        pts[i, j, k].point3.Z = pts[i, j, k].V;
                    }
                }
            }

            // Select slice:
            if (XYZSlice == SliceEnum.XSlice)
            {
                if (SliceLocation < ax.XMin)
                    SliceLocation = ax.XMin;
                if (SliceLocation > ax.XMax)
                    SliceLocation = ax.XMax;
                int nfix = (int)((SliceLocation - ds.XDataMin) / ds.XSpacing) + 1;
                for (int j = 0; j < pts.GetLength(1) - 1; j++)
                {
                    for (int k = 0; k < pts.GetLength(2) - 1; k++)
                    {
                        pta[0] = new PointF(pts[nfix, j, k].point3.X, pts[nfix, j, k].point3.Y);
                        pta[1] = new PointF(pts[nfix, j + 1, k].point3.X, pts[nfix, j + 1, k].point3.Y);
                        pta[2] = new PointF(pts[nfix, j + 1, k + 1].point3.X, pts[nfix, j + 1, k + 1].point3.Y);
                        pta[3] = new PointF(pts[nfix, j, k + 1].point3.X, pts[nfix, j, k + 1].point3.Y);
                        Color color = AddColor(cs, pts[nfix, j, k].point3, vmin, vmax, ax, va, cl);
                        aBrush = new SolidBrush(color);
                        g.FillPolygon(aBrush, pta);
                        if (ds.LineStyle.IsVisible)
                        {
                            g.DrawPolygon(aPen, pta);
                        }
                    }
                }
            }
            else if (XYZSlice == SliceEnum.YSlice)
            {
                if (SliceLocation < ax.YMin)
                    SliceLocation = ax.YMin;
                if (SliceLocation > ax.YMax)
                    SliceLocation = ax.YMax;
                int nfix = (int)((SliceLocation - ds.YDataMin) / ds.YSpacing) + 1;
                for (int i = 0; i < pts.GetLength(0) - 1; i++)
                {
                    for (int k = 0; k < pts.GetLength(2) - 1; k++)
                    {
                        pta[0] = new PointF(pts[i, nfix, k].point3.X, pts[i, nfix, k].point3.Y);
                        pta[1] = new PointF(pts[i + 1, nfix, k].point3.X, pts[i + 1, nfix, k].point3.Y);
                        pta[2] = new PointF(pts[i + 1, nfix, k + 1].point3.X, pts[i + 1, nfix, k + 1].point3.Y);
                        pta[3] = new PointF(pts[i, nfix, k + 1].point3.X, pts[i, nfix, k + 1].point3.Y);
                        Color color = AddColor(cs, pts[i, nfix, k].point3, vmin, vmax, ax, va, cl);

                        aBrush = new SolidBrush(color);
                        g.FillPolygon(aBrush, pta);
                        if (ds.LineStyle.IsVisible)
                        {
                            g.DrawPolygon(aPen, pta);
                        }
                    }
                }
            }
            else if (XYZSlice == SliceEnum.ZSlice)
            {
                if (SliceLocation < ax.ZMin)
                    SliceLocation = ax.ZMin;
                if (SliceLocation > ax.ZMax)
                    SliceLocation = ax.ZMax;
                int nfix = (int)((SliceLocation - ds.ZZDataMin) / ds.ZSpacing) + 1;
                for (int i = 0; i < pts.GetLength(0) - 1; i++)
                {
                    for (int j = 0; j < pts.GetLength(1) - 1; j++)
                    {
                        pta[0] = new PointF(pts[i, j, nfix].point3.X, pts[i, j, nfix].point3.Y);
                        pta[1] = new PointF(pts[i + 1, j, nfix].point3.X, pts[i + 1, j, nfix].point3.Y);
                        pta[2] = new PointF(pts[i + 1, j + 1, nfix].point3.X, pts[i + 1, j + 1, nfix].point3.Y);
                        pta[3] = new PointF(pts[i, j + 1, nfix].point3.X, pts[i, j + 1, nfix].point3.Y);
                        Color color = AddColor(cs, pts[i, j, nfix].point3, vmin, vmax, ax, va, cl);
                        aBrush = new SolidBrush(color);
                        g.FillPolygon(aBrush, pta);
                        if (ds.LineStyle.IsVisible)
                        {
                            g.DrawPolygon(aPen, pta);
                        }
                    }
                }
            }
            aPen.Dispose();
            aBrush.Dispose();
        }
Esempio n. 3
0
        private void AddBar3D(Graphics g, DataSeries ds, ChartStyle cs,
            ChartStyle2D cs2d, Axes ax, ViewAngle va, ChartLabels cl)
        {
            Matrix3 m = Matrix3.AzimuthElevation(va.Elevation, va.Azimuth);
            PointF[] pt = new PointF[4];
            Point3[,] pts = ds.PointArray;

            // Find the minumum and maximum z values:
            float zmin = ds.ZDataMin();
            float zmax = ds.ZDataMax();

            // Check parameters:
            float xlength = ds.BarStyle.XLength;
            if (xlength <= 0)
                xlength = 0.1f * ds.XSpacing;
            else if (xlength > 0.5f)
                xlength = 0.5f * ds.XSpacing;
            else
                xlength = ds.BarStyle.XLength * ds.XSpacing;
            float ylength = ds.BarStyle.YLength;
            if (ylength <= 0)
                ylength = 0.1f * ds.YSpacing;
            else if (ylength > 0.5f)
                ylength = 0.5f * ds.YSpacing;
            else
                ylength = ds.BarStyle.YLength * ds.YSpacing;
            float zorigin = ds.BarStyle.ZOrigin;

            // Draw 3D bars:
            for (int i = 0; i < pts.GetLength(0) - 1; i++)
            {
                for (int j = 0; j < pts.GetLength(1) - 1; j++)
                {
                    int ii = i;
                    int jj = j;
                    if (va.Azimuth >= -180 && va.Azimuth < -90)
                    {
                        ii = pts.GetLength(0) - 2 - i;
                        jj = j;
                    }
                    else if (va.Azimuth >= -90 && va.Azimuth < 0)
                    {
                        ii = pts.GetLength(0) - 2 - i;
                        jj = pts.GetLength(1) - 2 - j;
                    }
                    else if (va.Azimuth >= 0 && va.Azimuth < 90)
                    {
                        ii = i;
                        jj = pts.GetLength(1) - 2 - j;
                    }
                    else if (va.Azimuth >= 90 && va.Azimuth <= 180)
                    {
                        ii = i;
                        jj = j;
                    }
                    DrawBar(g, ds, cs, m, pts[ii, jj], xlength,
                        ylength, zorigin, zmax, zmin, ax, va, cl);
                }
            }
        }
Esempio n. 4
0
        private void AddContour3D(Graphics g, DataSeries ds, ChartStyle cs,
            ChartStyle2D cs2d, Axes ax, ViewAngle va, ChartLabels cl)
        {
            Pen aPen = new Pen(ds.LineStyle.LineColor, ds.LineStyle.Thickness);
            aPen.DashStyle = ds.LineStyle.Pattern;
            Point3[] pta = new Point3[2];
            Point3[,] pts = ds.PointArray;
            Matrix3 m = Matrix3.AzimuthElevation(va.Elevation, va.Azimuth);

            // Find the minumum and maximum z values:
            float zmin = ds.ZDataMin();
            float zmax = ds.ZDataMax();
            float[] zlevels = new float[numberContours];
            for (int i = 0; i < numberContours; i++)
            {
                zlevels[i] = zmin + i * (zmax - zmin) / (numberContours - 1);
            }

            int i0, i1, i2, j0, j1, j2;
            float zratio = 1;
            // Draw contour on the XY plane:
            for (int i = 0; i < pts.GetLength(0) - 1; i++)
            {
                for (int j = 0; j < pts.GetLength(1) - 1; j++)
                {
                    for (int k = 0; k < numberContours; k++)
                    {
                        if (IsColorMap && ChartType != ChartTypeEnum.FillContour &&
                            ChartType != ChartTypeEnum.SurfaceFillContour)
                        {
                            Color color = AddColor(cs, pts[i, j], zmin, zmax, ax, va, cl);
                            aPen = new Pen(color, ds.LineStyle.Thickness);
                            aPen.DashStyle = ds.LineStyle.Pattern;
                        }

                        // Left triangle:
                        i0 = i;
                        j0 = j;
                        i1 = i;
                        j1 = j + 1;
                        i2 = i + 1;
                        j2 = j + 1;
                        if ((zlevels[k] >= pts[i0, j0].Z && zlevels[k] < pts[i1, j1].Z ||
                            zlevels[k] < pts[i0, j0].Z && zlevels[k] >= pts[i1, j1].Z) &&
                            (zlevels[k] >= pts[i1, j1].Z && zlevels[k] < pts[i2, j2].Z ||
                            zlevels[k] < pts[i1, j1].Z && zlevels[k] >= pts[i2, j2].Z))
                        {
                            zratio = (zlevels[k] - pts[i0, j0].Z) /
                                (pts[i1, j1].Z - pts[i0, j0].Z);
                            pta[0] = new Point3(pts[i0, j0].X, (1 - zratio) *
                                pts[i0, j0].Y + zratio * pts[i1, j1].Y, ax.ZMin, 1);
                            zratio = (zlevels[k] - pts[i1, j1].Z) /
                                (pts[i2, j2].Z - pts[i1, j1].Z);
                            pta[1] = new Point3((1 - zratio) * pts[i1, j1].X +
                                zratio * pts[i2, j2].X, pts[i1, j1].Y, ax.ZMin, 1);
                            pta[0].Transform(m, chart3d, ax, cs, cl);
                            pta[1].Transform(m, chart3d, ax, cs, cl);
                            g.DrawLine(aPen, pta[0].X, pta[0].Y, pta[1].X, pta[1].Y);
                        }
                        else if ((zlevels[k] >= pts[i0, j0].Z && zlevels[k] < pts[i2, j2].Z ||
                            zlevels[k] < pts[i0, j0].Z && zlevels[k] >= pts[i2, j2].Z) &&
                            (zlevels[k] >= pts[i1, j1].Z && zlevels[k] < pts[i2, j2].Z ||
                            zlevels[k] < pts[i1, j1].Z && zlevels[k] >= pts[i2, j2].Z))
                        {
                            zratio = (zlevels[k] - pts[i0, j0].Z) /
                                (pts[i2, j2].Z - pts[i0, j0].Z);
                            pta[0] = new Point3((1 - zratio) * pts[i0, j0].X +
                                zratio * pts[i2, j2].X, (1 - zratio) * pts[i0, j0].Y +
                                zratio * pts[i2, j2].Y, ax.ZMin, 1);
                            zratio = (zlevels[k] - pts[i1, j1].Z) /
                               (pts[i2, j2].Z - pts[i1, j1].Z);
                            pta[1] = new Point3((1 - zratio) * pts[i1, j1].X +
                                zratio * pts[i2, j2].X, pts[i1, j1].Y, ax.ZMin, 1);
                            pta[0].Transform(m, chart3d, ax, cs, cl);
                            pta[1].Transform(m, chart3d, ax, cs, cl);
                            g.DrawLine(aPen, pta[0].X, pta[0].Y, pta[1].X, pta[1].Y);
                        }
                        else if ((zlevels[k] >= pts[i0, j0].Z && zlevels[k] < pts[i1, j1].Z ||
                            zlevels[k] < pts[i0, j0].Z && zlevels[k] >= pts[i1, j1].Z) &&
                            (zlevels[k] >= pts[i0, j0].Z && zlevels[k] < pts[i2, j2].Z ||
                            zlevels[k] < pts[i0, j0].Z && zlevels[k] >= pts[i2, j2].Z))
                        {
                            zratio = (zlevels[k] - pts[i0, j0].Z) /
                                (pts[i1, j1].Z - pts[i0, j0].Z);
                            pta[0] = new Point3(pts[i0, j0].X, (1 - zratio) *
                                pts[i0, j0].Y + zratio * pts[i1, j1].Y, ax.ZMin, 1);
                            zratio = (zlevels[k] - pts[i0, j0].Z) /
                                (pts[i2, j2].Z - pts[i0, j0].Z);
                            pta[1] = new Point3(pts[i0, j0].X * (1 - zratio) +
                                pts[i2, j2].X * zratio, pts[i0, j0].Y * (1 - zratio) +
                                pts[i2, j2].Y * zratio, ax.ZMin, 1);
                            pta[0].Transform(m, chart3d, ax, cs, cl);
                            pta[1].Transform(m, chart3d, ax, cs, cl);
                            g.DrawLine(aPen, pta[0].X, pta[0].Y, pta[1].X, pta[1].Y);
                        }

                        // right triangle:
                        i0 = i;
                        j0 = j;
                        i1 = i + 1;
                        j1 = j;
                        i2 = i + 1;
                        j2 = j + 1;
                        if ((zlevels[k] >= pts[i0, j0].Z && zlevels[k] < pts[i1, j1].Z ||
                            zlevels[k] < pts[i0, j0].Z && zlevels[k] >= pts[i1, j1].Z) &&
                            (zlevels[k] >= pts[i1, j1].Z && zlevels[k] < pts[i2, j2].Z ||
                            zlevels[k] < pts[i1, j1].Z && zlevels[k] >= pts[i2, j2].Z))
                        {
                            zratio = (zlevels[k] - pts[i0, j0].Z) /
                                (pts[i1, j1].Z - pts[i0, j0].Z);
                            pta[0] = new Point3(pts[i0, j0].X * (1 - zratio) +
                                pts[i1, j1].X * zratio, pts[i0, j0].Y, ax.ZMin, 1);
                            zratio = (zlevels[k] - pts[i1, j1].Z) /
                                (pts[i2, j2].Z - pts[i1, j1].Z);
                            pta[1] = new Point3(pts[i1, j1].X, pts[i1, j1].Y *
                                (1 - zratio) + pts[i2, j2].Y * zratio, ax.ZMin, 1);
                            pta[0].Transform(m, chart3d, ax, cs, cl);
                            pta[1].Transform(m, chart3d, ax, cs, cl);
                            g.DrawLine(aPen, pta[0].X, pta[0].Y, pta[1].X, pta[1].Y);
                        }
                        else if ((zlevels[k] >= pts[i0, j0].Z && zlevels[k] < pts[i2, j2].Z ||
                            zlevels[k] < pts[i0, j0].Z && zlevels[k] >= pts[i2, j2].Z) &&
                            (zlevels[k] >= pts[i1, j1].Z && zlevels[k] < pts[i2, j2].Z ||
                            zlevels[k] < pts[i1, j1].Z && zlevels[k] >= pts[i2, j2].Z))
                        {
                            zratio = (zlevels[k] - pts[i0, j0].Z) /
                                (pts[i2, j2].Z - pts[i0, j0].Z);
                            pta[0] = new Point3(pts[i0, j0].X * (1 - zratio) +
                                pts[i2, j2].X * zratio, pts[i0, j0].Y * (1 - zratio) +
                                pts[i2, j2].Y * zratio, ax.ZMin, 1);
                            zratio = (zlevels[k] - pts[i1, j1].Z) /
                                (pts[i2, j2].Z - pts[i1, j1].Z);
                            pta[1] = new Point3(pts[i1, j1].X, pts[i1, j1].Y *
                                (1 - zratio) + pts[i2, j2].Y * zratio, ax.ZMin, 1);
                            pta[0].Transform(m, chart3d, ax, cs, cl);
                            pta[1].Transform(m, chart3d, ax, cs, cl);
                            g.DrawLine(aPen, pta[0].X, pta[0].Y, pta[1].X, pta[1].Y);
                        }
                        else if ((zlevels[k] >= pts[i0, j0].Z && zlevels[k] < pts[i1, j1].Z ||
                            zlevels[k] < pts[i0, j0].Z && zlevels[k] >= pts[i1, j1].Z) &&
                            (zlevels[k] >= pts[i0, j0].Z && zlevels[k] < pts[i2, j2].Z ||
                            zlevels[k] < pts[i0, j0].Z && zlevels[k] >= pts[i2, j2].Z))
                        {
                            zratio = (zlevels[k] - pts[i0, j0].Z) /
                                (pts[i1, j1].Z - pts[i0, j0].Z);
                            pta[0] = new Point3(pts[i0, j0].X * (1 - zratio) +
                                pts[i1, j1].X * zratio, pts[i0, j0].Y, ax.ZMin, 1);
                            zratio = (zlevels[k] - pts[i0, j0].Z) /
                                (pts[i2, j2].Z - pts[i0, j0].Z);
                            pta[1] = new Point3(pts[i0, j0].X * (1 - zratio) +
                                pts[i2, j2].X * zratio, pts[i0, j0].Y * (1 - zratio) +
                                pts[i2, j2].Y * zratio, ax.ZMin, 1);
                            pta[0].Transform(m, chart3d, ax, cs, cl);
                            pta[1].Transform(m, chart3d, ax, cs, cl);
                            g.DrawLine(aPen, pta[0].X, pta[0].Y, pta[1].X, pta[1].Y);
                        }
                    }
                }
            }
            aPen.Dispose();
        }
Esempio n. 5
0
        public void AddColorBar(Graphics g, DataSeries ds, ChartStyle cs,
            ChartStyle2D cs2d, Axes ax, ViewAngle va, ChartLabels cl)
        {
            if (cs.IsColorBar && IsColorMap)
            {
                Pen aPen = new Pen(Color.Black, 1);
                SolidBrush aBrush = new SolidBrush(cl.TickFontColor);
                StringFormat sFormat = new StringFormat();
                sFormat.Alignment = StringAlignment.Near;
                SizeF size = g.MeasureString("A", cl.TickFont);

                int x, y, width, height;
                Point3[] pts = new Point3[64];
                PointF[] pta = new PointF[4];
                float zmin, zmax;
                if (ChartType == ChartTypeEnum.Slice)
                {
                    zmin = ds.VDataMin();
                    zmax = ds.VDataMax();
                }
                else
                {
                    zmin = ds.ZDataMin();
                    zmax = ds.ZDataMax();
                }
                float dz = (zmax - zmin) / 63;
                if (ChartType == ChartTypeEnum.Contour ||
                    ChartType == ChartTypeEnum.FillContour ||
                    ChartType == ChartTypeEnum.XYColor)
                {
                    x = 5 * cs2d.ChartArea.Width / 6;
                    y = cs2d.PlotArea.Y;
                    width = cs2d.ChartArea.Width / 25;
                    height = cs2d.PlotArea.Height;
                    // Add color bar:
                    for (int i = 0; i < 64; i++)
                    {
                        pts[i] = new Point3(x, y, zmin + i * dz, 1);
                    }
                    for (int i = 0; i < 63; i++)
                    {
                        Color color = AddColor(cs, pts[i], zmin, zmax, ax, va, cl);
                        aBrush = new SolidBrush(color);
                        float y1 = y + height - (pts[i].Z - zmin) * height / (zmax - zmin);
                        float y2 = y + height - (pts[i + 1].Z - zmin) * height / (zmax - zmin);
                        pta[0] = new PointF(x, y2);
                        pta[1] = new PointF(x + width, y2);
                        pta[2] = new PointF(x + width, y1);
                        pta[3] = new PointF(x, y1);
                        g.FillPolygon(aBrush, pta);
                    }
                    g.DrawRectangle(aPen, x, y, width, height);

                    // Add ticks and labels to the color bar:
                    float ticklength = 0.1f * width;
                    for (float z = zmin; z <= zmax; z = z + (zmax - zmin) / 6)
                    {
                        float yy = y + height - (z - zmin) * height / (zmax - zmin);
                        g.DrawLine(aPen, x, yy, x + ticklength, yy);
                        g.DrawLine(aPen, x + width, yy, x + width - ticklength, yy);
                        g.DrawString((Math.Round(z, 2)).ToString(), cl.TickFont, Brushes.Black,
                            new PointF(x + width + 5, yy - size.Height / 2), sFormat);
                    }
                }
                else
                {
                    x = 5 * cs2d.ChartArea.Width / 6;
                    y = cs2d.ChartArea.Height / 10;
                    width = cs2d.ChartArea.Width / 25;
                    height = 8 * cs2d.ChartArea.Height / 10;

                    // Add color bar:
                    for (int i = 0; i < 64; i++)
                    {
                        pts[i] = new Point3(x, y, zmin + i * dz, 1);
                    }
                    for (int i = 0; i < 63; i++)
                    {
                        Color color = AddColor(cs, pts[i], zmin, zmax, ax, va, cl);
                        aBrush = new SolidBrush(color);
                        float y1 = y + height - (pts[i].Z - zmin) * height / (zmax - zmin);
                        float y2 = y + height - (pts[i + 1].Z - zmin) * height / (zmax - zmin);
                        pta[0] = new PointF(x, y2);
                        pta[1] = new PointF(x + width, y2);
                        pta[2] = new PointF(x + width, y1);
                        pta[3] = new PointF(x, y1);
                        g.FillPolygon(aBrush, pta);
                    }
                    g.DrawRectangle(aPen, x, y, width, height);

                    // Add ticks and labels to the color bar:
                    float ticklength = 0.1f * width;
                    for (float z = zmin; z <= zmax; z = z + (zmax - zmin) / 6)
                    {
                        float yy = y + height - (z - zmin) * height / (zmax - zmin);
                        g.DrawLine(aPen, x, yy, x + ticklength, yy);
                        g.DrawLine(aPen, x + width, yy, x + width - ticklength, yy);
                        g.DrawString((Math.Round(z, 2)).ToString(), cl.TickFont, Brushes.Black,
                            new PointF(x + width + 5, yy - size.Height / 2), sFormat);
                    }
                }
            }
        }
Esempio n. 6
0
 public void AddChart(Graphics g, DataSeries ds, ChartStyle cs,
     ChartStyle2D cs2d, Axes ax, ViewAngle va, ChartLabels cl)
 {
     switch (ChartType)
     {
         case ChartTypeEnum.Line:
             AddLine(g, ds, cs, ax, va, cl);
             break;
         case ChartTypeEnum.Mesh:
             AddMesh(g, ds, cs, ax, va, cl);
             AddColorBar(g, ds, cs, cs2d, ax, va, cl);
             break;
         case ChartTypeEnum.MeshZ:
             AddMeshZ(g, ds, cs, ax, va, cl);
             AddColorBar(g, ds, cs, cs2d, ax, va, cl);
             break;
         case ChartTypeEnum.Waterfall:
             AddWaterfall(g, ds, cs, ax, va, cl);
             AddColorBar(g, ds, cs, cs2d, ax, va, cl);
             break;
         case ChartTypeEnum.Surface:
             AddSurface(g, ds, cs, cs2d, ax, va, cl);
             AddColorBar(g, ds, cs, cs2d, ax, va, cl);
             break;
         case ChartTypeEnum.XYColor:
             AddXYColor(g, ds, cs, cs2d, ax, va, cl);
             break;
         case ChartTypeEnum.Contour:
             AddContour(g, ds, cs, cs2d, ax, va, cl);
             break;
         case ChartTypeEnum.FillContour:
             AddXYColor(g, ds, cs, cs2d, ax, va, cl);
             AddContour(g, ds, cs, cs2d, ax, va, cl);
             break;
         case ChartTypeEnum.MeshContour:
             AddContour3D(g, ds, cs, cs2d, ax, va, cl);
             AddMesh(g, ds, cs, ax, va, cl);
             AddColorBar(g, ds, cs, cs2d, ax, va, cl);
             break;
         case ChartTypeEnum.SurfaceContour:
             AddContour3D(g, ds, cs, cs2d, ax, va, cl);
             AddSurface(g, ds, cs, cs2d, ax, va, cl);
             AddColorBar(g, ds, cs, cs2d, ax, va, cl);
             break;
         case ChartTypeEnum.SurfaceFillContour:
             AddXYColor3D(g, ds, cs, cs2d, ax, va, cl);
             AddContour3D(g, ds, cs, cs2d, ax, va, cl);
             AddSurface(g, ds, cs, cs2d, ax, va, cl);
             AddColorBar(g, ds, cs, cs2d, ax, va, cl);
             break;
         case ChartTypeEnum.Slice:
             AddSlice(g, ds, cs, cs2d, ax, va, cl);
             AddColorBar(g, ds, cs, cs2d, ax, va, cl);
             break;
         case ChartTypeEnum.Bar3D:
             AddBar3D(g, ds, cs, cs2d, ax, va, cl);
             AddColorBar(g, ds, cs, cs2d, ax, va, cl);
             break;
     }
 }
Esempio n. 7
0
        private void Interp(Graphics g, ChartStyle cs, ChartStyle2D cs2d, Matrix3 m,
            Point3[] pta, float zmin, float zmax, int flag, Axes ax,
            ViewAngle va, ChartLabels cl)
        {
            SolidBrush aBrush = new SolidBrush(Color.Black);
            PointF[] points = new PointF[4];
            int npoints = NumberInterp;
            Point3[,] pts = new Point3[npoints + 1, npoints + 1];
            Point3[,] pts1 = new Point3[npoints + 1, npoints + 1];
            float x0 = pta[0].X;
            float y0 = pta[0].Y;
            float x1 = pta[2].X;
            float y1 = pta[2].Y;
            float dx = (x1 - x0) / npoints;
            float dy = (y1 - y0) / npoints;
            float C00 = pta[0].Z;
            float C10 = pta[3].Z;
            float C11 = pta[2].Z;
            float C01 = pta[1].Z;
            float x, y, C;
            Color color;

            if (flag == 1) // For Surface chart
            {
                for (int i = 0; i <= npoints; i++)
                {
                    x = x0 + i * dx;
                    for (int j = 0; j <= npoints; j++)
                    {
                        y = y0 + j * dy;
                        C = (y1 - y) * ((x1 - x) * C00 +
                            (x - x0) * C10) / (x1 - x0) / (y1 - y0) +
                            (y - y0) * ((x1 - x) * C01 +
                            (x - x0) * C11) / (x1 - x0) / (y1 - y0);
                        pts[i, j] = new Point3(x, y, C, 1);
                        pts[i, j].Transform(m, chart3d, ax, cs, cl);
                    }
                }

                for (int i = 0; i < npoints; i++)
                {
                    for (int j = 0; j < npoints; j++)
                    {

                        color = AddColor(cs, pts[i, j], zmin, zmax, ax, va, cl);
                        aBrush = new SolidBrush(color);
                        points[0] = new PointF(pts[i, j].X, pts[i, j].Y);
                        points[1] = new PointF(pts[i + 1, j].X, pts[i + 1, j].Y);
                        points[2] = new PointF(pts[i + 1, j + 1].X, pts[i + 1, j + 1].Y);
                        points[3] = new PointF(pts[i, j + 1].X, pts[i, j + 1].Y);
                        g.FillPolygon(aBrush, points);
                        aBrush.Dispose();
                    }
                }
            }
            else if (flag == 2) // For XYColor chart
            {
                for (int i = 0; i <= npoints; i++)
                {
                    x = x0 + i * dx;
                    for (int j = 0; j <= npoints; j++)
                    {
                        y = y0 + j * dy;
                        C = (y1 - y) * ((x1 - x) * C00 +
                            (x - x0) * C10) / (x1 - x0) / (y1 - y0) +
                            (y - y0) * ((x1 - x) * C01 +
                            (x - x0) * C11) / (x1 - x0) / (y1 - y0);
                        pts[i, j] = new Point3(x, y, C, 1);
                    }
                }

                for (int i = 0; i < npoints; i++)
                {
                    for (int j = 0; j < npoints; j++)
                    {

                        color = AddColor(cs, pts[i, j], zmin, zmax, ax, va, cl);
                        aBrush = new SolidBrush(color);
                        points[0] = cs2d.Point2D(new PointF(pts[i, j].X, pts[i, j].Y), ax);
                        points[1] = cs2d.Point2D(new PointF(pts[i + 1, j].X, pts[i + 1, j].Y), ax);
                        points[2] = cs2d.Point2D(new PointF(pts[i + 1, j + 1].X, pts[i + 1, j + 1].Y), ax);
                        points[3] = cs2d.Point2D(new PointF(pts[i, j + 1].X, pts[i, j + 1].Y), ax);
                        g.FillPolygon(aBrush, points);
                        aBrush.Dispose();
                    }
                }
            }
            else if (flag == 3)  // For XYColor3D chart
            {
                for (int i = 0; i <= npoints; i++)
                {
                    x = x0 + i * dx;
                    for (int j = 0; j <= npoints; j++)
                    {
                        y = y0 + j * dy;
                        C = (y1 - y) * ((x1 - x) * C00 +
                            (x - x0) * C10) / (x1 - x0) / (y1 - y0) +
                            (y - y0) * ((x1 - x) * C01 +
                            (x - x0) * C11) / (x1 - x0) / (y1 - y0);
                        pts1[i, j] = new Point3(x, y, C, 1);
                        pts[i, j] = new Point3(x, y, ax.ZMin, 1);
                        pts[i, j].Transform(m, chart3d, ax, cs, cl);
                    }
                }

                for (int i = 0; i < npoints; i++)
                {
                    for (int j = 0; j < npoints; j++)
                    {

                        color = AddColor(cs, pts1[i, j], zmin, zmax, ax, va, cl);
                        aBrush = new SolidBrush(color);
                        points[0] = new PointF(pts[i, j].X, pts[i, j].Y);
                        points[1] = new PointF(pts[i + 1, j].X, pts[i + 1, j].Y);
                        points[2] = new PointF(pts[i + 1, j + 1].X, pts[i + 1, j + 1].Y);
                        points[3] = new PointF(pts[i, j + 1].X, pts[i, j + 1].Y);
                        g.FillPolygon(aBrush, points);
                        aBrush.Dispose();
                    }
                }
            }
        }
Esempio n. 8
0
        private void AddXYColor3D(Graphics g, DataSeries ds, ChartStyle cs,
            ChartStyle2D cs2d, Axes ax, ViewAngle va, ChartLabels cl)
        {
            Pen aPen = new Pen(ds.LineStyle.LineColor, ds.LineStyle.Thickness);
            aPen.DashStyle = ds.LineStyle.Pattern;
            SolidBrush aBrush = new SolidBrush(Color.White);
            PointF[] pta = new PointF[4];
            Point3[,] pts = ds.PointArray;
            Point3[,] pts1 = new Point3[pts.GetLength(0), pts.GetLength(1)];
            Point3[,] pts2 = new Point3[pts.GetLength(0), pts.GetLength(1)];
            Matrix3 m = Matrix3.AzimuthElevation(va.Elevation, va.Azimuth);

            // Find the minumum and maximum z values:
            float zmin = ds.ZDataMin();
            float zmax = ds.ZDataMax();

            // Perform transformation on points:
            for (int i = 0; i < pts.GetLength(0); i++)
            {
                for (int j = 0; j < pts.GetLength(1); j++)
                {
                    // Make a deep copy the points array:
                    pts1[i, j] = new Point3(pts[i, j].X, pts[i, j].Y, ax.ZMin, 1);
                    pts2[i, j] = new Point3(pts[i, j].X, pts[i, j].Y, ax.ZMin, 1);
                    pts1[i, j].Transform(m, chart3d, ax, cs, cl);
                }
            }

            // Draw surface on the XY plane:
            if (!IsInterp)
            {
                for (int i = 0; i < pts.GetLength(0) - 1; i++)
                {
                    for (int j = 0; j < pts.GetLength(1) - 1; j++)
                    {
                        pta[0] = new PointF(pts1[i, j].X, pts1[i, j].Y);
                        pta[1] = new PointF(pts1[i, j + 1].X, pts1[i, j + 1].Y);
                        pta[2] = new PointF(pts1[i + 1, j + 1].X, pts1[i + 1, j + 1].Y);
                        pta[3] = new PointF(pts1[i + 1, j].X, pts1[i + 1, j].Y);
                        Color color = AddColor(cs, pts[i, j], zmin, zmax, ax, va, cl);
                        aBrush = new SolidBrush(color);
                        g.FillPolygon(aBrush, pta);
                        if (ds.LineStyle.IsVisible)
                        {
                            //g.DrawPolygon(aPen, pta);
                        }
                    }
                }
            }

            // Draw refined surface:
            else if (IsInterp)
            {
                for (int i = 0; i < pts1.GetLength(0) - 1; i++)
                {
                    for (int j = 0; j < pts1.GetLength(1) - 1; j++)
                    {
                        Point3[] points = new Point3[4];
                        points[0] = pts[i, j];
                        points[1] = pts[i, j + 1];
                        points[2] = pts[i + 1, j + 1];
                        points[3] = pts[i + 1, j];
                        Interp(g, cs, cs2d, m, points, zmin, zmax, 3, ax, va, cl);
                    }
                }
            }
        }
Esempio n. 9
0
        private void AddXYColor(Graphics g, DataSeries ds, ChartStyle cs,
            ChartStyle2D cs2d, Axes ax, ViewAngle va, ChartLabels cl)
        {
            Pen aPen = new Pen(ds.LineStyle.LineColor, ds.LineStyle.Thickness);
            aPen.DashStyle = ds.LineStyle.Pattern;
            SolidBrush aBrush = new SolidBrush(Color.White);
            PointF[] pta = new PointF[4];
            Point3[,] pts = ds.PointArray;
            Matrix3 m = new Matrix3();

            // Find the minumum and maximum z values:
            float zmin = ds.ZDataMin();
            float zmax = ds.ZDataMax();

            // Draw surface on the XY plane:
            if (!IsInterp)
            {
                for (int i = 0; i < pts.GetLength(0) - 1; i++)
                {
                    for (int j = 0; j < pts.GetLength(1) - 1; j++)
                    {
                        pta[0] = cs2d.Point2D(new PointF(pts[i, j].X, pts[i, j].Y), ax);
                        pta[1] = cs2d.Point2D(new PointF(pts[i, j + 1].X, pts[i, j + 1].Y), ax);
                        pta[2] = cs2d.Point2D(new PointF(pts[i + 1, j + 1].X, pts[i + 1, j + 1].Y), ax);
                        pta[3] = cs2d.Point2D(new PointF(pts[i + 1, j].X, pts[i + 1, j].Y), ax);
                        Color color = AddColor(cs, pts[i, j], zmin, zmax, ax, va, cl);
                        aBrush = new SolidBrush(color);
                        g.FillPolygon(aBrush, pta);
                        if (ds.LineStyle.IsVisible)
                        {
                            g.DrawPolygon(aPen, pta);
                        }
                    }
                }
            }

            // Draw refined surface:
            else if (IsInterp)
            {
                for (int i = 0; i < pts.GetLength(0) - 1; i++)
                {
                    for (int j = 0; j < pts.GetLength(1) - 1; j++)
                    {
                        Point3[] points = new Point3[4];

                        points[0] = pts[i, j];
                        points[1] = pts[i, j + 1];
                        points[2] = pts[i + 1, j + 1];
                        points[3] = pts[i + 1, j];

                        Interp(g, cs, cs2d, m, points, zmin, zmax, 2, ax, va, cl);

                        pta[0] = cs2d.Point2D(new PointF(pts[i, j].X, pts[i, j].Y), ax);
                        pta[1] = cs2d.Point2D(new PointF(pts[i, j + 1].X, pts[i, j + 1].Y), ax);
                        pta[2] = cs2d.Point2D(new PointF(pts[i + 1, j + 1].X, pts[i + 1, j + 1].Y), ax);
                        pta[3] = cs2d.Point2D(new PointF(pts[i + 1, j].X, pts[i + 1, j].Y), ax);

                        if (ds.LineStyle.IsVisible)
                        {
                            g.DrawPolygon(aPen, pta);
                        }
                    }
                }
            }
        }