コード例 #1
0
        private void AddMeshZ(Graphics g, DataSeries ds, ChartStyle cs,
            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);
            Matrix3 m = Matrix3.AzimuthElevation(va.Elevation, va.Azimuth);
            PointF[] pta = new PointF[4];
            Point3[,] pts = ds.PointArray;
            Point3[,] pts1 = new Point3[pts.GetLength(0), pts.GetLength(1)];
            Color color;

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

            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, pts[i, j].Z, 1);
                    // Perform transformations on points:
                    pts[i, j].Transform(m, chart3d, ax, cs, cl);
                }
            }

            for (int i = 0; i < pts.GetLength(0) - 1; i++)
            {
                for (int j = 0; j < pts.GetLength(1) - 1; j++)
                {
                    int ii = i;
                    if (va.Azimuth >= -180 && va.Azimuth < 0)
                    {
                        ii = pts.GetLength(0) - 2 - i;
                    }
                    pta[0] = new PointF(pts[ii, j].X, pts[ii, j].Y);
                    pta[1] = new PointF(pts[ii, j + 1].X, pts[ii, j + 1].Y);
                    pta[2] = new PointF(pts[ii + 1, j + 1].X, pts[ii + 1, j + 1].Y);
                    pta[3] = new PointF(pts[ii + 1, j].X, pts[ii + 1, j].Y);
                    g.FillPolygon(aBrush, pta);
                    if (IsColorMap)
                    {
                        color = AddColor(cs, pts[ii, j], zmin, zmax, ax, va, cl);
                        aPen = new Pen(color, ds.LineStyle.Thickness);
                        aPen.DashStyle = ds.LineStyle.Pattern;
                    }
                    g.DrawPolygon(aPen, pta);
                }
            }

            Point3[] pt3 = new Point3[4];
            for (int i = 0; i < pts1.GetLength(0); i++)
            {
                int jj = pts1.GetLength(0) - 1;
                if (va.Elevation >= 0)
                {
                    if (va.Azimuth >= -90 && va.Azimuth <= 90)
                        jj = 0;
                }
                else if (va.Elevation < 0)
                {
                    jj = 0;
                    if (va.Azimuth >= -90 && va.Azimuth <= 90)
                        jj = pts1.GetLength(0) - 1;
                }

                if (i < pts1.GetLength(0) - 1)
                {
                    pt3[0] = new Point3(pts1[i, jj].X, pts1[i, jj].Y, pts1[i, jj].Z, 1);
                    pt3[1] = new Point3(pts1[i + 1, jj].X, pts1[i + 1, jj].Y, pts1[i + 1, jj].Z, 1);
                    pt3[2] = new Point3(pts1[i + 1, jj].X, pts1[i + 1, jj].Y, ax.ZMin, 1);
                    pt3[3] = new Point3(pts1[i, jj].X, pts1[i, jj].Y, ax.ZMin, 1);
                    for (int k = 0; k < 4; k++)
                        pt3[k].Transform(m, chart3d, ax, cs, cl);
                    pta[0] = new PointF(pt3[0].X, pt3[0].Y);
                    pta[1] = new PointF(pt3[1].X, pt3[1].Y);
                    pta[2] = new PointF(pt3[2].X, pt3[2].Y);
                    pta[3] = new PointF(pt3[3].X, pt3[3].Y);
                    g.FillPolygon(aBrush, pta);
                    if (IsColorMap)
                    {
                        color = AddColor(cs, pt3[0], zmin, zmax, ax, va, cl);
                        aPen = new Pen(color, ds.LineStyle.Thickness);
                        aPen.DashStyle = ds.LineStyle.Pattern;
                    }
                    g.DrawPolygon(aPen, pta);
                }
            }
            for (int j = 0; j < pts1.GetLength(1); j++)
            {
                int ii = 0;
                if (va.Elevation >= 0)
                {
                    if (va.Azimuth >= 0 && va.Azimuth <= 180)
                        ii = pts1.GetLength(1) - 1;
                }
                else if (va.Elevation < 0)
                {
                    if (va.Azimuth >= -180 && va.Azimuth <= 0)
                        ii = pts1.GetLength(1) - 1;
                }
                if (j < pts1.GetLength(1) - 1)
                {
                    pt3[0] = new Point3(pts1[ii, j].X, pts1[ii, j].Y, pts1[ii, j].Z, 1);
                    pt3[1] = new Point3(pts1[ii, j + 1].X, pts1[ii, j + 1].Y, pts1[ii, j + 1].Z, 1);
                    pt3[2] = new Point3(pts1[ii, j + 1].X, pts1[ii, j + 1].Y, ax.ZMin, 1);
                    pt3[3] = new Point3(pts1[ii, j].X, pts1[ii, j].Y, ax.ZMin, 1);
                    for (int k = 0; k < 4; k++)
                        pt3[k].Transform(m, chart3d, ax, cs, cl);
                    pta[0] = new PointF(pt3[0].X, pt3[0].Y);
                    pta[1] = new PointF(pt3[1].X, pt3[1].Y);
                    pta[2] = new PointF(pt3[2].X, pt3[2].Y);
                    pta[3] = new PointF(pt3[3].X, pt3[3].Y);
                    g.FillPolygon(aBrush, pta);
                    if (IsColorMap)
                    {
                        color = AddColor(cs, pt3[0], zmin, zmax, ax, va, cl);
                        aPen = new Pen(color, ds.LineStyle.Thickness);
                        aPen.DashStyle = ds.LineStyle.Pattern;
                    }
                    g.DrawPolygon(aPen, pta);
                }
            }
            aPen.Dispose();
            aBrush.Dispose();
        }
