コード例 #1
0
        public void DrawBmy(DovDrawings g, ChartStyle cs)
        {
            PointF pt1;
            PointF pt2;
            PointF pt3;
            PointF pt4;

            cs.YMin = 0;
            float minx1 = Min(bbm[1].ToArray());
            float minx2 = Min(tbm[1].ToArray());
            float maxx1 = Max(bbm[1].ToArray());
            float maxx2 = Max(tbm[1].ToArray());

            cs.XMin = (minx1 < minx2 ? minx1 : minx2);
            cs.XMax = (maxx1 > maxx2 ? maxx1 : maxx2);
            cs.YMax = fData.Length;
            for (int i = 0; i < bbm[0].Count - 1; i++)
            {
                pt1 = new PointF((float)bbm[1][i], (float)bbm[0][i]);
                pt2 = new PointF((float)bbm[1][i + 1], (float)bbm[0][i + 1]);
                pt3 = new PointF(0, pt1.Y);
                pt4 = new PointF(0, pt2.Y);
                g.DrawLine(cs.Point2D(pt1), cs.Point2D(pt2));
                g.DrawLine(cs.Point2D(pt2), cs.Point2D(pt4));
                g.DrawLine(cs.Point2D(pt4), cs.Point2D(pt3));
                if (i == (bbm[0].Count - 2))
                {
                    string va = string.Format("{0}kNm", Math.Round(pt2.X, 2));
                    g.FillColorOpt  = "black";
                    g.TextBase      = Canvas.CanvasEnum.TextBaseline.Bottom;
                    g.TextAlignment = Canvas.CanvasEnum.TextAlign.Left;
                    g.DrawText(va, cs.Point2D(pt2));
                }
            }
            for (int i = 0; i < tbm[0].Count - 1; i++)
            {
                pt1 = new PointF((float)tbm[1][i], (float)tbm[0][i] + fData.ColLocY + 0.5f * fData.ColumnLength);
                pt2 = new PointF((float)tbm[1][i + 1], (float)tbm[0][i + 1] + fData.ColLocY + 0.5f * fData.ColumnLength);
                pt3 = new PointF(0, pt1.Y);
                pt4 = new PointF(0, pt2.Y);
                if (i == 0)
                {
                    g.DrawLine(cs.Point2D(pt1), cs.Point2D(pt3));
                    //value
                    string va = string.Format("{0}kNm", Math.Round(pt1.X, 2));
                    g.FillColorOpt  = "black";
                    g.TextBase      = Canvas.CanvasEnum.TextBaseline.Top;
                    g.TextAlignment = Canvas.CanvasEnum.TextAlign.Left;
                    g.DrawText(va, cs.Point2D(pt1));
                }
                g.DrawLine(cs.Point2D(pt1), cs.Point2D(pt2));
                if (pt2.X != pt4.X)
                {
                    g.DrawLine(cs.Point2D(pt2), cs.Point2D(pt4));
                }
                g.DrawLine(cs.Point2D(pt4), cs.Point2D(pt3));
            }
        }
