Exemple #1
0
        public void Draw(GTranslator gt, bool EraseBkGnd)
        {
            if (!tabulated)
            {
                return; // ?
            }
            if (EraseBkGnd)
            {
                gt.Clear(CurrentColorSchema.backgroundColor);
            }

            DrawCoordinateSystem(gt);
            DrawGraphic(gt);
        }
Exemple #2
0
        public virtual void DrawCoordinateSystem(GTranslator gt)
        {
            float m_zoom_x = gt.zoom.X;
            float m_zoom_y = gt.zoom.Y;
            float ox       = gt.Ox;
            float oy       = gt.Oy;

            Pen GridPen = new Pen(CurrentColorSchema.gridColor, 0f);

            GridPen.DashStyle = DashStyle.Solid;

            Pen AxePen = new Pen(CurrentColorSchema.axesColor,
                                 2 / (m_zoom_x > m_zoom_y ?
                                      m_zoom_y : m_zoom_x));

            StringFormat stringFormatX = new StringFormat();
            StringFormat stringFormatY = new StringFormat();

            stringFormatX.LineAlignment = StringAlignment.Center;
            stringFormatY.LineAlignment = StringAlignment.Center;
            stringFormatX.Alignment     = StringAlignment.Far;
            //stringFormatX.FormatFlags = StringFormatFlags..DirectionVertical;

            Font font = new Font("Arial", 8, FontStyle.Regular);

            int x1, x2, y1, y2;

            //x1 = gt.VisibleClipBounds.Left;
            //x2 = gt.VisibleClipBounds.Right;
            //y1 = gt.VisibleClipBounds.Top;
            //y2 = gt.VisibleClipBounds.Bottom;
            x1 = 0; x2 = 240; y1 = 0; y2 = 320;

            #region Grid and text

            float dx = 30f, dy = 30f;// шаг сетки

            float textX = -(ox - 3);
            float textY = -oy + gt.VisibleClipBounds.Height;

            for (float x = (float)(int)Math.Ceiling(x1 / dx) * dx; x < x2; x += dx)
            {
                string label = x.ToString("#0.###");
                gt.DrawLine(GridPen, x, y1, x, y2);
                gt.DrawString(label, font, Color.Black,
                              new PointF(x, textY), stringFormatX);
            }

            for (float y = (float)(int)Math.Ceiling(y1 / dy) * dy; y < y2; y += dy)
            {
                gt.DrawString((y).ToString("#0.####"), font, Color.Black,
                              new PointF(textX, -y), stringFormatY);
                gt.DrawLine(GridPen, x1, -y, x2, -y);
            }

            #endregion

            #region Axes
            gt.g.DrawLine(AxePen, x1, 0, x2, 0);
            gt.g.DrawLine(AxePen, x2 - 6, 0 - 3, x2, 0);
            gt.g.DrawLine(AxePen, x2 - 6, 0 + 3, x2, 0);

            gt.g.DrawLine(AxePen, 0, y1, 0, y2);
            gt.g.DrawLine(AxePen, 0, y1, 0 - 3, y1 + 6);
            gt.g.DrawLine(AxePen, 0, y1, 0 + 3, y1 + 6);

            AxePen.Width = 0;
            gt.g.DrawLine(AxePen, x1, y2 - 1, x2, y2 - 1);
            gt.g.DrawLine(AxePen, x1, y1, x1, y2);
            #endregion
        }
Exemple #3
0
        public virtual void DrawGraphic(GTranslator gt)
        {
            float m_zoom = gt.zoom.X;
            Pen   pen    = new Pen(penColor, penWidth / m_zoom);

            //g.SmoothingMode = SmoothingMode.HighQuality;

            switch (drawingMode)
            {
            /*
             * case DrawModes.DrawLines:
             #region For each ( PointF[] segment in graphic ) check visibility and draw
             *  foreach (PointF[] segment in graphic)
             *  {
             *      for (int i = 0; i < segment.Length - 1; i++)
             *      {
             *          PointF pt1 = segment[i];
             *          PointF pt2 = segment[i + 1];
             *
             *          if (g.ClipBounds.Left > pt1.X)
             *              pt1.X = g.ClipBounds.Left;
             *
             *          if (g.ClipBounds.Right < pt1.X)
             *              pt1.X = g.ClipBounds.Right;
             *
             *          if (g.ClipBounds.Top > pt1.Y)
             *              pt1.Y = g.ClipBounds.Top;
             *
             *          if (g.ClipBounds.Bottom < pt1.Y)
             *              pt1.Y = g.ClipBounds.Bottom;
             *
             *          if (g.ClipBounds.Left > pt2.X)
             *              pt2.X = g.ClipBounds.Left;
             *
             *          if (g.ClipBounds.Right < pt2.X)
             *              pt2.X = g.ClipBounds.Right;
             *
             *          if (g.ClipBounds.Top > pt2.Y)
             *              pt2.Y = g.ClipBounds.Top;
             *
             *          if (g.ClipBounds.Bottom < pt2.Y)
             *              pt2.Y = g.ClipBounds.Bottom;
             *
             *          g.DrawLine(pen, pt1.X, pt1.Y, pt2.X, pt2.Y);
             *      }
             *  }
             #endregion
             * break;
             */
            case DrawModes.DrawPoints:
                float dotWidth = pen.Width;
                foreach (PointF[] segment in graphic)
                {
                    for (int i = 0; i < segment.Length; i++)
                    {
                        gt.DrawEllipse(pen,
                                       segment[i].X - dotWidth / 2f, segment[i].Y - dotWidth / 2f,
                                       dotWidth, dotWidth);
                    }
                }
                break;

            case DrawModes.DrawFilledPolygon:
                SolidBrush brush = new SolidBrush(pen.Color);
                Pen        pen1  = (Pen)pen.Clone();
                pen1.Width = 2f / m_zoom;
                foreach (PointF[] segment in graphic)
                {
                    if (segment.Length < 2)
                    {
                        continue;
                    }
                    gt.FillPolygon(brush, segment);

                    gt.DrawPolygon(pen1, segment);
                }
                break;
            }
        }
Exemple #4
0
 public void Draw(GTranslator gt)
 {
     Draw(gt, true);
 }