Exemplo n.º 1
0
        public void AddChartStyle2D(Graphics g, ChartStyle cs3d, Axes ax, Grid gd, 
            ChartLabels cl)
        {
            SetPlotArea(g, cs3d, cl, ax);
            Pen aPen = new Pen(Color.Black, 1f);

            SizeF tickFontSize = g.MeasureString("A", cl.TickFont);
            // Create vertical gridlines:
            float fX, fY;
            if (gd.IsYGrid == true)
            {
                aPen = new Pen(gd.GridStyle.LineColor, 1f);
                aPen.DashStyle = gd.GridStyle.Pattern;
                for (fX = ax.XMin + ax.XTick; fX < ax.XMax; fX += ax.XTick)
                {
                    g.DrawLine(aPen, Point2D(new PointF(fX, ax.YMin), ax),
                        Point2D(new PointF(fX, ax.YMax), ax));
                }
            }

            // Create horizontal gridlines:
            if (gd.IsXGrid == true)
            {
                aPen = new Pen(gd.GridStyle.LineColor, 1f);
                aPen.DashStyle = gd.GridStyle.Pattern;
                for (fY = ax.YMin + ax.YTick; fY < ax.YMax; fY += ax.YTick)
                {
                    g.DrawLine(aPen, Point2D(new PointF(ax.XMin, fY),ax),
                        Point2D(new PointF(ax.XMax, fY),ax));
                }
            }

            // Create the x-axis tick marks:
            for (fX = ax.XMin; fX <= ax.XMax; fX += ax.XTick)
            {
                PointF yAxisPoint = Point2D(new PointF(fX, ax.YMin), ax);
                g.DrawLine(Pens.Black, yAxisPoint, new PointF(yAxisPoint.X,
                                   yAxisPoint.Y - 5f));
            }

            // Create the y-axis tick marks:
            for (fY = ax.YMin; fY <= ax.YMax; fY += ax.YTick)
            {
                PointF xAxisPoint = Point2D(new PointF(ax.XMin, fY), ax);
                g.DrawLine(Pens.Black, xAxisPoint,
                    new PointF(xAxisPoint.X + 5f, xAxisPoint.Y));
            }
            aPen.Dispose();
        }
Exemplo n.º 2
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();
 }