コード例 #2
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();
        }
コード例 #3
0
        private void AddMesh(Graphics g, DataSeries ds, ChartStyle cs, 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);
            Matrix3 m = Matrix3.AzimuthElevation(va.Elevation, va.Azimuth);
            PointF[] pta = new PointF[4];
            Point3[,] pts = ds.PointArray;

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

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

            // Draw color mesh:
            for (int i = 0; i < pts.GetLength(0) - 1; i++)
            {
                for (int j = 0; j < pts.GetLength(1) - 1; j++)
                {
                    int ii = i;
                    if (va.Azimuth >= -180 && va.Azimuth < 0)
                    {
                        ii = pts.GetLength(0) - 2 - i;
                    }
                    pta[0] = new PointF(pts[ii, j].X, pts[ii, j].Y);
                    pta[1] = new PointF(pts[ii, j + 1].X, pts[ii, j + 1].Y);
                    pta[2] = new PointF(pts[ii + 1, j + 1].X, pts[ii + 1, j + 1].Y);
                    pta[3] = new PointF(pts[ii + 1, j].X, pts[ii + 1, j].Y);
                    if (!IsHiddenLine)
                    {
                        g.FillPolygon(aBrush, pta);
                    }
                    if (IsColorMap)
                    {
                        Color color = AddColor(cs, pts[ii, j], zmin, zmax, ax, va, cl);
                        aPen = new Pen(color, ds.LineStyle.Thickness);
                        aPen.DashStyle = ds.LineStyle.Pattern;
                    }
                    g.DrawPolygon(aPen, pta);
                }
            }
            aPen.Dispose();
            aBrush.Dispose();
        }
コード例 #4
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);
                }
            }
        }
コード例 #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);
                    }
                }
            }
        }
コード例 #6
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);
                    }
                }
            }
        }
コード例 #7
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);
                        }
                    }
                }
            }
        }
コード例 #8
0
        private void AddWaterfall(Graphics g, DataSeries ds, ChartStyle cs,
            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);
            Matrix3 m = Matrix3.AzimuthElevation(va.Elevation, va.Azimuth);
            Point3[,] pts = ds.PointArray;
            Point3[] pt3 = new Point3[pts.GetLength(0) + 2];
            PointF[] pta = new PointF[pts.GetLength(0) + 2];
            Color color;

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

            for (int j = 0; j < pts.GetLength(1); j++)
            {
                int jj = j;
                if (va.Elevation >= 0)
                {
                    if (va.Azimuth >= -90 && va.Azimuth < 90)
                    {
                        jj = pts.GetLength(1) - 1 - j;
                    }
                }
                else if (va.Elevation < 0)
                {
                    jj = pts.GetLength(1) - 1 - j;
                    if (va.Azimuth >= -90 && va.Azimuth < 90)
                    {
                        jj = j;
                    }
                }
                for (int i = 0; i < pts.GetLength(0); i++)
                {
                    pt3[i + 1] = pts[i, jj];
                    if (i == 0)
                    {
                        pt3[0] = new Point3(pt3[i + 1].X, pt3[i + 1].Y, ax.ZMin, 1);
                    }
                    if (i == pts.GetLength(0) - 1)
                    {
                        pt3[pts.GetLength(0) + 1] = new Point3(pt3[i + 1].X,
                            pt3[i + 1].Y, ax.ZMin, 1);
                    }
                }

                for (int i = 0; i < pt3.Length; i++)
                {
                    pt3[i].Transform(m, chart3d, ax, cs, cl);
                    pta[i] = new PointF(pt3[i].X, pt3[i].Y);
                }
                g.FillPolygon(aBrush, pta);

                for (int i = 1; i < pt3.Length; i++)
                {
                    if (IsColorMap)
                    {
                        color = AddColor(cs, pt3[i], zmin, zmax, ax, va, cl);
                        aPen = new Pen(color, ds.LineStyle.Thickness);
                        aPen.DashStyle = ds.LineStyle.Pattern;
                    }
                    g.DrawLine(aPen, pta[i - 1], pta[i]);
                }
            }
            aPen.Dispose();
            aBrush.Dispose();
        }