/// <summary> /// 判断两个Mark是否重叠; /// </summary> /// <param name="mrMark1"></param> /// <param name="mrMark2"></param> /// <returns></returns> private bool IsTwoMarkOverlapp(CMrMark mrMark1, CMrMark mrMark2) { RectangleBoundingBox boundingBox1 = mrMark1.mTextBoundingBox; RectangleBoundingBox boundingBox2 = mrMark2.mTextBoundingBox; Point centerPoint1 = boundingBox1.GetCenterPoint(); Point centerPoint2 = boundingBox2.GetCenterPoint(); double x = Math.Abs(centerPoint1.X - centerPoint2.X); double y = Math.Abs(centerPoint1.Y - centerPoint2.Y); if (x < CCommonPara.mDblError && y < CCommonPara.mDblError) { return(false); } if (y > (boundingBox1.Height + boundingBox2.Height) / 2.0) { return(false); } if (x > (boundingBox1.Width + boundingBox2.Width) / 2.0) { return(false); } return(true); }
public static dynamic GetTSObject(RectangleBoundingBox dynObject) { if (dynObject is null) { return(null); } return(dynObject.teklaObject); }
/// <summary> /// 调整重叠的Mark; /// </summary> /// <param name="mrMark1">需要调整的Mark</param> /// <param name="mrMark2">已经存在的Mark</param> private void AdjustOverlappMark(CMrMark mrMark1, CMrMark mrMark2) { RectangleBoundingBox boundingBox1 = mrMark1.mTextBoundingBox; RectangleBoundingBox boundingBox2 = mrMark2.mTextBoundingBox; Point centerPoint1 = boundingBox1.GetCenterPoint(); Point centerPoint2 = boundingBox2.GetCenterPoint(); double x = centerPoint1.X - centerPoint2.X; double y = centerPoint1.Y - centerPoint2.Y; if (Math.Abs(x) < (boundingBox1.Width + boundingBox2.Width) / 2.0) { double overlappWidth = (boundingBox1.Width + boundingBox2.Width) / 2.0 - Math.Abs(x) + 10; if (x < CCommonPara.mDblError) { mrMark1.mTextPoint.X = mrMark1.mTextPoint.X - overlappWidth; mrMark1.mTextBoundingBox.LowerLeft.X = mrMark1.mTextBoundingBox.LowerLeft.X - overlappWidth; mrMark1.mTextBoundingBox.LowerRight.X = mrMark1.mTextBoundingBox.LowerRight.X - overlappWidth; mrMark1.mTextBoundingBox.UpperLeft.X = mrMark1.mTextBoundingBox.UpperLeft.X - overlappWidth; mrMark1.mTextBoundingBox.UpperRight.X = mrMark1.mTextBoundingBox.UpperRight.X - overlappWidth; } else if (x > CCommonPara.mDblError) { mrMark1.mTextPoint.X = mrMark1.mTextPoint.X + overlappWidth; mrMark1.mTextBoundingBox.LowerLeft.X = mrMark1.mTextBoundingBox.LowerLeft.X + overlappWidth; mrMark1.mTextBoundingBox.LowerRight.X = mrMark1.mTextBoundingBox.LowerRight.X + overlappWidth; mrMark1.mTextBoundingBox.UpperLeft.X = mrMark1.mTextBoundingBox.UpperLeft.X + overlappWidth; mrMark1.mTextBoundingBox.UpperRight.X = mrMark1.mTextBoundingBox.UpperRight.X + overlappWidth; } } if (Math.Abs(y) < (boundingBox1.Height + boundingBox2.Height) / 2.0) { double overlappHeight = (boundingBox1.Height + boundingBox2.Height) / 2.0 - Math.Abs(y) + 10; if (y < CCommonPara.mDblError) { mrMark1.mTextPoint.Y = mrMark1.mTextPoint.Y - overlappHeight; mrMark1.mTextBoundingBox.LowerLeft.Y = mrMark1.mTextBoundingBox.LowerLeft.Y - overlappHeight; mrMark1.mTextBoundingBox.LowerRight.Y = mrMark1.mTextBoundingBox.LowerRight.Y - overlappHeight; mrMark1.mTextBoundingBox.UpperLeft.Y = mrMark1.mTextBoundingBox.UpperLeft.Y - overlappHeight; mrMark1.mTextBoundingBox.UpperRight.Y = mrMark1.mTextBoundingBox.UpperRight.Y - overlappHeight; } else if (y > CCommonPara.mDblError) { mrMark1.mTextPoint.Y = mrMark1.mTextPoint.Y + overlappHeight; mrMark1.mTextBoundingBox.LowerLeft.Y = mrMark1.mTextBoundingBox.LowerLeft.Y + overlappHeight; mrMark1.mTextBoundingBox.LowerRight.Y = mrMark1.mTextBoundingBox.LowerRight.Y + overlappHeight; mrMark1.mTextBoundingBox.UpperLeft.Y = mrMark1.mTextBoundingBox.UpperLeft.Y + overlappHeight; mrMark1.mTextBoundingBox.UpperRight.Y = mrMark1.mTextBoundingBox.UpperRight.Y + overlappHeight; } } }
static void DrawBB(ViewBase DrawView, RectangleBoundingBox boundingBox, DrawingColors Color) { PointList points = new PointList(); points.Add(boundingBox.LowerLeft); points.Add(boundingBox.UpperLeft); points.Add(boundingBox.UpperRight); points.Add(boundingBox.LowerRight); Polygon MyPolygon = new Polygon(DrawView, points); MyPolygon.Attributes.Line.Color = Color; MyPolygon.Insert(); }
private void adjustBBToInsertionPoint(ref RectangleBoundingBox boundingBox, TSG.Point insertionPoint) { if (insertionPoint.X > boundingBox.GetCenterPoint().X) { boundingBox.LowerRight.X += 75; boundingBox.UpperRight.X += 75; } else if (insertionPoint.X < boundingBox.GetCenterPoint().X) { boundingBox.LowerLeft.X -= 75; boundingBox.UpperLeft.X -= 75; } }
/// <summary> /// Edit opened drawing, take string from dialog and write it under every view in the drawing. /// Draws also rectangle around the text string. /// </summary> private void EditOpenedDrawing() { if (MyDrawingHandler.GetConnectionStatus()) { Drawing MyDrawing = MyDrawingHandler.GetActiveDrawing(); ContainerView Sheet = MyDrawing.GetSheet(); DrawingObjectEnumerator MyViewEnumerator = Sheet.GetViews(); //Looping through views in the drawing while (MyViewEnumerator.MoveNext()) { View CurrentView = MyViewEnumerator.Current as View; //If ViewBase used instead of View, then multidrawing's container views would work here also if (CurrentView != null) { //Getting bounding box for the view frame and calculating then the CenterPoint under it RectangleBoundingBox ViewAABB = CurrentView.GetAxisAlignedBoundingBox(); Point CenterPoint = new Point(); CenterPoint.X = ViewAABB.LowerLeft.X + (ViewAABB.LowerRight.X - ViewAABB.LowerLeft.X) / 2.0; CenterPoint.Y = ViewAABB.LowerLeft.Y - 5.0; //5.0 mm below the view's bounding box Text MyViewTitle = new Text(Sheet, CenterPoint, ViewTitle.Text, new Text.TextAttributes()); if (!MyViewTitle.Insert()) { Console.WriteLine("Insert failed."); } else { RectangleBoundingBox TitleAABB = MyViewTitle.GetAxisAlignedBoundingBox(); Rectangle myBox = new Rectangle(Sheet, TitleAABB.LowerLeft, TitleAABB.UpperRight); myBox.Insert(); } } } MyDrawing.CommitChanges(); } }