コード例 #2
0
        public void DrawBmx(DovDrawings g, ChartStyle cs)
        {
            PointF pt1;
            PointF pt2;
            PointF pt3;
            PointF pt4;

            cs.XMin = 0;
            cs.XMax = fData.Width;
            float miny1 = Min(lbm[1].ToArray());
            float miny2 = Min(rbm[1].ToArray());
            float maxy1 = Max(lbm[1].ToArray());
            float maxy2 = Max(rbm[1].ToArray());

            cs.YMin = (miny1 < miny2 ? miny1 : miny2);
            cs.YMax = (maxy1 > maxy2 ? maxy1 : maxy2);
            for (int i = 0; i < lbm[0].Count - 1; i++)
            {
                pt1 = new PointF((float)lbm[0][i], (float)lbm[1][i]);
                pt2 = new PointF((float)lbm[0][i + 1], (float)lbm[1][i + 1]);
                pt3 = new PointF(pt1.X, 0);
                pt4 = new PointF(pt2.X, 0);
                g.DrawLine(cs.Point2D(pt1), cs.Point2D(pt2));
                g.DrawLine(cs.Point2D(pt2), cs.Point2D(pt4));
                g.DrawLine(cs.Point2D(pt4), cs.Point2D(pt3));
                if (i == (lbm[0].Count - 2))
                {
                    string va = string.Format("{0}kNm", Math.Round(pt2.Y, 2));
                    g.FillColorOpt  = "black";
                    g.TextBase      = Canvas.CanvasEnum.TextBaseline.Top;
                    g.TextAlignment = Canvas.CanvasEnum.TextAlign.Right;
                    g.DrawText(va, cs.Point2D(pt2));
                }
            }
            for (int i = 0; i < rbm[0].Count - 1; i++)
            {
                pt1 = new PointF((float)rbm[0][i] + fData.ColLocX + 0.5f * fData.ColumnWidth, (float)rbm[1][i]);
                pt2 = new PointF((float)rbm[0][i + 1] + fData.ColLocX + 0.5f * fData.ColumnWidth, (float)rbm[1][i + 1]);
                pt3 = new PointF(pt1.X, 0);
                pt4 = new PointF(pt2.X, 0);
                if (i == 0)
                {
                    g.DrawLine(cs.Point2D(pt1), cs.Point2D(pt3));
                    string va = string.Format("{0}kNm", Math.Round(pt1.Y, 2));
                    g.FillColorOpt  = "black";
                    g.TextBase      = Canvas.CanvasEnum.TextBaseline.Top;
                    g.TextAlignment = Canvas.CanvasEnum.TextAlign.Left;
                    g.DrawText(va, cs.Point2D(pt1));
                }
                g.DrawLine(cs.Point2D(pt1), cs.Point2D(pt2));
                if (pt2.Y != pt4.Y)
                {
                    g.DrawLine(cs.Point2D(pt2), cs.Point2D(pt4));
                }
                g.DrawLine(cs.Point2D(pt4), cs.Point2D(pt3));
            }
        }
コード例 #3
0
ファイル: ChartStyle.cs プロジェクト: Honda99/StandUpTeam
        public void DrawTickMark(DovDrawings g)
        {
            float xlimMin = XMin;
            float xlimMax = XMax;
            float ylimMin = YMin;
            float ylimMax = YMax;
            float start   = XMin;
            float end     = XMax;

            g.DrwColor      = "green";
            g.LineThickness = 0.7f;

            //List<Task> gridx = new List<Task>();
            for (float i = start; i <= end; i += XTick)
            {
                PointF xPoint = Point2D(new PointF(i, ylimMin));
                g.DrawLine(new PointF(xPoint.X, xPoint.Y + TickLength), Point2D(new PointF(i, ylimMin)));
                g.TextFont      = TickFont;
                g.FillColorOpt  = TickFontColor;
                g.TextBase      = Canvas.CanvasEnum.TextBaseline.Top;
                g.TextAlignment = Canvas.CanvasEnum.TextAlign.Center;
                g.DrawText(Math.Round(i, 2).ToString(), new PointF(xPoint.X, xPoint.Y + TickLength));
            }
            g.DrwColor      = "#0cd5f0";
            g.LineThickness = 0.3f;
            start           = YMin;
            end             = YMax;
            for (float j = start; j <= end; j += YTick)
            {
                PointF yPoint = Point2D(new PointF(xlimMin, j));
                g.DrawLine(new PointF(yPoint.X - TickLength, yPoint.Y), Point2D(new PointF(xlimMin, j)));
                g.TextFont      = TickFont;
                g.FillColorOpt  = TickFontColor;
                g.TextBase      = Canvas.CanvasEnum.TextBaseline.Middle;
                g.TextAlignment = Canvas.CanvasEnum.TextAlign.Right;
                g.DrawText(Math.Round(j, 2).ToString(), new PointF(yPoint.X - TickLength, yPoint.Y));
            }
        }
コード例 #4
0
ファイル: ChartStyle.cs プロジェクト: Honda99/StandUpTeam
        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();
        }