Exemplo n.º 3
0
        private void AddGrids(Graphics g, Axes ax, ViewAngle va, Grid gd, ChartLabels cl)
        {
            Matrix3 m = Matrix3.AzimuthElevation(va.Elevation, va.Azimuth);
            Point3[] pta = new Point3[3];
            Point3[] pts = CoordinatesOfChartBox(ax, va);
            Pen aPen = new Pen(gd.GridStyle.LineColor, gd.GridStyle.Thickness);
            aPen.DashStyle = gd.GridStyle.Pattern;

            // Draw x gridlines:
            if (gd.IsXGrid)
            {
                for (float x = ax.XMin; x <= ax.XMax; x = x + ax.XTick)
                {
                    pts = CoordinatesOfChartBox(ax, va);
                    pta[0] = new Point3(x, pts[1].Y, pts[1].Z, pts[1].W);
                    if (va.Elevation >= 0)
                    {
                        if ((va.Azimuth >= -180 && va.Azimuth < -90) ||
                            (va.Azimuth >= 0 && va.Azimuth < 90))
                        {
                            pta[1] = new Point3(x, pts[0].Y, pts[1].Z, pts[1].W);
                            pta[2] = new Point3(x, pts[0].Y, pts[3].Z, pts[1].W);
                        }
                        else
                        {
                            pta[1] = new Point3(x, pts[2].Y, pts[1].Z, pts[1].W);
                            pta[2] = new Point3(x, pts[2].Y, pts[3].Z, pts[1].W);

                        }
                    }
                    else if (va.Elevation < 0)
                    {
                        if ((va.Azimuth >= -180 && va.Azimuth < -90) ||
                            (va.Azimuth >= 0 && va.Azimuth < 90))
                        {
                            pta[1] = new Point3(x, pts[2].Y, pts[1].Z, pts[1].W);
                            pta[2] = new Point3(x, pts[2].Y, pts[3].Z, pts[1].W);

                        }
                        else
                        {
                            pta[1] = new Point3(x, pts[0].Y, pts[1].Z, pts[1].W);
                            pta[2] = new Point3(x, pts[0].Y, pts[3].Z, pts[1].W);
                        }
                    }
                    for (int i = 0; i < pta.Length; i++)
                    {
                        pta[i].Transform(m, chart3d, ax, this, cl);
                    }
                    g.DrawLine(aPen, pta[0].X, pta[0].Y, pta[1].X, pta[1].Y);
                    g.DrawLine(aPen, pta[1].X, pta[1].Y, pta[2].X, pta[2].Y);
                }
            }
            // Draw y gridlines:
            if (gd.IsYGrid)
            {
                for (float y = ax.YMin; y <= ax.YMax; y = y + ax.YTick)
                {
                    pts = CoordinatesOfChartBox(ax, va);
                    pta[0] = new Point3(pts[1].X, y, pts[1].Z, pts[1].W);
                    if (va.Elevation >= 0)
                    {
                        if ((va.Azimuth >= -180 && va.Azimuth < -90) ||
                            (va.Azimuth >= 0 && va.Azimuth < 90))
                        {
                            pta[1] = new Point3(pts[2].X, y, pts[1].Z, pts[1].W);
                            pta[2] = new Point3(pts[2].X, y, pts[3].Z, pts[1].W);
                        }
                        else
                        {
                            pta[1] = new Point3(pts[0].X, y, pts[1].Z, pts[1].W);
                            pta[2] = new Point3(pts[0].X, y, pts[3].Z, pts[1].W);
                        }
                    }
                    if (va.Elevation < 0)
                    {
                        if ((va.Azimuth >= -180 && va.Azimuth < -90) ||
                            (va.Azimuth >= 0 && va.Azimuth < 90))
                        {
                            pta[1] = new Point3(pts[0].X, y, pts[1].Z, pts[1].W);
                            pta[2] = new Point3(pts[0].X, y, pts[3].Z, pts[1].W);

                        }
                        else
                        {
                            pta[1] = new Point3(pts[2].X, y, pts[1].Z, pts[1].W);
                            pta[2] = new Point3(pts[2].X, y, pts[3].Z, pts[1].W);
                        }
                    }
                    for (int i = 0; i < pta.Length; i++)
                    {
                        pta[i].Transform(m, chart3d, ax, this, cl);
                    }
                    g.DrawLine(aPen, pta[0].X, pta[0].Y, pta[1].X, pta[1].Y);
                    g.DrawLine(aPen, pta[1].X, pta[1].Y, pta[2].X, pta[2].Y);
                }
            }

            // Draw Z gridlines:
            if (gd.IsZGrid)
            {
                for (float z = ax.ZMin; z <= ax.ZMax; z = z + ax.ZTick)
                {
                    pts = CoordinatesOfChartBox(ax, va);
                    pta[0] = new Point3(pts[2].X, pts[2].Y, z, pts[2].W);
                    if (va.Elevation >= 0)
                    {
                        if ((va.Azimuth >= -180 && va.Azimuth < -90) ||
                            (va.Azimuth >= 0 && va.Azimuth < 90))
                        {
                            pta[1] = new Point3(pts[2].X, pts[0].Y, z, pts[1].W);
                            pta[2] = new Point3(pts[0].X, pts[0].Y, z, pts[1].W);
                        }
                        else
                        {
                            pta[1] = new Point3(pts[0].X, pts[2].Y, z, pts[1].W);
                            pta[2] = new Point3(pts[0].X, pts[1].Y, z, pts[1].W);
                        }
                    }
                    if (va.Elevation < 0)
                    {
                        if ((va.Azimuth >= -180 && va.Azimuth < -90) ||
                            (va.Azimuth >= 0 && va.Azimuth < 90))
                        {
                            pta[1] = new Point3(pts[0].X, pts[2].Y, z, pts[1].W);
                            pta[2] = new Point3(pts[0].X, pts[0].Y, z, pts[1].W);

                        }
                        else
                        {
                            pta[1] = new Point3(pts[2].X, pts[0].Y, z, pts[1].W);
                            pta[2] = new Point3(pts[0].X, pts[0].Y, z, pts[1].W);
                        }
                    }
                    for (int i = 0; i < pta.Length; i++)
                    {
                        pta[i].Transform(m, chart3d, ax, this, cl);
                    }
                    g.DrawLine(aPen, pta[0].X, pta[0].Y, pta[1].X, pta[1].Y);
                    g.DrawLine(aPen, pta[1].X, pta[1].Y, pta[2].X, pta[2].Y);
                }
            }
        }
Exemplo n.º 4
0
 public void AddChartStyle(Graphics g, Axes ax, ViewAngle va, Grid gd, ChartLabels cl)
 {
     AddTicks(g, ax, va, cl);
     AddGrids(g, ax, va, gd, cl);
     AddAxes(g, ax, va, cl);
     AddLabels(g, ax, va, cl);
 }