---------------------------------------------------------------------------------------------------------
●·● 目录:
A1 …………
A2 ………… A3 ………… A4 ………… A5 ………… A6 ………… A7 ………… A8 ………… A9 …………---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ ╠══════════════════════════════════════════════════╣ ╚════════╝●·● Geometry 总结:
- Polyline:是 Path 的集合,可以实现 IGeometryCollection 接口,用于添加几何图形!
- Path:由 Segment 组成,可以实现 ISegmentCollection 接口,用于添加 Segment!
- Polygon:是 Ring 的集合,可以实现 IGeometryCollection 接口,用于添加几何图形!
- Ring:由 Segment 组成,可以实现 ISegmentCollection 接口,用于添加 Segment!
- Segment:包括 Line、CircularArc、EllipticArc、BezierCurve 四个!
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ ╠══════════════════════════════════════════════════╣ ╚════════╝●·● 绘制几何图形 —— 圆:
- 构造圆心点,IPoint。
- 构造圆弧,IConstructCircularArc,通过此接口,利用圆心和半径来确定圆弧。
- 构造线段,ISegment,将圆弧转为线段接口,用于添加到下面的线段集合中。
- 构造线段集合,ISegmentCollection,将上面的线段添加进来。
- 构造环,IRing,将线段集合转为环接口,用于实现图形的 Close 。
- 构造几何图形集合:IGeometryCollection,将上面的环添加到几何图形集合中,然后就可以用了。
有填充颜色的:
IPoint pPoint = new PointClass();pPoint.X = 110;pPoint.Y = 40;//构建圆对象IConstructCircularArc pConstructCircularArc = new CircularArcClass();pConstructCircularArc.ConstructCircle(pPoint, 20, false);ICircularArc pArc = pConstructCircularArc as ICircularArc; //不必要ISegment pSegment1 = pArc as ISegment;//通过ISegmentCollection构建Ring对象ISegmentCollection pSegCollection = new RingClass();object o = Type.Missing;//添加Segement对象即圆pSegCollection.AddSegment(pSegment1, ref o, ref o);//QI到IRing接口封闭Ring对象,使其有效IRing pRing = pSegCollection as IRing;pRing.Close();//通过Ring对象使用IGeometryCollection构建Polygon对象IGeometryCollection pGeometryColl = new PolygonClass();pGeometryColl.AddGeometry(pRing, ref o, ref o);//构建一个CircleElement对象IElement pElement = new CircleElementClass();pElement.Geometry = pGeometryColl as IGeometry;IGraphicsContainer pGC = this.axMapControl1.ActiveView.GraphicsContainer;pGC.AddElement(pElement, 0);this.axMapControl1.Refresh();
没有填充颜色的,只需加入下面一句,使其为透明颜色即可!
pColor.Transparency = 0;
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ ╠══════════════════════════════════════════════════╣ ╚════════╝●·● 绘制几何图形 —— 椭圆:
- 构造两个点,IPoint。
- 构造包络线也就是矩形,IEnvelope,通过上面的两个点。
- 构造圆弧,IConstructEllipticArc,通过此接口,利用矩形来确定椭圆弧。
- 构造线段,ISegment,将椭圆弧转为线段接口,用于添加到下面的线段集合中。
- 构造线段集合,ISegmentCollection,将上面的线段添加进来。
- 构造环,IRing,将线段集合转为环接口,用于实现图形的 Close 。
- 构造几何图形集合:IGeometryCollection,将上面的环添加到几何图形集合中,然后就可以用了。
有填充颜色的:
IPoint pPoint1 = new PointClass();pPoint1.PutCoords(80, 20);IPoint pPoint2 = new PointClass();pPoint2.PutCoords(130, 50);IEnvelope pEnvelope = new EnvelopeClass();pEnvelope.LowerLeft = pPoint1;pEnvelope.UpperRight = pPoint2;IConstructEllipticArc pConstructEllipticArc = new EllipticArcClass();pConstructEllipticArc.ConstructEnvelope(pEnvelope);IEllipticArc pEllipticArc = pConstructEllipticArc as IEllipticArc; //不必要ISegment pSegment = pEllipticArc as ISegment;ISegmentCollection pSegmentCollection = new RingClass();object o = Type.Missing;pSegmentCollection.AddSegment(pSegment, ref o, ref o);IRing pRing = pSegmentCollection as IRing;pRing.Close();IGeometryCollection pGeometryColl = new PolygonClass();pGeometryColl.AddGeometry(pRing, ref o, ref o);ISimpleLineSymbol pSimpleLineSym = new SimpleLineSymbol();pSimpleLineSym.Color = GetColor(0, 0, 0);pSimpleLineSym.Width = 2;ISimpleFillSymbol pSimpleFillSym = new SimpleFillSymbol();IRgbColor pColor = new RgbColor();pColor.Red = 255;pColor.Green = 255;pSimpleFillSym.Color = pColor;pSimpleFillSym.Outline = pSimpleLineSym;IElement pElement = new EllipseElementClass();pElement.Geometry = pGeometryColl as IGeometry;IFillShapeElement pFillShapeElement = pElement as IFillShapeElement;pFillShapeElement.Symbol = pSimpleFillSym;IGraphicsContainer pGC = axMapControl1.ActiveView.GraphicsContainer;pGC.AddElement(pElement, 0);axMapControl1.Refresh();
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ ╠══════════════════════════════════════════════════╣ ╚════════╝●·● 绘制几何图形 —— 圆弧:
- 构造圆心点,IPoint。
- 构造圆弧,IConstructCircularArc,通过此接口,利用圆心、半径、起始角度,中心角来确定圆弧。
- 构造线段,ISegment,将圆弧转为线段接口,用于添加到下面的线段集合中。
- 构造线段集合,ISegmentCollection,将上面的线段添加进来。
- 构造环或者路径,IRing or IPath,将线段集合转为环接口或是路径接口 。
- 构造几何图形集合:IGeometryCollection,将上面的环添加到几何图形集合中,然后就可以用了。
IPoint pPoint = new PointClass();pPoint.X = 80;pPoint.Y = 40;IConstructCircularArc pConstructCircularArc = new CircularArcClass();pConstructCircularArc.ConstructBearingRadiusAngle(pPoint, 0, false, 20, Math.PI*4/3);ICircularArc pArc = pConstructCircularArc as ICircularArc; //不必要ISegment pSegment1 = pArc as ISegment;ISegmentCollection pSegCollection = new RingClass();object o = Type.Missing;pSegCollection.AddSegment(pSegment1, ref o, ref o);IRing pRing = pSegCollection as IRing;//IPath pRing = pSegCollection as IPath; //也可以的IGeometryCollection pGeometryColl = new PolygonClass();pGeometryColl.AddGeometry(pRing, ref o, ref o);ISimpleLineSymbol pSimpleLineSym = new SimpleLineSymbol();pSimpleLineSym.Color = GetColor(0, 0, 0);pSimpleLineSym.Width = 2;ISimpleFillSymbol pSimpleFillSym = new SimpleFillSymbol();IRgbColor pColor = new RgbColor();pColor.RGB = 255;//pColor.Transparency = 0; //透明填充pSimpleFillSym.Color = pColor;pSimpleFillSym.Outline = pSimpleLineSym;IElement pElement = new CircleElementClass();IFillShapeElement pFillShapeEle = pElement as IFillShapeElement;pFillShapeEle.Symbol = pSimpleFillSym;pElement.Geometry = pGeometryColl as IGeometry;IGraphicsContainer pGC = this.axMapControl1.ActiveView.GraphicsContainer;pGC.AddElement(pElement, 0);this.axMapControl1.Refresh();
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ ╠══════════════════════════════════════════════════╣ ╚════════╝●·● 绘制几何图形 —— 椭圆弧:
1. 实现画¼圆弧:Construct an elliptic arc that starts at fromPoint, goes to toPoint, and spans an angle of pi/2. The rotation of the ellipse will be either 0 or pi/2.
IPoint pPoint1 = new PointClass();pPoint1.PutCoords(105, 20);IPoint pPoint2 = new PointClass();pPoint2.PutCoords(130, 35);IEnvelope pEnvelope = new EnvelopeClass();pEnvelope.LowerLeft = pPoint1;pEnvelope.UpperRight = pPoint2;IConstructEllipticArc pConstructEllipticArc = new EllipticArcClass();pConstructEllipticArc.ConstructQuarterEllipse(pPoint1, pPoint2, true); //第三个参数决定顺逆时针!ISegment pSegment = pConstructEllipticArc as ISegment;ISegmentCollection pSegmentCollection = new RingClass();object o = Type.Missing;pSegmentCollection.AddSegment(pSegment, ref o, ref o);IRing pRing = pSegmentCollection as IRing;IGeometryCollection pGeometryColl = new PolygonClass();pGeometryColl.AddGeometry(pRing, ref o, ref o);ISimpleLineSymbol pSimpleLineSym = new SimpleLineSymbol();pSimpleLineSym.Color = GetColor(0, 0, 0);pSimpleLineSym.Width = 2;ISimpleFillSymbol pSimpleFillSym = new SimpleFillSymbol();IRgbColor pColor = new RgbColor();pColor.Red = 255;pSimpleFillSym.Color = pColor;pSimpleFillSym.Outline = pSimpleLineSym;IElement pElement = new EllipseElementClass();pElement.Geometry = pGeometryColl as IGeometry;IFillShapeElement pFillShapeElement = pElement as IFillShapeElement;pFillShapeElement.Symbol = pSimpleFillSym;IGraphicsContainer pGC = axMapControl1.ActiveView.GraphicsContainer;pGC.AddElement(pElement, 0);axMapControl1.Refresh();
2. 实现根据起始点,以及限制在一个矩形中:Construct an elliptic arc that starts at fromPoint, goes to toPoint, and tries to have the embedded ellipse inscribed in the suggestedEnvelope. The result will have rotation of 0 or pi/2.
IPoint pPoint1 = new PointClass();pPoint1.PutCoords(80, 20);IPoint pPoint2 = new PointClass();pPoint2.PutCoords(130, 50);IPoint pPoint3 = new PointClass();pPoint3.PutCoords(50, 20);IPoint pPoint4 = new PointClass();pPoint4.PutCoords(140, 60);IEnvelope pEnvelope = new EnvelopeClass();pEnvelope.LowerLeft = pPoint3;pEnvelope.UpperRight = pPoint4;IConstructEllipticArc pConstructEllipticArc = new EllipticArcClass();pConstructEllipticArc.ConstructTwoPointsEnvelope(pPoint1, pPoint2, pEnvelope, esriArcOrientation.esriArcMajor);ISegment pSegment = pConstructEllipticArc as ISegment;ISegmentCollection pSegmentCollection = new RingClass();object o = Type.Missing;pSegmentCollection.AddSegment(pSegment, ref o, ref o);IRing pRing = pSegmentCollection as IRing;IGeometryCollection pGeometryColl = new PolygonClass();pGeometryColl.AddGeometry(pRing, ref o, ref o);ISimpleLineSymbol pSimpleLineSym = new SimpleLineSymbol();pSimpleLineSym.Color = GetColor(0, 0, 0);pSimpleLineSym.Width = 2;ISimpleFillSymbol pSimpleFillSym = new SimpleFillSymbol();IRgbColor pColor = new RgbColor();pColor.Red = 255;pColor.Transparency = 0;pSimpleFillSym.Color = pColor;pSimpleFillSym.Outline = pSimpleLineSym;IElement pElement2 = new RectangleElementClass();pElement2.Geometry = pEnvelope;IFillShapeElement pFillShapeElement2 = pElement2 as IFillShapeElement;pFillShapeElement2.Symbol = pSimpleFillSym;IElement pElement = new EllipseElementClass();pElement.Geometry = pGeometryColl as IGeometry;IFillShapeElement pFillShapeElement = pElement as IFillShapeElement;pColor.Transparency = 1;pSimpleFillSym.Color = pColor;pFillShapeElement.Symbol = pSimpleFillSym;IGraphicsContainer pGC = axMapControl1.ActiveView.GraphicsContainer;pGC.AddElement(pElement, 0);pGC.AddElement(pElement2, 0);axMapControl1.Refresh();
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ ╠══════════════════════════════════════════════════╣ ╚════════╝●·● 绘制几何图形 —— 椭圆:
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ ╠══════════════════════════════════════════════════╣ ╚════════╝●·● 绘制几何图形 —— 椭圆: