protected override SecProp ShapeSecProp() { CircularArc bendl = new CircularArc { Material = Material, r = r1, t = t, phi = 90 * Math.PI / 180, point = "j", xp = 0, yp = 0, theta = -(45 + 90) * Math.PI / 180 }; CircularArc bendu = new CircularArc { Material = Material, r = r2, t = t, phi = 90 * Math.PI / 180, point = "j", xp = t, yp = h, theta = 45 * Math.PI / 180 }; Rectangle recl = new Rectangle { Material = Material, b = b1 - r1 - t, t = t, point = "a", xp = t + r1, yp = 0, theta = 0 }; Rectangle recu = new Rectangle { Material = Material, b = b2 - r2 - t, t = t, point = "e", xp = -r2, yp = h, theta = 0 }; Rectangle vert = new Rectangle { Material = Material, b = h - r1 - r2 - 2 * t, t = t, point = "c", xp = 0, yp = r1 + t, theta = 90 * Math.PI / 180 }; Section FZ = new Section(); FZ.AddShape(bendl); FZ.AddShape(bendu); FZ.AddShape(recl); FZ.AddShape(recu); FZ.AddShape(vert); return(FZ.CalculateSecProp()); }
private void CircularArcToolActivate(object sender, EventArgs e) { CircularArc arc = new CircularArc(new RectangleF(0, 0, 50, 50)); diagramComponent.Controller.NodeToInsert = arc; SetActiveTool("InsertNodeTool"); }
public static CircularArc ConnectShapesArc(Shape Start, Shape End, ICapStyle StartCapStyle, ICapStyle EndCapStyle, Object Tag, Dataweb.NShape.WinFormsUI.Display Display, Dataweb.NShape.Project Project, ILineStyle LineStyle, Layer Layer) { CircularArc arc = (CircularArc)Project.ShapeTypes["CircularArc"].CreateInstance(); arc.LineStyle = LineStyle; arc.Tag = Tag; arc.SecurityDomainName = 'B'; Display.Diagram.Shapes.Add(arc); arc.StartCapStyle = StartCapStyle; arc.EndCapStyle = EndCapStyle; arc.Connect(ControlPointId.FirstVertex, Start, ControlPointId.Reference); arc.Connect(ControlPointId.LastVertex, End, ControlPointId.Reference); Point firstPt = arc.GetControlPointPosition(ControlPointId.FirstVertex); Point lastPt = arc.GetControlPointPosition(ControlPointId.LastVertex); Point dstPos = Point.Empty; dstPos.X = ((firstPt.X + lastPt.X) / 2) + 1; dstPos.Y = ((firstPt.Y + lastPt.Y) / 2) + 1; arc.InsertVertex(ControlPointId.LastVertex, dstPos.X, dstPos.Y); Display.Diagram.AddShapeToLayers(arc, Layer.Id); Project.Repository.Insert((Shape)arc, Display.Diagram); return(arc); }
private ICircularArc method_8(IPoint point, double num, bool flag) { IConstructCircularArc constructCircularArc = new CircularArc() as IConstructCircularArc; constructCircularArc.ConstructCircle(point, num, flag); return((ICircularArc)constructCircularArc); }
public static ICircularArc CreateCircArc(IPoint pCenter, IPoint pFrom, ref IPoint pTo) { ICircularArc circularArcClass = null; circularArcClass = new CircularArc(); circularArcClass.PutCoords(pCenter, pFrom, pTo, esriArcOrientation.esriArcClockwise); return(circularArcClass); }
private void carcToolStripButton_Click(object sender, EventArgs e) { CircularArc carc = new CircularArc(new RectangleF(300, 300, 100, 70)); // set your custom node to the NodeToInsert property this.diagram1.Controller.NodeToInsert = carc; SetActiveTool("InsertNodeTool"); }
public AGSCircularArcSegment(CircularArc srcSeg) { base.StartPoint = new AGSPoint(srcSeg.FromPoint as PointN); base.EndPoint = new AGSPoint(srcSeg.ToPoint as PointN); this.Center = new AGSPoint(srcSeg.CenterPoint as PointN); this.FromAngle = srcSeg.FromAngle; this.ToAngle = srcSeg.ToAngle; this.IsMinor = srcSeg.IsMinor; this.IsCounterClockwise = srcSeg.IsCounterClockwise; }
private static Entity DrawCircle(CircularArc arc, double defaultElevation) { PointN pointN = arc.FromPoint as PointN; PointN pointN2 = arc.CenterPoint as PointN; double num = Math.Sqrt((pointN.X - pointN2.X) * (pointN.X - pointN2.X) + (pointN.Y - pointN2.Y) * (pointN.Y - pointN2.Y)); Point3d point3d = new Point3d(pointN2.X, pointN2.Y, pointN2.Z); Entity entity = new Circle(point3d, Vector3d.ZAxis, num); entity.ColorIndex = (256); return(entity); }
/// <summary> /// 通过开始点和结束点创建半圆弧片段 /// </summary> /// <param name="fromPoint">开始点</param> /// <param name="toPoint">结束点</param> /// <returns>半圆弧片段</returns> public static ISegment CreateHalfCircularArcByTwoPoints(IPoint fromPoint, IPoint toPoint) { ILine line = CreateLineByTwoPoints(fromPoint, toPoint); ILine normal = new Line(); line.QueryNormal(esriSegmentExtension.esriNoExtension, 0.5, true, (double)(line.Length / 2.0), normal); IConstructCircularArc Constructor = new CircularArc() as IConstructCircularArc; Constructor.ConstructThreePoints(fromPoint, normal.ToPoint, toPoint, true); return((ISegment)Constructor); }
private static Entity DrawCircularArc(CircularArc arc, double defaultElevation, Point[] densifiedPoints) { PointN pointN = arc.FromPoint as PointN; PointN pointN2 = arc.ToPoint as PointN; PointN pointN3 = arc.CenterPoint as PointN; Point3d point3d = new Point3d(pointN.X, pointN.Y, pointN.Z); Point3d point3d2 = new Point3d(pointN3.X, pointN3.Y, pointN3.Z); Point3d point3d3 = new Point3d(pointN2.X, pointN2.Y, pointN2.Z); Point2d centerPoint = new Point2d(pointN3.X, pointN3.Y); Point2d point2d = new Point2d(pointN.X, pointN.Y); Math.Abs(centerPoint.GetDistanceTo(point2d)); CircularArc3d circArc; if (densifiedPoints != null) { int num = densifiedPoints.Length / 2; PointN pointN4 = (PointN)densifiedPoints[num]; if (arc.IsCounterClockwise) { PointN arg_CC_0 = (PointN)densifiedPoints[0]; PointN arg_D9_0 = (PointN)densifiedPoints[densifiedPoints.Length - 1]; } else { PointN arg_E4_0 = (PointN)densifiedPoints[0]; PointN arg_F1_0 = (PointN)densifiedPoints[densifiedPoints.Length - 1]; } Point3d point3d4 = new Point3d(pointN4.X, pointN4.Y, pointN4.Z); circArc = new CircularArc3d(point3d, point3d4, point3d3); } else { Point2d point2d2 = new Point2d(point3d.X, point3d.Y); Point2d point2d3 = new Point2d(point3d3.X, point3d3.Y); double num2 = GIS2CAD.CalcThetaFromVectors(point2d2, point2d3, centerPoint, arc.IsCounterClockwise); double num3 = Math.Tan(num2 / 4.0); if (!arc.IsCounterClockwise) { num3 *= -1.0; } CircularArc2d circularArc2d = new CircularArc2d(point2d2, point2d3, num3, false); Point2d[] samplePoints = circularArc2d.GetSamplePoints(3); Point3d point3d5 = new Point3d(samplePoints[1].X, samplePoints[1].Y, point3d2.Z); circArc = new CircularArc3d(point3d, point3d5, point3d3); } new Point3d(pointN3.X, pointN3.Y, pointN3.Z); Arc arc2 = GIS2CAD.CreateFromCircularArc(circArc); arc2.ColorIndex = (256); return(arc2); }
public AGSPath(Path srcP) { this.Segments = new List <AGSSegment>(); if (srcP.SegmentArray != null) { Segment[] segmentArray = srcP.SegmentArray; for (int i = 0; i < segmentArray.Length; i++) { Segment segment = segmentArray[i]; Line line = segment as Line; CircularArc circularArc = segment as CircularArc; EllipticArc ellipticArc = segment as EllipticArc; BezierCurve bezierCurve = segment as BezierCurve; if (line != null) { this.Segments.Add(new AGSLineSegment(line)); } else if (circularArc != null) { if (circularArc.IsLine) { this.Segments.Add(new AGSLineSegment(circularArc.FromPoint as PointN, circularArc.ToPoint as PointN)); } else { this.Segments.Add(new AGSCircularArcSegment(circularArc)); } } else if (ellipticArc != null) { this.Segments.Add(new AGSEllipticalArcSegment(ellipticArc)); } else if (bezierCurve != null) { this.Segments.Add(new AGSBezierSegment(bezierCurve)); } } return; } if (srcP.PointArray != null) { int num = srcP.PointArray.Length; AGSPoint f = new AGSPoint(srcP.PointArray[0] as PointN); for (int j = 1; j < num; j++) { AGSPoint aGSPoint = new AGSPoint(srcP.PointArray[j] as PointN); this.Segments.Add(new AGSLineSegment(f, aGSPoint)); f = aGSPoint; } } }
private IPoint ComputeCenterPointFromRadius(IPolyline ThePolyline, double NewRadius, bool IsMinorCurve) { IConstructCircularArc pCircArcConst = new CircularArc() as IConstructCircularArc; pCircArcConst.ConstructEndPointsRadius(ThePolyline.FromPoint, ThePolyline.ToPoint, (NewRadius < 0), Math.Abs(NewRadius), IsMinorCurve); ICircularArc pCircArc = pCircArcConst as ICircularArc; IPoint pCtrPoint = pCircArc.CenterPoint; IZAware pZAw = pCtrPoint as IZAware; pZAw.ZAware = true; pCtrPoint.Z = 0; return(pCtrPoint); }
public override void OnMouseDown(int button, int Shift, int x, int y) { if (button != 1) { return; } if (this._context.ActiveView is IPageLayout) { IPoint location = this._context.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); IMap map = this._context.ActiveView.HitTestMap(location); if (map == null) { return; } if (map != this._context.FocusMap) { this._context.ActiveView.FocusMap = map; this._context.ActiveView.Refresh(); } } IPoint point = ((IActiveView)this._context.FocusMap).ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); frmInputText frm = new frmInputText(); frm.txtText.Properties.EditFormat.FormatType = FormatType.Numeric; frm.Label = "输入半径"; if (frm.ShowDialog() != DialogResult.OK) { return; } try { double radius = Convert.ToDouble(frm.txtText.EditValue); IConstructCircularArc2 arc2 = new CircularArc() as IConstructCircularArc2; arc2.ConstructCircle(point, radius, false); IPolygon polygon = new Polygon() as IPolygon; object value = Missing.Value; (polygon as ISegmentCollection).AddSegment(arc2 as ISegment, ref value, ref value); _plugin.FireFenceAdded(new FenceAddedArgs((IGeometry)polygon)); IActiveView activeView = this._context.FocusMap as IActiveView; activeView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, polygon.Envelope); } catch (Exception ex) { MessageService.Current.Warn("半径必须为数字!"); } }
protected override SecProp ShapeSecProp() { CircularArc bend = new CircularArc { Material = Material, r = r, t = t, phi = 90 * Math.PI / 180, point = "j", xp = 0, yp = 0, theta = -(45 + 90) * Math.PI / 180 }; Rectangle rec1 = new Rectangle { Material = Material, b = b1 - r - t, t = t, point = "a", xp = t + r, yp = 0, theta = 0 }; Rectangle rec2 = new Rectangle { Material = Material, b = b2 - r - t, t = t, point = "c", xp = 0, yp = r + t, theta = 90 * Math.PI / 180 }; Section FA = new Section(); FA.AddShape(bend); FA.AddShape(rec1); FA.AddShape(rec2); return(FA.CalculateSecProp()); }
private ICircularArc method_1(IPoint ipoint_1, IPoint ipoint_2, IPoint ipoint_3) { ICircularArc circularArc; try { IConstructCircularArc circularArcClass = new CircularArc() as IConstructCircularArc; circularArcClass.ConstructThreePoints(ipoint_1, ipoint_3, ipoint_2, false); circularArc = circularArcClass as ICircularArc; } catch (Exception exception) { exception.ToString(); ICircularArc circularArcClass1 = new CircularArc() { FromPoint = ipoint_1, ToPoint = ipoint_2 }; circularArc = circularArcClass1; } return(circularArc); }
public List <IPrintPageInfo> CreateStripMapPageInfos(IPolyline stripLine) { IPolyline pPolyline; IPoint pCenterPoint; IPolygon pCirclePoly; IPolygon pGridPoly; IConstructCircularArc pCircularArc; ISegmentCollection pSegmentCollection; ITopologicalOperator pTopoOpt; IGeometryCollection pGeoCol; IPoint pIntersectPoint; ICurve pArc; IPoint pIntersectPointPrev; bool bFirstRun; int lLoop2; double dHighest = 0; int lHighestRef; double dHighestPrev; ICurve pCurve; ILine pLine; IPolyline pPLine; bool bContinue; bool bReducedRadius; double dGridAngle; double dHighestThisTurn; int lCounter = 0; List <IPrintPageInfo> pages = new List <IPrintPageInfo>(); pPolyline = stripLine; pCenterPoint = pPolyline.FromPoint; double m_GridWidth = _mapTemplate.Width * _scale / 100.0; double m_GridHeight = _mapTemplate.Height * _scale / 100.0; double dCircleRadius; List <double> colIntersects = new List <double>(); double dIntersect; dHighestPrev = -1; bFirstRun = true; pArc = pPolyline; bContinue = false; bool isLoop1 = true; object missing = Missing.Value; do { if (bFirstRun) { dCircleRadius = m_GridWidth / 2.0; } else { dCircleRadius = m_GridWidth; } bReducedRadius = false; do { //! 创建搜索圆 pCircularArc = new CircularArc() as IConstructCircularArc; pCircularArc.ConstructCircle(pCenterPoint, dCircleRadius, false); pCirclePoly = new Polygon() as IPolygon; pSegmentCollection = pCirclePoly as ISegmentCollection; pSegmentCollection.AddSegment(pCircularArc as ISegment, ref missing, ref missing); pTopoOpt = pPolyline as ITopologicalOperator; pGeoCol = new GeometryBag() as IGeometryCollection; pGeoCol = pTopoOpt.Intersect(pCirclePoly, esriGeometryDimension.esriGeometry0Dimension) as IGeometryCollection; if (pGeoCol.GeometryCount == 0) { //! 需要检查,没有交点的的时候的处理 return(null); } pArc = pPolyline; lHighestRef = -1; dHighestThisTurn = 102; for (lLoop2 = 0; lLoop2 < pGeoCol.GeometryCount; lLoop2++) { pIntersectPoint = pGeoCol.Geometry[lLoop2] as IPoint; dIntersect = ReturnPercentageAlong(pPolyline, pIntersectPoint); if (dIntersect > (dHighestPrev * 1.001) && dIntersect < dHighestThisTurn) { dHighest = dIntersect; dHighestThisTurn = dIntersect; lHighestRef = lLoop2; } } if (lHighestRef < 0) { dHighest = 101; pIntersectPoint = IntersectPointExtendedTo(pPolyline, pCirclePoly); pIntersectPointPrev = pCenterPoint; } else { pIntersectPoint = pGeoCol.Geometry[lHighestRef] as IPoint; if (bFirstRun) { pIntersectPointPrev = new Point(); pIntersectPointPrev.PutCoords(pCenterPoint.X - (pIntersectPoint.X - pCenterPoint.X), pCenterPoint.Y - (pIntersectPoint.Y - pCenterPoint.Y)); } else { pIntersectPointPrev = pCenterPoint; } } if (bReducedRadius) { IPolyline pTmpPLine; IPolygon pTmpCPoly; IPoint pTmpIntPoint; pCircularArc = new CircularArc() as IConstructCircularArc; if (bFirstRun) { pCircularArc.ConstructCircle(pCenterPoint, m_GridWidth / 2.0, false); } else { pCircularArc.ConstructCircle(pCenterPoint, m_GridWidth, false); } pTmpCPoly = new Polygon() as IPolygon; pSegmentCollection = pTmpCPoly as ISegmentCollection; pSegmentCollection.AddSegment((ISegment)pCircularArc, ref missing, ref missing); pTmpPLine = new Polyline() as IPolyline; pTmpPLine.FromPoint = pIntersectPointPrev; pTmpPLine.ToPoint = pIntersectPoint; pTmpIntPoint = IntersectPointExtendedTo(pTmpPLine, pTmpCPoly); CreateAngledGridPolygon(pIntersectPointPrev, pTmpIntPoint, out pGridPoly, out dGridAngle); } else { CreateAngledGridPolygon(pIntersectPointPrev, pIntersectPoint, out pGridPoly, out dGridAngle); } pTopoOpt = pGridPoly as ITopologicalOperator; pGeoCol = new GeometryBag() as IGeometryCollection; pGeoCol = pTopoOpt.Intersect(pPolyline, esriGeometryDimension.esriGeometry0Dimension) as IGeometryCollection; bContinue = true; if (pGeoCol.GeometryCount > 2) { colIntersects = new List <double>(); for (lLoop2 = 2; lLoop2 < pGeoCol.GeometryCount; lLoop2++) { colIntersects.Add(ReturnPercentageAlong(pArc, pGeoCol.Geometry[lLoop2] as IPoint)); } for (lLoop2 = 0; lLoop2 < colIntersects.Count; lLoop2++) { if (colIntersects[lLoop2] > (dHighestPrev * 1.001) && colIntersects[lLoop2] < (dHighestPrev * 0.999)) { bContinue = false; dHighest = dHighestPrev; dCircleRadius = dCircleRadius - m_GridWidth * 0.1; bReducedRadius = true; if (dCircleRadius < 0) { bContinue = true; break; } } } } if (bContinue && bReducedRadius) { double dTmpHighest; pArc = pPolyline; lHighestRef = -1; dTmpHighest = -1; for (lLoop2 = 0; lLoop2 < pGeoCol.GeometryCount; lLoop2++) { pIntersectPoint = pGeoCol.Geometry[lLoop2] as IPoint; dIntersect = ReturnPercentageAlong(pArc, pIntersectPoint); if (dIntersect > dTmpHighest) { dTmpHighest = dIntersect; lHighestRef = lLoop2; } } if (lHighestRef >= 0) { pIntersectPoint = pGeoCol.Geometry[lHighestRef] as IPoint; } dHighest = dTmpHighest; } } while (!bContinue); bFirstRun = false; dHighestPrev = dHighest; lCounter++; IPrintPageInfo page = new PrintPageInfo(); page.Boundary = pGridPoly; page.PageID = lCounter; page.Angle = dGridAngle; page.PageName = "带状图(" + lCounter.ToString() + ")"; page.Scale = _scale; pages.Add(page); pCenterPoint = pIntersectPoint; } while (dHighest < 100); foreach (IPrintPageInfo pageInfo in pages) { pageInfo.TotalCount = pages.Count; } return(pages); }
public bool Snap(IGeometry igeometry_0, IPoint ipoint_0, double double_0) { ILine lineClass; double length = 0; int num = 0; int num1 = 0; bool flag = true; IPoint pointClass = new ESRI.ArcGIS.Geometry.Point(); double num2 = 1000; bool flag1 = false; object value = Missing.Value; IPoint ipoint0 = ipoint_0; IPoint point = null; point = (!(igeometry_0 is IPoint) ? ((IPointCollection)igeometry_0).Point[0] : (IPoint)igeometry_0); for (int i = 0; i < this.ifeatureCache_0.Count; i++) { IHitTest shape = (IHitTest)this.ifeatureCache_0.Feature[i].Shape; if (shape.HitTest(ipoint0, double_0, esriGeometryHitPartType.esriGeometryPartBoundary, pointClass, ref length, ref num, ref num1, ref flag)) { IGeometryCollection geometryCollection = shape as IGeometryCollection; if (geometryCollection != null) { ISegmentCollection geometry = geometryCollection.Geometry[num] as ISegmentCollection; if (geometry != null) { ISegment segment = geometry.Segment[num1]; if (segment is ICircularArc) { IPoint centerPoint = ((ICircularArc)segment).CenterPoint; ILine line = new Line(); line.PutCoords(point, centerPoint); double length1 = line.Length; IConstructCircularArc circularArcClass = new CircularArc() as IConstructCircularArc; circularArcClass.ConstructCircle(point, length1, true); IGeometryCollection polylineClass = new Polyline() as IGeometryCollection; ISegmentCollection pathClass = new ESRI.ArcGIS.Geometry.Path() as ISegmentCollection; pathClass.AddSegment((ISegment)circularArcClass, ref value, ref value); polylineClass.AddGeometry((IGeometry)pathClass, ref value, ref value); ((ITopologicalOperator)polylineClass).Simplify(); IGeometryCollection polylineClass1 = new Polyline() as IGeometryCollection; ISegmentCollection segmentCollection = new Path() as ISegmentCollection; segmentCollection.AddSegment(segment, ref value, ref value); polylineClass1.AddGeometry((IGeometry)segmentCollection, ref value, ref value); ((ITopologicalOperator)polylineClass1).Simplify(); IGeometry geometry1 = ((ITopologicalOperator)polylineClass).Intersect((IGeometry)polylineClass1, esriGeometryDimension.esriGeometry0Dimension); if (geometry1 != null) { if (!(geometry1 is IPointCollection)) { lineClass = new Line(); lineClass.PutCoords((IPoint)geometry1, ipoint0); if (num2 > length) { num2 = length; pointClass = ((IPointCollection)geometry1).Point[0]; ipoint_0.PutCoords(pointClass.X, pointClass.Y); flag1 = true; } } else { lineClass = new Line(); ILine lineClass1 = new Line(); lineClass.PutCoords(((IPointCollection)geometry1).Point[0], ipoint0); lineClass1.PutCoords(((IPointCollection)geometry1).Point[1], ipoint0); if (lineClass.Length <= lineClass1.Length) { length = lineClass.Length; pointClass = ((IPointCollection)geometry1).Point[0]; } else { length = lineClass1.Length; pointClass = ((IPointCollection)geometry1).Point[1]; } if (num2 > length) { num2 = length; pointClass = ((IPointCollection)geometry1).Point[0]; ipoint_0.PutCoords(pointClass.X, pointClass.Y); flag1 = true; } } } } } } } } return(flag1); }
private ISegment method_2(ISegment isegment_0, IPoint ipoint_0) { ISegment lineClass; IPoint pointClass; IPoint point; ISegment segment; IPoint x; double num; double num1; double x1; double num2; IPoint fromPoint = isegment_0.FromPoint; IPoint toPoint = isegment_0.ToPoint; if (isegment_0.GeometryType == esriGeometryType.esriGeometryLine) { lineClass = new Line() as ISegment; pointClass = new ESRI.ArcGIS.Geometry.Point(); pointClass.PutCoords(2 * ipoint_0.X - fromPoint.X, fromPoint.Y); point = new ESRI.ArcGIS.Geometry.Point(); point.PutCoords(2 * ipoint_0.X - toPoint.X, toPoint.Y); lineClass.FromPoint = pointClass; lineClass.ToPoint = point; segment = lineClass; } else if (isegment_0.GeometryType == esriGeometryType.esriGeometryCircularArc) { lineClass = new CircularArc() as ISegment; pointClass = new ESRI.ArcGIS.Geometry.Point(); pointClass.PutCoords(2 * ipoint_0.X - fromPoint.X, fromPoint.Y); point = new ESRI.ArcGIS.Geometry.Point(); point.PutCoords(2 * ipoint_0.X - toPoint.X, toPoint.Y); x = new ESRI.ArcGIS.Geometry.Point(); (isegment_0 as ICircularArc).QueryCenterPoint(x); x.X = 2 * ipoint_0.X - x.X; (lineClass as IConstructCircularArc).ConstructThreePoints(pointClass, x, point, false); segment = lineClass; } else if (isegment_0.GeometryType == esriGeometryType.esriGeometryEllipticArc) { lineClass = new EllipticArc() as ISegment; pointClass = new ESRI.ArcGIS.Geometry.Point(); pointClass.PutCoords(2 * ipoint_0.X - fromPoint.X, fromPoint.Y); point = new ESRI.ArcGIS.Geometry.Point(); point.PutCoords(2 * ipoint_0.X - toPoint.X, toPoint.Y); x = new ESRI.ArcGIS.Geometry.Point(); (isegment_0 as IEllipticArc).QueryCenterPoint(x); x.X = 2 * ipoint_0.X - x.X; isegment_0.Envelope.QueryCoords(out num, out num1, out x1, out num2); num = 2 * ipoint_0.X - num; x1 = 2 * ipoint_0.X - x1; IEnvelope envelopeClass = new Envelope() as IEnvelope; envelopeClass.PutCoords(num, num1, x1, num2); (lineClass as IConstructEllipticArc).ConstructTwoPointsEnvelope(pointClass, point, envelopeClass, ((isegment_0 as IEllipticArc).IsCounterClockwise ? esriArcOrientation.esriArcCounterClockwise : esriArcOrientation.esriArcClockwise)); segment = lineClass; } else if (isegment_0.GeometryType != esriGeometryType.esriGeometryBezier3Curve) { segment = null; } else { lineClass = new Line() as ISegment; pointClass = new ESRI.ArcGIS.Geometry.Point(); pointClass.PutCoords(2 * ipoint_0.X - fromPoint.X, fromPoint.Y); point = new ESRI.ArcGIS.Geometry.Point(); point.PutCoords(2 * ipoint_0.X - toPoint.X, toPoint.Y); lineClass.FromPoint = pointClass; lineClass.ToPoint = point; segment = lineClass; } return(segment); }
private ISegment method_3(ISegment isegment_0, IPoint ipoint_0) { ISegment lineClass; IPoint pointClass; IPoint point; ISegment segment; double num; double y; double num1; double y1; IPoint fromPoint = isegment_0.FromPoint; IPoint toPoint = isegment_0.ToPoint; if (isegment_0.GeometryType == esriGeometryType.esriGeometryLine) { lineClass = new Line() as ISegment; pointClass = new ESRI.ArcGIS.Geometry.Point(); pointClass.PutCoords(fromPoint.X, 2 * ipoint_0.Y - fromPoint.Y); point = new ESRI.ArcGIS.Geometry.Point(); point.PutCoords(toPoint.X, 2 * ipoint_0.Y - toPoint.Y); lineClass.FromPoint = pointClass; lineClass.ToPoint = point; segment = lineClass; } else if (isegment_0.GeometryType == esriGeometryType.esriGeometryCircularArc) { lineClass = new CircularArc() as ISegment; pointClass = new ESRI.ArcGIS.Geometry.Point(); pointClass.PutCoords(fromPoint.X, 2 * ipoint_0.Y - fromPoint.Y); point = new ESRI.ArcGIS.Geometry.Point(); point.PutCoords(toPoint.X, 2 * ipoint_0.Y - toPoint.Y); IPoint pointClass1 = new ESRI.ArcGIS.Geometry.Point(); (isegment_0 as ICircularArc).QueryCenterPoint(pointClass1); pointClass1.Y = 2 * ipoint_0.Y - pointClass1.Y; (lineClass as IConstructCircularArc).ConstructThreePoints(pointClass, pointClass1, point, false); segment = lineClass; } else if (isegment_0.GeometryType == esriGeometryType.esriGeometryEllipticArc) { lineClass = new EllipticArc() as ISegment; pointClass = new ESRI.ArcGIS.Geometry.Point(); pointClass.PutCoords(fromPoint.X, 2 * ipoint_0.Y - fromPoint.Y); point = new ESRI.ArcGIS.Geometry.Point(); point.PutCoords(toPoint.X, 2 * ipoint_0.Y - toPoint.Y); isegment_0.Envelope.QueryCoords(out num, out y, out num1, out y1); y = 2 * ipoint_0.Y - y; y1 = 2 * ipoint_0.Y - y1; IEnvelope envelopeClass = new Envelope() as IEnvelope; envelopeClass.PutCoords(num, y, num1, y1); (lineClass as IConstructEllipticArc).ConstructTwoPointsEnvelope(pointClass, point, envelopeClass, ((isegment_0 as IEllipticArc).IsCounterClockwise ? esriArcOrientation.esriArcCounterClockwise : esriArcOrientation.esriArcClockwise)); segment = lineClass; } else if (isegment_0.GeometryType != esriGeometryType.esriGeometryBezier3Curve) { segment = null; } else { lineClass = new Line() as ISegment; pointClass = new ESRI.ArcGIS.Geometry.Point(); pointClass.PutCoords(fromPoint.X, 2 * ipoint_0.Y - fromPoint.Y); point = new ESRI.ArcGIS.Geometry.Point(); point.PutCoords(toPoint.X, 2 * ipoint_0.Y - toPoint.Y); lineClass.FromPoint = pointClass; lineClass.ToPoint = point; segment = lineClass; } return(segment); }
private static Entity DrawPart(Segment[] segs, Point[] points, Point[] densifiedPoints, bool closePart, bool hasZ, double defaultElevation) { double num = 0.0; if (segs != null) { if (segs.Length == 1) { CircularArc circularArc = segs[0] as CircularArc; EllipticArc ellipticArc = segs[0] as EllipticArc; BezierCurve bezierCurve = segs[0] as BezierCurve; ArcGIS10Types.Line line = segs[0] as ArcGIS10Types.Line; if (circularArc != null) { if (((PointN)circularArc.FromPoint).X == ((PointN)circularArc.ToPoint).X && ((PointN)circularArc.FromPoint).Y == ((PointN)circularArc.ToPoint).Y) { return(GIS2CAD.DrawCircle(circularArc, defaultElevation)); } return(GIS2CAD.DrawCircularArc(circularArc, defaultElevation, densifiedPoints)); } else if (ellipticArc != null) { if (!ellipticArc.IsCounterClockwise) { return(AGSEllipticalArc.ToCadSpline(ellipticArc, defaultElevation)); } return(AGSEllipticalArc.ToCadEllipse(ellipticArc, defaultElevation)); } else { if (line != null) { return(GIS2CAD.DrawPolyline(densifiedPoints, false)); } if (bezierCurve != null) { return(GIS2CAD.DrawPolyline(densifiedPoints, closePart)); } } } else if (segs.Length > 1) { PointN pointN = segs[0].FromPoint as PointN; num = pointN.Z; if (num == 0.0) { num = defaultElevation; } if (GIS2CAD.CanBeDrawnAsPolyline(segs)) { var polyline = new Autodesk.AutoCAD.DatabaseServices.Polyline(); polyline.ColorIndex = (256); int num2 = 0; PointN pointN2 = (PointN)segs[0].ToPoint; for (int i = 0; i < segs.Length; i++) { Segment segment = segs[i]; CircularArc circularArc2 = segment as CircularArc; var line2 = segment as ArcGIS10Types.Line; if (line2 != null) { PointN pointN3 = (PointN)line2.FromPoint; polyline.AddVertexAt(num2++, new Point2d(pointN3.X, pointN3.Y), 0.0, -1.0, -1.0); pointN2 = (PointN)line2.ToPoint; } else if (circularArc2 != null) { PointN pointN4 = (PointN)circularArc2.CenterPoint; PointN pointN5 = (PointN)circularArc2.FromPoint; PointN pointN6 = (PointN)circularArc2.ToPoint; new Point2d(pointN5.X - pointN4.X, pointN5.Y - pointN4.Y); new Point2d(pointN6.X - pointN4.X, pointN6.Y - pointN4.Y); Point2d point2d = new Point2d(pointN5.X, pointN5.Y); Point2d centerPoint = new Point2d(pointN4.X, pointN4.Y); Point2d point2d2 = new Point2d(pointN6.X, pointN6.Y); double num3 = Math.Abs(centerPoint.GetDistanceTo(point2d)); double num4 = Math.Abs(point2d.GetDistanceTo(point2d2)); double num5 = num3; double num6 = num3; double d = (num5 * num5 + num6 * num6 - num4 * num4) / (2.0 * num5 * num6); double num7 = Math.Acos(d); num7 = GIS2CAD.CalcThetaFromVectors(point2d, point2d2, centerPoint, circularArc2.IsCounterClockwise); double num8 = Math.Tan(num7 / 4.0); if (!circularArc2.IsCounterClockwise) { num8 *= -1.0; } polyline.AddVertexAt(num2++, point2d, num8, -1.0, -1.0); pointN2 = pointN6; } } polyline.AddVertexAt(num2, new Point2d(pointN2.X, pointN2.Y), 0.0, -1.0, -1.0); if (closePart) { polyline.Closed = (true); } return(polyline); } return(GIS2CAD.Draw3dPline(densifiedPoints, closePart)); } } else if (points != null) { if (points.Length == 2) { var line3 = new Autodesk.AutoCAD.DatabaseServices.Line(); line3.ColorIndex = (256); GIS2CAD.AdjustZ(ref points, defaultElevation); Point3d startPoint = GIS2CAD.ToCadPoint3d((PointN)points[0]); Point3d endPoint = GIS2CAD.ToCadPoint3d((PointN)points[1]); line3.StartPoint = (startPoint); line3.EndPoint = (endPoint); return(line3); } if (points.Length > 0) { if (!GIS2CAD.IsPlanar(points)) { try { Document document = AfaDocData.ActiveDocData.Document; var database = document.Database; var transactionManager = document.TransactionManager; using (document.LockDocument()) { using (Transaction transaction = transactionManager.StartTransaction()) { BlockTable blockTable = (BlockTable)transaction.GetObject(database.BlockTableId, 0); BlockTableRecord blockTableRecord = (BlockTableRecord)transaction.GetObject(blockTable[(BlockTableRecord.ModelSpace)], (OpenMode)1); Polyline3d polyline3d = new Polyline3d(); polyline3d.ColorIndex = (256); blockTableRecord.AppendEntity(polyline3d); transaction.AddNewlyCreatedDBObject(polyline3d, true); Point[] array = points; for (int j = 0; j < array.Length; j++) { PointN srcPt = (PointN)array[j]; PolylineVertex3d polylineVertex3d = new PolylineVertex3d(GIS2CAD.ToCadPoint3d(srcPt)); polyline3d.AppendVertex(polylineVertex3d); transaction.AddNewlyCreatedDBObject(polylineVertex3d, true); } if (closePart) { polyline3d.Closed = (true); } document.TransactionManager.QueueForGraphicsFlush(); document.TransactionManager.FlushGraphics(); document.Editor.UpdateScreen(); transaction.Commit(); return(polyline3d); } } } catch (System.Exception ex) { string arg_526_0 = ex.Message; } } var polyline2 = new Autodesk.AutoCAD.DatabaseServices.Polyline(); polyline2.ColorIndex = (256); polyline2.Elevation = (num); num = ((PointN)points[0]).Z; if (num == 0.0) { num = defaultElevation; } int num9 = 0; Point[] array2 = points; for (int k = 0; k < array2.Length; k++) { PointN pointN7 = (PointN)array2[k]; polyline2.AddVertexAt(num9++, new Point2d(pointN7.X, pointN7.Y), 0.0, -1.0, -1.0); } if (closePart) { polyline2.Closed = (true); } return(polyline2); } } return(null); }
private void drawCircleGraphic(double Size) { IMxDocument pMxDoc = m_pDoc; IActiveView pActiveView; IScreenDisplay pScreenDisplay; IEnvelope pEnv; IPoint pCenterPoint; IDisplayTransformation pTransform; pActiveView = pMxDoc.FocusMap as IActiveView; pScreenDisplay = pActiveView.ScreenDisplay; pTransform = pScreenDisplay.DisplayTransformation; pEnv = pTransform.FittedBounds; pCenterPoint = new Point(); pCenterPoint.PutCoords((pEnv.XMax + pEnv.XMin) / 2, (pEnv.YMax + pEnv.YMin) / 2); IConstructCircularArc pCircle = new CircularArc() as IConstructCircularArc; ISegmentCollection pPolygon = new Polygon() as ISegmentCollection; Size *= 10000; Size = Math.Sqrt(Size / 3.1416); pCircle.ConstructCircle(pCenterPoint, Size, true); pPolygon.AddSegment(pCircle as ISegment); IPolygon pFinalPolygon; pFinalPolygon = pPolygon as IPolygon; pFinalPolygon.Close(); IRgbColor pLineColor = new RgbColor(); pLineColor.Red = 255; // A CHANGER!!! addGraphicToMap(pMxDoc.FocusMap, pFinalPolygon, pLineColor, pLineColor); }
/// <summary> /// initializes the Diagram data /// </summary> private void InitializeDiagram() { Syncfusion.Windows.Forms.Diagram.Rectangle rect = new Syncfusion.Windows.Forms.Diagram.Rectangle(100, 25, 120, 75); rect.FillStyle.Color = Color.FromArgb(240, 242, 240); rect.FillStyle.ForeColor = Color.White; rect.FillStyle.Type = FillStyleType.LinearGradient; rect.LineStyle.LineColor = Color.DarkGray; AddLabel(rect, "Rectangle", Position.Center); diagram1.Model.AppendChild(rect); Syncfusion.Windows.Forms.Diagram.RoundRect roundRect = new Syncfusion.Windows.Forms.Diagram.RoundRect(400, 25, 120, 75, MeasureUnits.Pixel); roundRect.FillStyle.Color = Color.FromArgb(240, 242, 240); roundRect.FillStyle.ForeColor = Color.White; roundRect.LineStyle.LineColor = Color.DarkGray; roundRect.FillStyle.Type = FillStyleType.LinearGradient; AddLabel(roundRect, "RoundRect1", Position.Center); diagram1.Model.AppendChild(roundRect); Ellipse ellipse1 = new Ellipse(100, 125, 120, 80); ellipse1.FillStyle.Color = Color.FromArgb(240, 242, 240); ellipse1.FillStyle.ForeColor = Color.White; ellipse1.LineStyle.LineColor = Color.DarkGray; ellipse1.FillStyle.Type = FillStyleType.LinearGradient; AddLabel(ellipse1, "Ellipse", Position.Center); diagram1.Model.AppendChild(ellipse1); Polygon poly = new Polygon(new PointF[] { new PointF(160, 235), new PointF(100, 265), new PointF(120, 325), new PointF(200, 325), new PointF(220, 265) }); poly.FillStyle.Color = Color.FromArgb(240, 242, 240); poly.FillStyle.ForeColor = Color.White; poly.FillStyle.Type = FillStyleType.LinearGradient; poly.LineStyle.LineColor = Color.DarkGray; AddLabel(poly, "Polygon", Position.Center); diagram1.Model.AppendChild(poly); SemiCircle semiCircle = new SemiCircle(400, 125, 120, 75); semiCircle.FillStyle.Color = Color.FromArgb(240, 242, 240); semiCircle.FillStyle.ForeColor = Color.White; semiCircle.FillStyle.Type = FillStyleType.LinearGradient; semiCircle.LineStyle.LineColor = Color.DarkGray; AddLabel(semiCircle, "SemiCircle", Position.Center); diagram1.Model.AppendChild(semiCircle); TextNode textNode = new TextNode("TextNode1", new RectangleF(400, 245, 120, 50)); textNode.FontStyle.Size = 9; textNode.FontStyle.Family = "Segoe UI"; textNode.HorizontalAlignment = StringAlignment.Center; textNode.VerticalAlignment = StringAlignment.Center; textNode.LineStyle.LineColor = Color.DarkGray; textNode.FontColorStyle.Color = Color.Black; diagram1.Model.AppendChild(textNode); RichTextNode richTextNode = new RichTextNode(@"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Meiryo UI;}{\f1\fnil\fcharset0 Microsoft Sans Serif;}} {\colortbl ;\red255\green0\blue0;\red0\green64\blue128;} \viewkind4\uc1\pard\b\f0\fs17 This is a text symbol\f1 \b0\f0 designed using the \cf1\b\i Essential Diagram\i0 \cf2\ul RichText\ulnone node\cf0\b0 .\par \i\f1\fs20\par }", new RectangleF(400, 320, 120, 100)); richTextNode.LineStyle.LineColor = Color.DarkGray; diagram1.Model.AppendChild(richTextNode); #if !NETCORE BitmapNode bmpNode = new BitmapNode(@"..\..\..\..\..\..\common\Images\Diagram\OrgChart Layout\image3.png"); #else BitmapNode bmpNode = new BitmapNode(@"..\..\..\..\..\..\..\common\Images\Diagram\OrgChart Layout\image3.png"); #endif bmpNode.Name = "BitmapNode1"; bmpNode.PinPoint = new PointF(700, 75); bmpNode.Size = new SizeF(120, 100); bmpNode.LineStyle.LineWidth = 0; diagram1.Model.AppendChild(bmpNode); ClosedCurveNode curve = new ClosedCurveNode(new PointF[] { new PointF(120, 350), new PointF(120, 450), new PointF(220, 400) }); curve.FillStyle.Color = Color.FromArgb(240, 242, 240); curve.FillStyle.ForeColor = Color.White; curve.FillStyle.Type = FillStyleType.LinearGradient; curve.LineStyle.LineColor = Color.DarkGray; AddLabel(curve, "ClosedCurve", Position.Center); diagram1.Model.AppendChild(curve); CurveNode curve1 = new CurveNode(new PointF[] { new PointF(120, 100), new PointF(120, 200), new PointF(220, 150) }); curve1 = new CurveNode(new PointF[] { new PointF(0, 30), new PointF(4.99999952f, 25), new PointF(18.3333321f, 0), new PointF(30, 0), new PointF(41.66666641f, 0), new PointF(58.33333321f, 30), new PointF(70, 30), new PointF(81.66666f, 30), new PointF(95, 4.99999952f), new PointF(100, 0) }); AddLabel(curve1, "CurveNode", Position.Center); diagram1.Model.AppendChild(curve1); CircularArc circular = new CircularArc(new RectangleF(640, 150, 100, 100), 0, 270); circular.FillStyle.Color = Color.FromArgb(240, 242, 240); circular.FillStyle.ForeColor = Color.White; circular.FillStyle.Type = FillStyleType.LinearGradient; circular.LineStyle.LineColor = Color.DarkGray; circular.PinPoint = new PointF(700, 200); AddLabel(circular, "CircularArc", Position.Center); diagram1.Model.AppendChild(circular); Line line1 = new Line(new PointF(700, 320), new PointF(700, 430)); line1.LineStyle.LineColor = Color.DarkGray; AddLabel(line1, "line", Position.TopCenter); diagram1.Model.AppendChild(line1); PolylineNode polyLine = new PolylineNode(new PointF[] { new PointF(640, 500), new PointF(760, 500), new PointF(640, 540), new PointF(760, 540) }); polyLine.LineStyle.LineColor = Color.DarkGray; polyLine.LineStyle.LineWidth = 1; Syncfusion.Windows.Forms.Diagram.Label label = new Syncfusion.Windows.Forms.Diagram.Label(polyLine, "PolyLine Node"); label.OffsetX = polyLine.BoundingRectangle.Width / 5f; label.OffsetY = polyLine.BoundingRectangle.Height + 10; label.FontStyle.Family = "Segoe UI"; label.FontColorStyle.Color = Color.Black; label.FontStyle.Size = 9; polyLine.Labels.Add(label); diagram1.Model.AppendChild(polyLine); BezierCurve bezier = new BezierCurve(new PointF[] { new PointF(100, 470), new PointF(160, 470), new PointF(160, 560), new PointF(220, 560) }); AddLabel(bezier, "BezierCurve", Position.BottomCenter); diagram1.Model.AppendChild(bezier); SplineNode spline = new SplineNode(new PointF[] { new PointF(400, 460), new PointF(520, 500), new PointF(400, 520) }); spline.LineStyle.LineColor = Color.Black; spline.LineStyle.LineWidth = 1; AddLabel(spline, "Spline", Position.BottomCenter); diagram1.Model.AppendChild(spline); }