Example #1
0
        private void Add3DGrids(DovDrawings g)
        {
            Matrix3 m = Matrix3.AzimuthElevation(Elevation, Azimuth);

            Point3[] pta = new Point3[3];
            Point3[] pts;
            g.DrwColor      = "white";
            g.LineThickness = 0.5f;
            // Draw x gridlines:
            if (IsXGrid)
            {
                for (float x = XMin; x <= XMax; x = x + XTick)
                {
                    pts    = CoordinatesOfChartBox();
                    pta[0] = new Point3(x, pts[1].Y, pts[1].Z, pts[1].W);
                    if (Elevation >= 0)
                    {
                        if ((Azimuth >= -180 && Azimuth < -90) ||
                            (Azimuth >= 0 && 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 (Elevation < 0)
                    {
                        if ((Azimuth >= -180 && Azimuth < -90) ||
                            (Azimuth >= 0 && 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, this);
                    }
                    g.DrawLine(pta[0].X, pta[0].Y, pta[1].X, pta[1].Y);
                    g.DrawLine(pta[1].X, pta[1].Y, pta[2].X, pta[2].Y);
                }
            }
            // Draw y gridlines:
            if (IsYGrid)
            {
                for (float y = YMin; y <= YMax; y = y + YTick)
                {
                    pts    = CoordinatesOfChartBox();
                    pta[0] = new Point3(pts[1].X, y, pts[1].Z, pts[1].W);
                    if (Elevation >= 0)
                    {
                        if ((Azimuth >= -180 && Azimuth < -90) ||
                            (Azimuth >= 0 && 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 (Elevation < 0)
                    {
                        if ((Azimuth >= -180 && Azimuth < -90) ||
                            (Azimuth >= 0 && 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, this);
                    }
                    g.DrawLine(pta[0].X, pta[0].Y,
                               pta[1].X, pta[1].Y);
                    g.DrawLine(pta[1].X, pta[1].Y,
                               pta[2].X, pta[2].Y);
                }
            }
            //Draw Z gridlines:
            if (IsZGrid)
            {
                for (float z = ZMin; z <= ZMax; z = z + ZTick)
                {
                    pts    = CoordinatesOfChartBox();
                    pta[0] = new Point3(pts[2].X, pts[2].Y, z, pts[2].W);
                    if (Elevation >= 0)
                    {
                        if ((Azimuth >= -180 && Azimuth < -90) ||
                            (Azimuth >= 0 && 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 (Elevation < 0)
                    {
                        if ((Azimuth >= -180 && Azimuth < -90) ||
                            (Azimuth >= 0 && 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, this);
                    }
                    g.DrawLine(pta[0].X, pta[0].Y, pta[1].X, pta[1].Y);
                    g.DrawLine(pta[1].X, pta[1].Y, pta[2].X, pta[2].Y);
                }
            }
        }
Example #2
0
        private void Add3DLabels(DovDrawings g)
        {
            Matrix3 m  = Matrix3.AzimuthElevation(Elevation, Azimuth);
            Point3  pt = new Point3();

            Point3[] pts = CoordinatesOfChartBox();
            // Add x tick labels:
            float offset     = (YMax - YMin) / 20;
            float labelSpace = offset;

            g.FillColorOpt  = "white";
            g.TextFont      = LabelFont;
            g.TextAlignment = Canvas.CanvasEnum.TextAlign.Right;
            for (float x = XMin + XTick; x < XMax; x = x + XTick)
            {
                if (Elevation >= 0)
                {
                    if (Azimuth >= -90 && Azimuth < 90)
                    {
                        labelSpace = -offset;
                    }
                }
                else if (Elevation < 0)
                {
                    if ((Azimuth >= -180 && Azimuth < -90) ||
                        Azimuth >= 90 && Azimuth <= 180)
                    {
                        labelSpace = -offset;
                    }
                }
                pt = new Point3(x, pts[1].Y + labelSpace, pts[1].Z, pts[1].W);
                pt.Transform(m, this);

                g.DrawText(Math.Round(x, 2).ToString(), new PointF(pt.X, pt.Y));
            }
            // Add y tick labels:
            offset          = (XMax - XMin) / 20;
            labelSpace      = offset;
            g.TextAlignment = Canvas.CanvasEnum.TextAlign.Left;
            for (float y = YMin + YTick; y < YMax; y = y + YTick)
            {
                pts = CoordinatesOfChartBox();
                if (Elevation >= 0)
                {
                    if (Azimuth >= -180 && Azimuth < 0)
                    {
                        labelSpace = -offset;
                    }
                }
                else if (Elevation < 0)
                {
                    if (Azimuth >= 0 && Azimuth < 180)
                    {
                        labelSpace = -offset;
                    }
                }
                pt = new Point3(pts[1].X + labelSpace, y, pts[1].Z, pts[1].W);
                pt.Transform(m, this);
                g.DrawText(Math.Round(y, 2).ToString(), new PointF(pt.X, pt.Y));
            }
            // Add z tick labels:
            float  xoffset     = (XMax - XMin) / 30.0f;
            float  yoffset     = (YMax - YMin) / 15.0f;
            float  xlabelSpace = xoffset;
            float  ylabelSpace = yoffset;
            float  txtHeight   = 8;
            string font        = "pt Verenda";

            font       = txtHeight + font;
            LabelFont  = font;
            g.TextFont = LabelFont;

            g.TextAlignment = Canvas.CanvasEnum.TextAlign.Right;
            for (float z = ZMin; z <= ZMax; z = z + ZTick)
            {
                pts = CoordinatesOfChartBox();
                if (Elevation >= 0)
                {
                    if (Azimuth >= -180 && Azimuth < -90)
                    {
                        xlabelSpace = 0;
                        ylabelSpace = yoffset;
                    }
                    else if (Azimuth >= -90 && Azimuth < 0)
                    {
                        xlabelSpace = xoffset;
                        ylabelSpace = 0;
                    }
                    else if (Azimuth >= 0 && Azimuth < 90)
                    {
                        xlabelSpace = 0;
                        ylabelSpace = -yoffset;
                    }
                    else if (Azimuth >= 90 && Azimuth <= 180)
                    {
                        xlabelSpace = -xoffset;
                        ylabelSpace = 0;
                    }
                }
                else if (Elevation < 0)
                {
                    if (Azimuth >= -180 && Azimuth < -90)
                    {
                        ylabelSpace = 0;
                        xlabelSpace = xoffset;
                    }
                    else if (Azimuth >= -90 && Azimuth < 0)
                    {
                        ylabelSpace = -yoffset;
                        xlabelSpace = 0;
                    }
                    else if (Azimuth >= 0 && Azimuth < 90)
                    {
                        ylabelSpace = 0;
                        xlabelSpace = -xoffset;
                    }
                    else if (Azimuth >= 90 && Azimuth <= 180)
                    {
                        ylabelSpace = yoffset;
                        xlabelSpace = 0;
                    }
                }
                pt = new Point3(pts[2].X + ylabelSpace,
                                pts[2].Y + xlabelSpace, z, pts[2].W);
                pt.Transform(m, this);
                g.TextBase      = Canvas.CanvasEnum.TextBaseline.Middle;
                g.TextAlignment = Canvas.CanvasEnum.TextAlign.Right;
                g.DrawText(Math.Round(z, 2).ToString(), new PointF(pt.X - labelSpace, pt.Y - txtHeight / 2));
            }
            // Add Title:

            if (Title != "No Title")
            {
                g.TextFont = TitleFont;
                g.DrawText(Title, new PointF(ChartArea.Width / 2, ChartArea.Height / 30));
            }
            // Add x axis label:
            offset     = (YMax - YMin) / 3;
            labelSpace = offset;

            float offset1 = (XMax - XMin) / 10;
            float xc      = offset1;

            if (Elevation >= 0)
            {
                if (Azimuth >= -90 && Azimuth < 90)
                {
                    labelSpace = -offset;
                }
                if (Azimuth >= 0 && Azimuth <= 180)
                {
                    xc = -offset1;
                }
            }
            else if (Elevation < 0)
            {
                if ((Azimuth >= -180 && Azimuth < -90) ||
                    Azimuth >= 90 && Azimuth <= 180)
                {
                    labelSpace = -offset;
                }
                if (Azimuth >= -180 && Azimuth <= 0)
                {
                    xc = -offset1;
                }
            }
            Point3[] pta = new Point3[2];
            pta[0] = new Point3(XMin, pts[1].Y + labelSpace,
                                pts[1].Z, pts[1].W);
            pta[1] = new Point3((XMin + XMax) / 2 - xc,
                                pts[1].Y + labelSpace, pts[1].Z, pts[1].W);
            pta[0].Transform(m, this);
            pta[1].Transform(m, this);
            float theta = (float)Math.Atan((pta[1].Y - pta[0].Y) /
                                           (pta[1].X - pta[0].X));

            g.Save();
            g.TextBase = Canvas.CanvasEnum.TextBaseline.Middle;
            g.Translate(pta[1].X, pta[1].Y);
            g.Rotate(theta);
            g.DrawText(XLabel, new PointF(0, 0));

            g.Restore();
            // Add y axis label:
            offset     = (XMax - XMin) / 3;
            offset1    = (YMax - YMin) / 5;
            labelSpace = offset;
            float yc = YTick;

            if (Elevation >= 0)
            {
                if (Azimuth >= -180 && Azimuth < 0)
                {
                    labelSpace = -offset;
                }
                if (Azimuth >= -90 && Azimuth <= 90)
                {
                    yc = -offset1;
                }
            }
            else if (Elevation < 0)
            {
                yc = -offset1;
                if (Azimuth >= 0 && Azimuth < 180)
                {
                    labelSpace = -offset;
                }
                if (Azimuth >= -90 && Azimuth <= 90)
                {
                    yc = offset1;
                }
            }
            pta[0] = new Point3(pts[1].X + labelSpace, YMin, pts[1].Z, pts[1].W);

            pta[1] = new Point3(pts[1].X + labelSpace, (YMin + YMax) / 2 + yc, pts[1].Z, pts[1].W);

            pta[0].Transform(m, this);
            pta[1].Transform(m, this);
            theta = (float)Math.Atan((pta[1].Y - pta[0].Y) /
                                     (pta[1].X - pta[0].X));

            g.Save();
            g.Translate(pta[1].X, pta[1].Y);
            g.Rotate(theta);
            g.DrawText(YLabel, new PointF(0, 0));

            g.Restore();
            // Add z axis labels:
            float zticklength = 10;

            labelSpace = -1.3f * offset;
            offset1    = (ZMax - ZMin) / 8;
            float zc = -offset1;

            for (float z = ZMin; z < ZMax; z = z + ZTick)
            {
                float size = 30f;/*await g.MeasureTextWidthAsync(z.ToString());*/
                if (zticklength < size)
                {
                    zticklength = size;
                }
            }
            float zlength = -zticklength;

            if (Elevation >= 0)
            {
                if (Azimuth >= -180 && Azimuth < -90)
                {
                    zlength    = -zticklength;
                    labelSpace = -1.3f * offset;
                    zc         = -offset1;
                }
                else if (Azimuth >= -90 && Azimuth < 0)
                {
                    zlength    = zticklength;
                    labelSpace = 2 * offset / 3;
                    zc         = offset1;
                }
                else if (Azimuth >= 0 && Azimuth < 90)
                {
                    zlength    = zticklength;
                    labelSpace = 2 * offset / 3;
                    zc         = -offset1;
                }
                else if (Azimuth >= 90 && Azimuth <= 180)
                {
                    zlength    = -zticklength;
                    labelSpace = -1.3f * offset;
                    zc         = offset1;
                }
            }
            else if (Elevation < 0)
            {
                if (Azimuth >= -180 && Azimuth < -90)
                {
                    zlength    = -zticklength;
                    labelSpace = -1.3f * offset;
                    zc         = offset1;
                }
                else if (Azimuth >= -90 && Azimuth < 0)
                {
                    zlength    = zticklength;
                    labelSpace = 2 * offset / 3;
                    zc         = -offset1;
                }
                else if (Azimuth >= 0 && Azimuth < 90)
                {
                    zlength    = zticklength;
                    labelSpace = 2 * offset / 3;
                    zc         = offset1;
                }
                else if (Azimuth >= 90 && Azimuth <= 180)
                {
                    zlength    = -zticklength;
                    labelSpace = -1.3f * offset;
                    zc         = -offset1;
                }
            }
            pta[0] = new Point3(pts[2].X - 1.6f * labelSpace, pts[2].Y,
                                (ZMin + ZMax) / 2 + zc, pts[2].W);
            pta[0].Transform(m, this);
            /// rotate Graphic
            g.Save();
            g.TextBase = Canvas.CanvasEnum.TextBaseline.Middle;
            g.Translate(pta[0].X - zlength, pta[0].Y);
            g.Rotate(270 * (float)Math.PI / 180);
            g.DrawText(ZLabel, new PointF(0, 0));
            g.Restore();
        }
Example #3
0
        private void Add3DTicks(DovDrawings g)
        {
            Matrix3 m = Matrix3.AzimuthElevation(Elevation, Azimuth);

            Point3[] pta = new Point3[2];
            Point3[] pts = CoordinatesOfChartBox();
            g.DrwColor = "green";
            // Add x ticks:
            float offset     = (YMax - YMin) / 20.0f;
            float ticklength = offset;

            for (float x = XMin; x <= XMax; x = x + XTick)
            {
                if (Elevation >= 0)
                {
                    if (Azimuth >= -90 && Azimuth < 90)
                    {
                        ticklength = -offset;
                    }
                }
                else if (Elevation < 0)
                {
                    if ((Azimuth >= -180 && Azimuth < -90) ||
                        Azimuth >= 90 && Azimuth <= 180)
                    {
                        ticklength = -(YMax - YMin) / 30;
                    }
                }
                pta[0] = new Point3(x, pts[1].Y + ticklength,
                                    pts[1].Z, pts[1].W);
                pta[1] = new Point3(x, pts[1].Y, pts[1].Z, pts[1].W);
                for (int i = 0; i < pta.Length; i++)
                {
                    pta[i].Transform(m, this);
                }
                g.DrawLine(pta[0].X, pta[0].Y, pta[1].X, pta[1].Y);
            }
            // Add y ticks:
            offset     = (XMax - XMin) / 20.0f;
            ticklength = offset;
            for (float y = YMin; y <= YMax; y = y + YTick)
            {
                pts = CoordinatesOfChartBox();
                if (Elevation >= 0)
                {
                    if (Azimuth >= -180 && Azimuth < 0)
                    {
                        ticklength = -offset;
                    }
                }
                else if (Elevation < 0)
                {
                    if (Azimuth >= 0 && Azimuth < 180)
                    {
                        ticklength = -offset;
                    }
                }
                pta[0] = new Point3(pts[1].X + ticklength, y,
                                    pts[1].Z, pts[1].W);
                pta[1] = new Point3(pts[1].X, y, pts[1].Z, pts[1].W);
                for (int i = 0; i < pta.Length; i++)
                {
                    pta[i].Transform(m, this);
                }
                g.DrawLine(pta[0].X, pta[0].Y, pta[1].X, pta[1].Y);
            }
            // Add z ticks:
            float xoffset     = (XMax - XMin) / 30.0f;
            float yoffset     = (YMax - YMin) / 30.0f;
            float xticklength = xoffset;
            float yticklength = yoffset;

            for (float z = ZMin; z <= ZMax; z = z + ZTick)
            {
                if (Elevation >= 0)
                {
                    if (Azimuth >= -180 && Azimuth < -90)
                    {
                        xticklength = 0;
                        yticklength = yoffset;
                    }
                    else if (Azimuth >= -90 && Azimuth < 0)
                    {
                        xticklength = xoffset;
                        yticklength = 0;
                    }
                    else if (Azimuth >= 0 && Azimuth < 90)
                    {
                        xticklength = 0;
                        yticklength = -yoffset;
                    }
                    else if (Azimuth >= 90 && Azimuth <= 180)
                    {
                        xticklength = -xoffset;
                        yticklength = 0;
                    }
                }
                else if (Elevation < 0)
                {
                    if (Azimuth >= -180 && Azimuth < -90)
                    {
                        yticklength = 0;
                        xticklength = xoffset;
                    }
                    else if (Azimuth >= -90 && Azimuth < 0)
                    {
                        yticklength = -yoffset;
                        xticklength = 0;
                    }
                    else if (Azimuth >= 0 && Azimuth < 90)
                    {
                        yticklength = 0;
                        xticklength = -xoffset;
                    }
                    else if (Azimuth >= 90 && Azimuth <= 180)
                    {
                        yticklength = yoffset;
                        xticklength = 0;
                    }
                }
                pta[0] = new Point3(pts[2].X, pts[2].Y, z, pts[2].W);
                pta[1] = new Point3(pts[2].X + yticklength,
                                    pts[2].Y + xticklength, z, pts[2].W);
                for (int i = 0; i < pta.Length; i++)
                {
                    pta[i].Transform(m, this);
                }
                g.DrawLine(pta[0].X, pta[0].Y, pta[1].X, pta[1].Y);
            }
        }