- 积分
- 59
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2012-2-26
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2015-12-23 22:08:41
|
显示全部楼层
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.IO;
- using wContour;
- namespace HimawariCast_Display
- {
- class LineContour
- {
- public System.Windows.Forms.PictureBox PictureBox1 = null;
- public double[,] _gridData = null;
- double[,] _discreteData = null;
- double[] _X = null;
- double[] _Y = null;
- double[] _CValues = null;
- Color[] _colors = null;
- List<List<PointD>> _mapLines = new List<List<PointD>>();
- List<Border> _borders = new List<Border>();
- List<PolyLine> _contourLines = new List<PolyLine>();
- List<PolyLine> _clipContourLines = new List<PolyLine>();
- List<Polygon> _contourPolygons = new List<Polygon>();
- List<Polygon> _clipContourPolygons = new List<Polygon>();
- List<wContour.Legend.lPolygon> _legendPolygons = new List<Legend.lPolygon>();
- List<PolyLine> _streamLines = new List<PolyLine>();
-
- double _undefData = -9999.0;
- List<List<PointD>> _clipLines = new List<List<PointD>>();
- //List<PointD> _clipPList = new List<PointD>();
- public Color _startColor = default(Color);
- public Color _endColor = default(Color);
- private int _highlightIdx = 0;
- private double _minX = 0;
- private double _minY = 0;
- private double _maxX = 0;
- private double _maxY = 0;
- private double _scaleX = 1.0;
- private double _scaleY = 1.0;
- public string _dFormat = "0";
- public bool GB_DrawSet = true;
- public bool CB_DiscreteData = false;
- public bool CB_GridData = false;
- public bool CB_BorderLines = false;
- public bool CB_ContourLine = false;
- public bool CB_ContourPolygon = true;
- public bool CB_Clipped = true;
- public bool ChB_Highlight = true;
- public void CreateGridData(int rows, int cols)
- {
- int i = 0;
- int j = 0;
- double XDelt = 0;
- double YDelt = 0;
- //---- Generate X and Y coordinates
- _X = new double[cols];
- _Y = new double[rows];
- XDelt = this.PictureBox1.Width / cols;
- YDelt = this.PictureBox1.Height / rows;
- for (i = 0; i <= cols - 1; i++)
- {
- _X[i] = i * XDelt;
- }
- for (i = 0; i <= rows - 1; i++)
- {
- _Y[i] = i * YDelt;
- }
- }
- public void SetStation(double[] x, double[] y)
- {
- _X = x;
- _Y = y;
- }
- public void SetContourValues(double[] values)
- {
- _CValues = values;
- }
- public void TracingContourLines()
- {
- //---- Contour values
- int nc = _CValues.Length;
- //---- Colors
- _colors = CreateColors(_startColor, _endColor, nc + 1);
- double XDelt = 0;
- double YDelt = 0;
- XDelt = _X[1] - _X[0];
- YDelt = _Y[1] - _Y[0];
- int[,] S1 = new int[1, 1];
- _borders = Contour.TracingBorders(_gridData, _X, _Y, ref S1, _undefData);
- _contourLines = Contour.TracingContourLines(_gridData, _X, _Y, nc, _CValues, _undefData, _borders, S1);
- }
- public void SmoothLines()
- {
- _contourLines = Contour.SmoothLines(_contourLines);
- }
- private Color[] CreateColors(Color sColor, Color eColor, int cNum)
- {
- Color[] colors = new Color[cNum];
- int sR = 0;
- int sG = 0;
- int sB = 0;
- int eR = 0;
- int eG = 0;
- int eB = 0;
- int rStep = 0;
- int gStep = 0;
- int bStep = 0;
- int i = 0;
- sR = sColor.R;
- sG = sColor.G;
- sB = sColor.B;
- eR = eColor.R;
- eG = eColor.G;
- eB = eColor.B;
- rStep = Convert.ToInt32((eR - sR) / cNum);
- gStep = Convert.ToInt32((eG - sG) / cNum);
- bStep = Convert.ToInt32((eB - sB) / cNum);
- for (i = 0; i <= colors.Length - 1; i++)
- {
- colors[i] = Color.FromArgb(sR + i * rStep, sG + i * gStep, sB + i * bStep);
- }
- return colors;
- }
- public void GetEcllipseClipping()
- {
- _clipLines = new List<List<PointD>>();
- //---- Generate border with ellipse
- double x0 = 0;
- double y0 = 0;
- double a = 0;
- double b = 0;
- double c = 0;
- bool ifX = false;
- x0 = this.PictureBox1.Width / 2;
- y0 = this.PictureBox1.Height / 2;
- double dist = 0;
- dist = 100;
- a = x0 - dist;
- b = y0 - dist / 2;
- if (a > b)
- {
- ifX = true;
- }
- else
- {
- ifX = false;
- c = a;
- a = b;
- b = c;
- }
- int i = 0;
- int n = 0;
- n = 100;
- double nx = 0;
- double x1 = 0;
- double y1 = 0;
- double ytemp = 0;
- List<PointD> pList = new List<PointD>();
- List<PointD> pList1 = new List<PointD>();
- wContour.PointD aPoint;
- nx = (x0 * 2 - dist * 2) / n;
- for (i = 1; i <= n; i++)
- {
- x1 = dist + nx / 2 + (i - 1) * nx;
- if (ifX)
- {
- ytemp = Math.Sqrt((1 - Math.Pow((x1 - x0), 2) / Math.Pow(a, 2)) * Math.Pow(b, 2));
- y1 = y0 + ytemp;
- aPoint = new PointD();
- aPoint.X = x1;
- aPoint.Y = y1;
- pList.Add(aPoint);
- aPoint = new PointD();
- aPoint.X = x1;
- y1 = y0 - ytemp;
- aPoint.Y = y1;
- pList1.Add(aPoint);
- }
- else
- {
- ytemp = Math.Sqrt((1 - Math.Pow((x1 - x0), 2) / Math.Pow(b, 2)) * Math.Pow(a, 2));
- y1 = y0 + ytemp;
- aPoint = new PointD();
- aPoint.X = x1;
- aPoint.Y = y1;
- pList1.Add(aPoint);
- aPoint = new PointD();
- aPoint.X = x1;
- y1 = y0 - ytemp;
- aPoint.Y = y1;
- pList1.Add(aPoint);
- }
- }
- aPoint = new PointD();
- if (ifX)
- {
- aPoint.X = x0 - a;
- }
- else
- {
- aPoint.X = x0 - b;
- }
- aPoint.Y = y0;
- List<PointD> cLine = new List<PointD>();
- cLine.Add(aPoint);
- for (i = 0; i <= pList.Count - 1; i++)
- {
- cLine.Add(pList[i]);
- }
- aPoint = new PointD();
- aPoint.Y = y0;
- if (ifX)
- {
- aPoint.X = x0 + a;
- }
- else
- {
- aPoint.X = x0 + b;
- }
- cLine.Add(aPoint);
- for (i = pList1.Count - 1; i >= 0; i += -1)
- {
- cLine.Add(pList1[i]);
- }
- cLine.Add(cLine[0]);
- _clipLines.Add(cLine);
- }
- public void ClipLines()
- {
- _clipContourLines = new List<PolyLine>();
- foreach (List<PointD> cLine in _clipLines)
- _clipContourLines.AddRange(Contour.ClipPolylines(_contourLines, cLine));
- }
- public void ClipPolygons()
- {
- _clipContourPolygons = new List<Polygon>();
- //for (int i = 0; i < _clipLines.Count; i++)
- // _clipContourPolygons.AddRange(Contour.ClipPolygons(_contourPolygons, _clipLines[i]));
- //_clipContourPolygons.AddRange(Contour.ClipPolygons(_contourPolygons, _clipLines[20]));
- foreach (List<PointD> cLine in _clipLines)
- _clipContourPolygons.AddRange(Contour.ClipPolygons(_contourPolygons, cLine));
- }
- public void TracingPolygons()
- {
- _contourPolygons = Contour.TracingPolygons(_gridData, _contourLines, _borders, _CValues);
- }
- public void CreateLegend()
- {
- wContour.Legend aLegend = new wContour.Legend();
- wContour.PointD aPoint = new PointD();
- double width = _maxX - _minX;
- aPoint.X = _minX + width / 4;
- aPoint.Y = _minY + width / 100;
- wContour.Legend.legendPara lPara = new Legend.legendPara();
- lPara.startPoint = aPoint;
- lPara.isTriangle = true;
- lPara.isVertical = false;
- lPara.length = width / 2;
- lPara.width = width / 100;
- lPara.contourValues = _CValues;
- _legendPolygons = Legend.CreateLegend(lPara);
- }
- public void ClearObjects()
- {
- _discreteData = null;
- _gridData = null;
- _borders = new List<Border>();
- _contourLines = new List<PolyLine>();
- _contourPolygons = new List<Polygon>();
- _clipLines = new List<List<PointD>>();
- _clipContourLines = new List<PolyLine>();
- _clipContourPolygons = new List<Polygon>();
- _mapLines = new List<List<PointD>>();
- _legendPolygons = new List<Legend.lPolygon>();
- _streamLines = new List<PolyLine>();
- }
- public void SetCoordinate(double minX, double maxX, double minY, double maxY)
- {
- _minX = minX;
- _maxX = maxX;
- _minY = minY;
- _maxY = maxY;
- _scaleX = (this.PictureBox1.Width - 10) / (_maxX - _minX);
- _scaleY = (this.PictureBox1.Height - 10) / (_maxY - _minY);
- //this.PictureBox1.Refresh();
- }
- private void ToScreen(double pX, double pY, ref int sX, ref int sY)
- {
- sX = (int)((pX - _minX) * _scaleX);
- sY = (int)((_maxY - pY) * _scaleY);
- }
- private void ToScreen(double pX, double pY, ref float sX, ref float sY)
- {
- sX = (float)((pX - _minX) * _scaleX);
- sY = (float)((_maxY - pY) * _scaleY);
- }
- private void ToCoordinate(int sX, int sY, ref double pX, ref double pY)
- {
- pX = sX / _scaleX + _minX;
- pY = _maxY - sY / _scaleY;
- }
- public void PaintGraphics(Graphics g)
- {
- int i = 0;
- int j = 0;
- wContour.PolyLine aline = default(wContour.PolyLine);
- List<PointD> newPList = new List<PointD>();
- double aValue = 0;
- Color aColor = default(Color);
- Pen aPen = default(Pen);
- wContour.PointD aPoint = default(wContour.PointD);
- Point[] Points = null;
- int sX = 0;
- int sY = 0;
- //Draw contour polygons
- if (CB_ContourPolygon)
- {
- List<Polygon> drawPolygons = _contourPolygons;
- if (CB_Clipped)
- drawPolygons = _clipContourPolygons;
- for (i = 0; i < drawPolygons.Count; i++)
- {
- DrawPolygon(g, drawPolygons[i], false);
- }
- if (ChB_Highlight)
- {
- if (_highlightIdx < drawPolygons.Count)
- DrawPolygon(g, drawPolygons[_highlightIdx], true);
- }
- }
- //Draw contour lines
- if (CB_ContourLine)
- {
- List<PolyLine> drawLines = _contourLines;
- if (CB_Clipped)
- drawLines = _clipContourLines;
- for (i = 0; i <= drawLines.Count - 1; i++)
- {
- aline = drawLines[i];
- aValue = aline.Value;
- aColor = _colors[Array.IndexOf(_CValues, aValue)];
- newPList = aline.PointList;
- Points = new Point[newPList.Count];
- for (j = 0; j <= newPList.Count - 1; j++)
- {
- aPoint = (wContour.PointD)newPList[j];
- ToScreen(aPoint.X, aPoint.Y, ref sX, ref sY);
- Points[j] = new Point(sX, sY);
- }
- aPen = new Pen(Color.Black);
- aPen.Color = aColor;
- g.DrawLines(aPen, Points);
- }
- }
- //Draw border lines
- if (CB_BorderLines)
- {
- for (i = 0; i < _borders.Count; i++)
- {
- Border aBorder = _borders[i];
- for (j = 0; j < aBorder.LineNum; j++)
- {
- BorderLine bLine = aBorder.LineList[j];
- Points = new Point[bLine.pointList.Count];
- for (int k = 0; k < bLine.pointList.Count; k++)
- {
- aPoint = bLine.pointList[k];
- ToScreen(aPoint.X, aPoint.Y, ref sX, ref sY);
- Points[k] = new Point(sX, sY);
- }
- g.DrawLines(Pens.Purple, Points);
- //if (i == 3)
- //{
- // Pen bPen = new Pen(Color.Blue);
- // bPen.Width = 2;
- // g.DrawLines(bPen, Points);
- //}
- //if (i == 3)
- // g.DrawString(i.ToString(), new Font("Arial", 8), new SolidBrush(Color.Red), Points[0].X, Points[0].Y);
- }
- }
- }
- //Draw clip line
- if (CB_Clipped && _clipLines.Count > 0)
- {
- foreach (List<PointD> cLine in _clipLines)
- {
- Points = new Point[cLine.Count];
- for (i = 0; i < cLine.Count; i++)
- {
- aPoint = cLine[i];
- ToScreen(aPoint.X, aPoint.Y, ref sX, ref sY);
- Points[i] = new Point(sX, sY);
- }
- g.DrawLines(Pens.Purple, Points);
- }
- }
- //Draw data points
- Font drawFont = new Font("Arial", 8);
- SolidBrush drawBrush = new SolidBrush(Color.Black);
- if (CB_DiscreteData && _discreteData != null)
- {
- for (i = 0; i < _discreteData.GetLength(1); i++)
- {
- ToScreen(_discreteData[0, i], _discreteData[1, i], ref sX, ref sY);
- g.DrawEllipse(Pens.Red, sX, sY, 1.5f, 1.5f);
- //if (_discreteData[2, i] >= 0.1)
- // g.DrawString(_discreteData[2, i].ToString(_dFormat), drawFont, drawBrush, sX, sY);
- }
- }
- if (CB_GridData && _gridData != null)
- {
- for (i = 0; i < _gridData.GetLength(0); i++)
- {
- for (j = 0; j < _gridData.GetLength(1); j++)
- {
- ToScreen(_X[j], _Y[i], ref sX, ref sY);
- if (!DoubleEquals(_gridData[i, j], _undefData))
- {
- g.DrawEllipse(Pens.Red, sX, sY, 1.5f, 1.5f);
- //if (_gridData[i, j] >= 0.1)
- g.DrawString(_gridData[i, j].ToString(_dFormat), drawFont, drawBrush, sX, sY);
- //g.DrawString(i.ToString() + "," + j.ToString(), drawFont, drawBrush, sX, sY);
- }
- else
- g.DrawEllipse(Pens.Gray, sX, sY, 1.5f, 1.5f);
- }
- }
- }
- //Draw stream lines
- if (_streamLines.Count > 0)
- {
- for (i = 0; i < _streamLines.Count; i++)
- {
- aline = _streamLines[i];
- aValue = aline.Value;
- newPList = aline.PointList;
- PointF[] fPoints = new PointF[newPList.Count];
- float fX = 0, fY = 0;
- for (j = 0; j < newPList.Count; j++)
- {
- aPoint = (wContour.PointD)newPList[j];
- ToScreen(aPoint.X, aPoint.Y, ref fX, ref fY);
- fPoints[j] = new PointF(fX, fY);
- }
- aPen = new Pen(Color.Blue);
- g.DrawLines(aPen, fPoints);
- int len = 12;
- for (j = 0; j < fPoints.Length; j++)
- {
- if (j > 0 && j < fPoints.Length - 2 && j % len == 0)
- {
- //Draw arraw
- PointF aP = fPoints[j];
- PointF bPoint = fPoints[j + 1];
- DrawArrowYaq(g, aP, bPoint);
- //double U = bPoint.X - aP.X;
- //double V = bPoint.Y - aP.Y;
- //double angle = Math.Atan((V) / (U)) * 180 / Math.PI;
- //angle = angle + 90;
- //if (U < 0)
- // angle = angle + 180;
- //if (angle >= 360)
- // angle = angle - 360;
- //PointF[] apoints = new PointF[3];
- //PointF eP1 = new PointF();
- //double aSize = 8;
- //eP1.X = (int)(aP.X - aSize * Math.Sin((angle + 20.0) * Math.PI / 180));
- //eP1.Y = (int)(aP.Y + aSize * Math.Cos((angle + 20.0) * Math.PI / 180));
- //apoints[0] = eP1;
- //apoints[1] = aP;
- ////g.DrawLine(aPen, aP, eP1);
- //PointF eP2 = new PointF();
- //eP2.X = (int)(aP.X - aSize * Math.Sin((angle - 20.0) * Math.PI / 180));
- //eP2.Y = (int)(aP.Y + aSize * Math.Cos((angle - 20.0) * Math.PI / 180));
- ////g.DrawLine(aPen, aP, eP1);
- //apoints[2] = eP2;
- //g.DrawLines(aPen, apoints);
- }
- }
- }
- }
- //Draw map lines
- if (_mapLines.Count > 0)
- {
- for (i = 0; i < _mapLines.Count; i++)
- {
- newPList = _mapLines[i];
- Points = new Point[newPList.Count];
- for (j = 0; j <= newPList.Count - 1; j++)
- {
- aPoint = newPList[j];
- ToScreen(aPoint.X, aPoint.Y, ref sX, ref sY);
- Points[j] = new Point(sX, sY);
- }
- aPen = new Pen(Color.Black);
- aPen.Color = Color.Black;
- g.DrawLines(aPen, Points);
- //g.DrawString("0", new Font("Arial", 8), new SolidBrush(Color.Black), Points[0]);
- }
- }
- //---- Draw legend
- if (CB_ContourPolygon)
- {
- if (_legendPolygons.Count > 0)
- {
- wContour.Legend.lPolygon aLPolygon = default(wContour.Legend.lPolygon);
- SolidBrush aBrush = new SolidBrush(Color.Black);
- for (i = 0; i < _legendPolygons.Count; i++)
- {
- aLPolygon = _legendPolygons[i];
- aValue = aLPolygon.value;
- if (aLPolygon.isFirst)
- {
- aColor = _colors[0];
- }
- else
- {
- aColor = _colors[Array.IndexOf(_CValues, aValue) + 1];
- }
- newPList = aLPolygon.pointList;
- Points = new Point[newPList.Count];
- for (j = 0; j <= newPList.Count - 1; j++)
- {
- aPoint = newPList[j];
- ToScreen(aPoint.X, aPoint.Y, ref sX, ref sY);
- Points[j] = new Point(sX, sY);
- }
- aBrush.Color = aColor;
- g.FillPolygon(aBrush, Points);
- g.DrawPolygon(Pens.Black, Points);
- Point sPoint = Points[2];
- if (i < _legendPolygons.Count - 1)
- {
- g.DrawString(_CValues[i].ToString("0.0"), drawFont, Brushes.Black, sPoint.X - 10, sPoint.Y - 15);
- }
- }
- }
- }
- //PctureBox1.Image.Save("123.png", System.Drawing.Imaging.ImageFormat.Png);
- //g.Save(
- }
- private static bool DoubleEquals(double a, double b)
- {
- if (Math.Abs(a - b) < 0.000001)
- return true;
- else
- return false;
- }
- private float DrawArrowYaq(Graphics GR, PointF p0, PointF p1)
- {
- double dX = p0.X - p1.X;
- double dY = p0.Y - p1.Y;
- double X = p0.X - (dX / 2);
- double Y = p0.Y - (dY / 2);
- float Angle = getAngleYaq(dX, dY);
- RectangleF R = new RectangleF((float)X - 4, (float)Y - 4, 8, 8);
- // Rectangle.r
- // GR.DrawLine(Pens.Black, SC.TraceFrom, SC.TraceTo);
- // GR.FillEllipse(Brushes.Red, R);
- // return;
- float xMid = (float)X;
- float yMid = (float)Y;
- //R = new RectangleF(xMid - 4, yMid - 3, 8, 6);
- PointF[] pt = new PointF[5];
- pt[0] = new PointF(R.X, R.Y);
- pt[1] = new PointF(R.Right, R.Top + (R.Height / 2));
- pt[2] = new PointF(R.Left, R.Bottom);
- pt[3] = new PointF(R.Left + R.Width / 2, pt[1].Y);
- pt[4] = pt[0];
- // g.DrawLine(Pens.Red, 0, yMid, this.Width, yMid);
- // g.DrawLine(Pens.Red, xMid, 0, xMid, this.Height);
- //the central point of the rotation
- Matrix Mx = GR.Transform;
- GR.TranslateTransform(xMid, yMid);
- //rotation procedure
- // GR.RotateTransform(Angle + 90);
- Angle = 180 - Angle;
- GR.RotateTransform(-Angle);
- GR.TranslateTransform(-xMid, -yMid);
- GR.FillPolygon(Brushes.Black, pt);
- GR.ResetTransform();
- return Angle;
- // GR.Transform = Mx;
- }
- public static float getAngleYaq(double uValue, double vValue)
- {
- float angle = (float)(Math.Atan(vValue / uValue) * 180 / Math.PI);
- if (uValue < 0)
- {
- angle -= 180;
- }
- return angle;
- }
- private void DrawPolygon(Graphics g, Polygon aPolygon, bool isHighlight)
- {
- int j;
- PolyLine aline = aPolygon.OutLine;
- double aValue = aPolygon.LowValue;
- Color aColor = _colors[Array.IndexOf(_CValues, aValue) + 1];
- if (isHighlight)
- aColor = Color.Green;
- else
- {
- if (!aPolygon.IsHighCenter)
- {
- for (j = 0; j <= _colors.Length - 1; j++)
- {
- if (aColor == _colors[j])
- {
- aColor = _colors[j - 1];
- }
- }
- }
- }
- List<PointD> newPList = aline.PointList;
- //if (!Contour.IsClockwise(newPList))
- // newPList.Reverse();
- Point[] Points = new Point[newPList.Count];
- int sX = 0, sY = 0;
- for (j = 0; j <= newPList.Count - 1; j++)
- {
- PointD aPoint = newPList[j];
- ToScreen(aPoint.X, aPoint.Y, ref sX, ref sY);
- Points[j] = new Point(sX, sY);
- }
- GraphicsPath bPath = new GraphicsPath();
- GraphicsPath aPath = new GraphicsPath();
- aPath.AddPolygon(Points);
- bPath.AddLines(Points);
- //Region aRegion = new Region(aPath);
- if (aPolygon.HasHoles)
- {
- for (int h = 0; h < aPolygon.HoleLines.Count; h++)
- {
- newPList = aPolygon.HoleLines[h].PointList;
- //if (Contour.IsClockwise(newPList))
- // newPList.Reverse();
- Points = new Point[newPList.Count];
- for (j = 0; j <= newPList.Count - 1; j++)
- {
- PointD aPoint = newPList[j];
- ToScreen(aPoint.X, aPoint.Y, ref sX, ref sY);
- Points[j] = new Point(sX, sY);
- }
- //aPath = new GraphicsPath();
- aPath.AddPolygon(Points);
- GraphicsPath cPath = new GraphicsPath();
- cPath.AddLines(Points);
- bPath.AddPath(cPath, false);
- //aRegion.Xor(aPath);
- }
- }
- Pen aPen = new Pen(Color.Black);
- aPen.Color = aColor;
- SolidBrush aBrush = new SolidBrush(Color.Black);
- aBrush.Color = aColor;
- g.FillPath(aBrush, aPath);
- g.DrawPath(Pens.Black, bPath);
- }
- }
-
- }
复制代码 这是我把你的代码copy出来,生成一个类,测试调用方法
- private void DrawLine()
- {
- int layer = 0;
- Int16 element_type = Convert.ToInt16(this.comboBox3.SelectedItem);
- HHKJ.CloudMap.CloudHeader head = new HHKJ.CloudMap.CloudHeader();
- short _Width = 3000;
- short _Height = 3000;
- head.E0 = 140.7;
- head.Prjct = 'E';
- head.Width = _Width;
- head.Height = _Height;
- head.MaxLat = fhead.Latitude;
- head.MaxLon = fhead.Longitude + fhead.Longitudinal * fhead.Intervals_long;
- head.MinLat = fhead.Latitude - fhead.Latitudinal * fhead.Intervals_lat;
- head.MinLon = fhead.Longitude;
- head.Space = 1.25;
- HHKJ.CloudMap.CloudToImage cloud = new HHKJ.CloudMap.CloudToImage();
- cloud.CldHeader = head;
- cloud.Grap = Grap;
- for (int i = 0; i < fhead.Stored; i++)
- {
- if (e_type[i].E_type == Convert.ToInt16(this.comboBox1.SelectedItem) && e_type[i].Storage == element_type)
- {
- layer = i;
- break;
- }
- }
- this.pictureBox1.Width = _Width;
- this.pictureBox1.Height = _Height;
- line = new LineContour();
- line._startColor = Color.Yellow;
- line._endColor = Color.Red;
- line.ClearObjects();
- line.PictureBox1 = this.pictureBox1;
- //line.CreateGridData(fhead.Latitudinal, fhead.Longitudinal);
- line.SetCoordinate(-10, pictureBox1.Width, -10, pictureBox1.Height);
- fhead.Latitudinal = 20;
- fhead.Longitudinal = 20;
- line._gridData = new double[fhead.Latitudinal, fhead.Longitudinal];
- double[] _X = new double[fhead.Longitudinal];
- double[] _Y = new double[fhead.Latitudinal];
- double XDelt = this.pictureBox1.Width / fhead.Longitudinal;
- double YDelt = this.pictureBox1.Height / fhead.Latitudinal;
- for (int i = 0; i <= fhead.Longitudinal - 1; i++)
- {
- _X[i] = i * XDelt;
- }
- for (int i = 0; i <= fhead.Latitudinal - 1; i++)
- {
- _Y[i] = i * YDelt;
- }
- for (int j = 0; j < fhead.Latitudinal; j++)
- {
- for (int i = 0; i < fhead.Longitudinal; i++)
- {
- line._gridData[j, i] = e_type[layer].Reference + fdata[layer + 66 * this.comboBox2.SelectedIndex].Data[j, i] / (float)e_type[layer].Factor - 273.15f;
- }
- }
- //for (int j = 0; j < fhead.Latitudinal; j++)
- //{
- // PointF pf = cloud.LaLoToXY(head, fhead.Latitude - j * fhead.Intervals_lat, fhead.Longitude );
- // _Y[j] = pf.Y;
- //}
- //for (int i = 0; i < fhead.Longitudinal; i++)
- //{
- // PointF pf = cloud.LaLoToXY(head, fhead.Latitude , fhead.Longitude + i * fhead.Intervals_long);
- // _X[i] = pf.X;
- //}
- line.SetStation(_X, _Y);
- double[] values = new double[] {-20,-10,0,10, 20,30,40,50,60,70,80,90,300 ,500};
- line.SetContourValues(values);
- line.TracingContourLines();
- line.SmoothLines();
- line.GetEcllipseClipping();
- line.ClipLines();
- line.TracingPolygons();
- line.ClipPolygons();
- line._dFormat = "0";
- line.CreateLegend();
- line.CB_GridData = true;
- line.CB_ContourLine = true;
- line.CB_ContourPolygon = false;
- //Bitmap bmp = new Bitmap(_Width, _Height, PixelFormat.Format24bppRgb);
- //Grap = Graphics.FromImage(bmp);
- //Grap.Clear(Color.White);
- //line.PaintGraphics(Grap);
- //pictureBox1.Image = bmp;
- pictureBox1.Refresh();
- //bmp.Save("123.png" ,ImageFormat.Png);
- }
复制代码
|
|