Пример #1
0
 public Draw3DChart(Panel p, ChartStyle cs3d)
 {
     panel = p;
     Debug.WriteLine("3D Panel Size = " + panel.Size.Width.ToString()
                     + " X " + panel.Size.Height.ToString());
     cs           = cs3d;
     NumberInterp = 2;
 }
Пример #2
0
 public void UpdateChartStyle(ChartStyle cs3d, bool measureThick)
 {
     //cs = cs3d.ShallowCopy();
     cs.XMax      = cs3d.XMax;
     cs.XMin      = cs3d.XMin;
     cs.XTick     = (cs.XMax - cs.XMin) / Constants.Draw2DXTickNumber;
     cs.FullScale = cs3d.FullScale;
     isThick      = measureThick;
 }
Пример #3
0
 public void SetBoundary(int xmin, int xmax, int ymin, int ymax, ChartStyle s)
 {
     xMin = xmin;
     xMax = xmax;
     yMin = ymin;
     yMax = ymax;
     cs   = s;
     SetStartingPos();
 }
Пример #4
0
        public DrawSection(Panel p, ChartStyle cs3d)
        {
            panel    = p;
            cs       = cs3d.ShallowCopy();
            cs.XTick = 20;
            float scale = 28.0f;

            XOffset = panel.Width / scale;
            YOffset = panel.Height / scale;
        }
Пример #5
0
        //2D point
        private PointF PointSkin(PointF p, ChartStyle cs3d)
        {
            PointF pt = new PointF();

            if (p.X < cs3d.XMin || p.X > cs3d.XMax ||
                p.Y < cs3d.YMin || p.Y > cs3d.YMax)
            {
                p.X = Single.NaN;
                p.Y = Single.NaN;
            }
            pt.X = (p.X - cs3d.XMin) * panel.Width / (cs3d.XMax - cs3d.XMin);
            pt.Y = (p.Y - cs3d.YMin) * panel.Height / (cs3d.YMax - cs3d.YMin);
            return(pt);
        }
Пример #6
0
        private void AddMesh(Graphics g, DataSeries ds, ChartStyle cs)
        {
            Debug.WriteLine("Entering AddMesh panel=" + panel.Width.ToString()
                            + "," + panel.Height.ToString());

            Pen apen = new Pen(ds.DataLine.LineColor, ds.DataLine.Thickness);

            using (SolidBrush abrush = new SolidBrush(Color.Wheat))
            {
                Point3[,] pts = ds.CloneDataSet();
                PointF[] pta = new PointF[4];
                Matrix3  m   = Matrix3.AzimuthElevation(cs.Elevation, cs.Azimuth);

                //Points transform
                for (int i = 0; i < pts.GetLength(0); i++)
                {
                    for (int j = 0; j < pts.GetLength(1); j++)
                    {
                        pts[i, j].Transform(m, panel.Size, cs);
                    }
                }

                //Draw 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 (cs.Azimuth >= -180 && cs.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);
                        g.DrawPolygon(apen, pta);
                    }
                }
            }
            apen.Dispose();

            Debug.WriteLine("Exit AddMesh panel=" + panel.Width.ToString()
                            + "," + panel.Height.ToString());
        }
Пример #7
0
 public void AddChartStyle2D(Graphics g, ChartStyle cs3d)
 {
     using (Pen apen = new Pen(cs3d.GridColor, 1f))
     {
         apen.DashStyle = cs3d.GridStyle;
         //Create Vertical Grid Lines
         if (cs3d.IsYGrid)
         {
             for (float x = cs3d.XMin + cs3d.XTick; x < cs3d.XMax; x += cs3d.XTick)
             {
                 g.DrawLine(apen, PointSkin(new PointF(x, cs3d.YMin), cs3d)
                            , PointSkin(new PointF(x, cs3d.YMax), cs3d));
             }
         }
         //Create Horizontal Grid Lines
         if (cs3d.IsXGrid)
         {
             for (float y = cs3d.YMin + cs3d.YTick; y < cs3d.YMax; y += cs3d.YTick)
             {
                 g.DrawLine(apen, PointSkin(new PointF(cs3d.XMin, y), cs3d)
                            , PointSkin(new PointF(cs3d.XMax, y), cs3d));
             }
         }
         //Create x-axis tick marks
         for (float x = cs3d.XMin; x <= cs3d.XMax; x += cs3d.XTick)
         {
             PointF axisPoint = PointSkin(new PointF(x, cs3d.YMin), cs3d);
             g.DrawLine(apen, axisPoint
                        , new PointF(axisPoint.X, axisPoint.Y - 5f));
         }
         //Create x-axis tick marks
         for (float y = cs3d.YMin; y <= cs3d.YMax; y += cs3d.YTick)
         {
             PointF axisPoint = PointSkin(new PointF(cs3d.XMin, y), cs3d);
             g.DrawLine(apen, axisPoint
                        , new PointF(axisPoint.X + 5f, axisPoint.Y));
         }
     }
 }
Пример #8
0
        public Form1()
        {
            InitializeComponent();
            Screen    myScreen = Screen.FromControl(this);
            Rectangle area = myScreen.WorkingArea;
            float     ratio = area.Width / area.Height;
            int       w, h;
            Point     pos;

            if (ratio < 1.5)
            {
                h   = (int)(area.Height * 0.9);
                w   = (int)(h * 1.5);
                pos = new Point(w / 12, h / 12);
            }
            else
            {
                w   = (int)(area.Width * 0.9);
                h   = (int)(w / 1.5);
                pos = new Point(w / 12, h / 12);
            }
            this.Size      = new Size(w, h);
            this.Location  = pos;
            this.BackColor = Color.AliceBlue;

            cs3       = new ChartStyle();
            drawBase3 = new Draw3DBase(panel3D, cs3);

            draw3 = new Draw3DChart(panel3D, cs3);
            draw3.NumberInterp = 5;
            ColorMap cm = new ColorMap();

            draw3.CMap = cm.Jet();

            skin3 = new Draw3DSkin(panel3D);
            skin3.PlotBackColor   = this.BackColor;
            skin3.PlotBorderColor = this.BackColor;

            //Init trackBar
            PosMin = 0;
            PosMax = 50000;
            DrawTrackBar();

            //Data Generation
            InitCSPara();
            ds = new DataSeries();
            //ds.Random3D(cs3);
            ds.DataLine.LineColor = Color.DarkBlue;
            ds.DataLine.Thickness = 1;
            panel3D.Paint        += new PaintEventHandler(Plot3D);
            panel3D.BackColor     = Color.Cornsilk;

            //ds.ZdataStat();
            lbAvg.Text = ds.Zavg.ToString("0.000");
            lbMax.Text = ds.Zmax.ToString("0.000");
            lbMin.Text = ds.Zmin.ToString("0.000");

            //2D view
            panel2D.Paint    += new PaintEventHandler(Plot2D);
            panel2D.BackColor = Color.Azure;
            draw2             = new DrawSection(panel2D, cs3);


            //two sets of horizontal and vertical rulers
            dl_array    = new DraggableLine[dl_num];
            dl_array[0] = new DraggableLine(new Pen(Color.Navy, 2), 0, true);
            dl_array[1] = new DraggableLine(new Pen(Color.Navy, 2), 0, false);
            dl_array[2] = new DraggableLine(new Pen(Color.DarkGreen, 2), 15, true);
            dl_array[3] = new DraggableLine(new Pen(Color.DarkGreen, 2), 15, false);
        }
Пример #9
0
 public Draw3DBase(Panel p, ChartStyle cs3d)
 {
     panel = p;
     cs    = cs3d;
 }