private RectangleF GetNodeEditRectangle() { RectangleF rectangleF; float thWidth = UCCanvas.GetThresholdWidth(); if (this.currentNodeIndex == 0) { rectangleF = ScreenUtils.GetRectangleF(this.MultiLinePoints[0], this.MultiLinePoints[1], thWidth); } else if (this.currentNodeIndex == this.MultiLinePoints.Count - 1) { rectangleF = ScreenUtils.GetRectangleF(this.MultiLinePoints[this.MultiLinePoints.Count - 2], this.MultiLinePoints[this.MultiLinePoints.Count - 1], thWidth); } else { List <UnitPoint> temp = new List <UnitPoint>(); temp.Add(this.MultiLinePoints[this.currentNodeIndex - 1]); temp.Add(this.MultiLinePoints[this.currentNodeIndex]); temp.Add(this.MultiLinePoints[this.currentNodeIndex + 1]); float maxX = (float)temp.Max <UnitPoint>(maxx => maxx.X); float maxY = (float)temp.Max <UnitPoint>(maxy => maxy.Y); float minX = (float)temp.Min <UnitPoint>(minx => minx.X); float minY = (float)temp.Min <UnitPoint>(miny => miny.Y); rectangleF = ScreenUtils.GetRectangleF(new UnitPoint(minX, minY), new UnitPoint(maxX, maxY), thWidth); } return(rectangleF); }
public bool SetStartMovePoint(UnitPoint unitPoint) { float thresholdWidth = UCCanvas.GetThresholdWidth(); if (this.PointInObject(unitPoint)) { if (HitUtil.IsPointInLine(this.LeftTopPoint, this.RightTopPoint, unitPoint, thresholdWidth)) { unitPoint = this.HandleSideBoundError(unitPoint, LeftTopPoint, RightTopPoint, thresholdWidth); this.StartMovePoint = HitUtil.FindApparentIntersectPoint(this.CenterPoint, unitPoint, this.LeftTopPoint, this.RightTopPoint); this.StartMovePosition = NodePosition.LeftTop; } else if (HitUtil.IsPointInLine(this.RightTopPoint, this.RightBottomPoint, unitPoint, thresholdWidth)) { unitPoint = this.HandleSideBoundError(unitPoint, RightTopPoint, RightBottomPoint, thresholdWidth); this.StartMovePoint = HitUtil.FindApparentIntersectPoint(this.CenterPoint, unitPoint, this.RightTopPoint, this.RightBottomPoint); this.StartMovePosition = NodePosition.RightTop; } else if (HitUtil.IsPointInLine(this.RightBottomPoint, this.LeftBottomPoint, unitPoint, thresholdWidth)) { unitPoint = this.HandleSideBoundError(unitPoint, RightBottomPoint, LeftBottomPoint, thresholdWidth); this.StartMovePoint = HitUtil.FindApparentIntersectPoint(this.CenterPoint, unitPoint, this.RightBottomPoint, this.LeftBottomPoint); this.StartMovePosition = NodePosition.RightBottom; } else if (HitUtil.IsPointInLine(this.LeftBottomPoint, this.LeftTopPoint, unitPoint, thresholdWidth)) { unitPoint = this.HandleSideBoundError(unitPoint, LeftBottomPoint, LeftTopPoint, thresholdWidth); this.StartMovePoint = HitUtil.FindApparentIntersectPoint(this.CenterPoint, unitPoint, this.LeftBottomPoint, this.LeftTopPoint); this.StartMovePosition = NodePosition.LeftBottom; } this.OverCutting(); return(true); } return(false); }
public void OpenFileDialog(UCCanvas canvas) { try { if (!IsNeedToSave(canvas)) { return; } List <FigureBaseModel> figures = null; FigureFilePreview figurePreview = new FigureFilePreview(); OpenFileDialogEx open = new OpenFileDialogEx(); open.Filter = "所有文件(*.*)|*.WXF;*.DXF;|WSX默认切割文件(*.WXF)|*.WXF|AutoCAD图形文件(*.DXF)|*.DXF"; open.PreviewControl = figurePreview; open.OnFileSelectChanged += (s, e) => { if (figurePreview.IsPreView) { figures = ParseFigureFile(e.Path); figurePreview.FigurePreview(figures); } else { figurePreview.FigurePreview(new List <FigureBaseModel>()); } }; if (open.ShowDialog() == DialogResult.OK) { OpenFile(open.FileName, canvas, false, figures); } } catch (Exception ex) { XtraMessageBox.Show(ex.Message, "消息", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public RectangleF GetBoundingRectangle(BoundingRectangleType rectangleType) { float thresholdWidth = UCCanvas.GetThresholdWidth(); if (thresholdWidth < this.Width) { thresholdWidth = this.Width; } RectangleF rectangleF; switch (rectangleType) { case BoundingRectangleType.Drawing: rectangleF = this.GetDrawingRectangle(); break; case BoundingRectangleType.NodeEditing: rectangleF = this.GetNodeEditRectangle(); break; case BoundingRectangleType.SelectRange: rectangleF = this.GetSelectionRectangle(); break; default: rectangleF = new RectangleF(); break; } return(rectangleF); }
private bool IsNeedToSave(UCCanvas canvas) { var curfigures = FigureHelper.ToFigureBaseModel(canvas.Model.DrawingLayer.Objects); if (oldFigures != null && oldFigures.Count == 0) { oldFigures = null; } if (curfigures != null && curfigures.Count == 0) { curfigures = null; } string oldHashcode = JsonConvert.SerializeObject(oldFigures); string curHashcode = JsonConvert.SerializeObject(curfigures); if (oldHashcode.GetHashCode() != curHashcode.GetHashCode()) { var result = XtraMessageBox.Show(string.Format("是否保存对\"{0}\"的修改?", this.FileName), "消息", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) { this.SaveFile(canvas.Model.DrawingLayer.Objects); return(true); } else if (result == DialogResult.No) { return(true); } else { return(false); } } return(true); }
public ArrayFullHelper(UCCanvas uCCanvas, List <IDrawObject> allDrawObjects, List <IDrawObject> drawObjects, ArrayFullModel arrayFull) { this.uCCanvas = uCCanvas; this.allDrawObjects = allDrawObjects; this.drawObjects = drawObjects; this.arrayFullModel = arrayFull; }
public INodePoint NodePoint(UnitPoint unitPoint) { if (HitUtil.CircleHitPoint(this.P1, UCCanvas.GetThresholdWidth(this.radius), unitPoint)) { return(new NodePointSingleDot(this)); } return(null); }
private UnitPoint MidPoint(UnitPoint p1, UnitPoint p2, UnitPoint hitPoint) { UnitPoint midPoint = HitUtil.LineMidpoint(p1, p2); if (HitUtil.CircleHitPoint(midPoint, UCCanvas.GetThresholdWidth(), hitPoint)) { return(midPoint); } return(UnitPoint.Empty); }
public override RectangleF GetBoundingRectangle(BoundingRectangleType rectangleType) { if (this.IsCompleteDraw || this.IsEditMode) { return(base.GetBoundingRectangle(rectangleType)); } float thWidth = UCCanvas.GetThresholdWidth(); return(ScreenUtils.GetRectangleF(this.p1, this.p2, thWidth / 2)); }
private UnitPoint MidPoint(ICanvas canvas, UnitPoint P1, UnitPoint P2, UnitPoint hitPoint) { UnitPoint midPoint = HitUtil.LineMidpoint(P1, P2); float thresholdWidth = UCCanvas.GetThresholdWidth(); if (HitUtil.CircleHitPoint(midPoint, thresholdWidth, hitPoint)) { return(midPoint); } return(UnitPoint.Empty); }
public void New(UCCanvas canvas) { if (!IsNeedToSave(canvas)) { return; } canvas.Model.DrawingLayer.Objects.Clear(); GlobalModel.TotalDrawObjectCount = 0;//计数归零 canvas.DoInvalidate(true); this.oldFigures = null; this.UpdateFilePath(null); }
public override RectangleF GetBoundingRectangle(BoundingRectangleType rectangleType) { float thresholdWidth = UCCanvas.GetThresholdWidth(); if (this.arcCurrentPointType == ArcCurrentPointType.MidPoint) { return(ScreenUtils.GetRectangleF(this.startPoint, this.midPoint, thresholdWidth)); } else { return(this.GetBoundingRectCommon(thresholdWidth)); } }
public INodePoint NodePoint(UnitPoint unitPoint) { float thWidth = UCCanvas.GetThresholdWidth(); for (int i = 0; i < this.SideCount; i++) { if (HitUtil.PointInPoint(this.hexagonPoints[i], unitPoint, thWidth)) { return(new NodeHexagon(this, i)); } } return(null); }
public override RectangleF GetBoundingRectangle(BoundingRectangleType rectangleType) { float thresholdWidth = UCCanvas.GetThresholdWidth(); if (this.IsCompleteDraw || this.IsEditMode) { return(this.GetBoundingRectCommon(thresholdWidth)); } else { return(HitUtil.CircleBoundingRectangle(this.Center, this.Radius + thresholdWidth / 2)); } }
/// <summary> /// 计算放置的对象数量 /// </summary> /// <param name="rowCount"></param> /// <param name="colCount"></param> private void CalRowAndColCount(out int rowCount, out int colCount) { float thresholdWidth = UCCanvas.GetThresholdWidth(); GetAllDrawingsMaxMinPoint(out UnitPoint maxpoint, out UnitPoint minpoint); double width = maxpoint.X - minpoint.X - thresholdWidth; double height = maxpoint.Y - minpoint.Y - thresholdWidth; double totalwidth = Math.Abs(SecondPoint.X - FirstPoint.X - thresholdWidth); double totalheight = Math.Abs(SecondPoint.Y - FirstPoint.Y - thresholdWidth); colCount = Math.Abs((int)Math.Floor((totalwidth + OffsetColumn) / (width + OffsetColumn))); rowCount = Math.Abs((int)Math.Floor((totalheight + OffsetRow) / (height + OffsetRow))); }
public FigureFilePreview() { InitializeComponent(); this.ckPreView.Checked = this.IsPreView; this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true); this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); this.dataModel = new DataModel(); this.myCanvas = new UCCanvas(this, this.dataModel); this.myCanvas.Dock = DockStyle.Fill; this.panelDrawing.Controls.Add(this.myCanvas); this.myCanvas.SetCenter(new UnitPoint(0, 0)); this.dataModel.SelectEventEnabled = false; this.myCanvas.CanvasEnabled = false; }
public override RectangleF GetBoundingRectangle(BoundingRectangleType rectangleType) { if (this.IsCompleteDraw || this.IsEditMode) { return(base.GetBoundingRectangle(rectangleType)); } float thWidth = UCCanvas.GetThresholdWidth(); float maxX = (float)this.Points.Max <UnitPointBulge>(x => x.Point.X); float maxY = (float)this.Points.Max <UnitPointBulge>(x => x.Point.Y); float minX = (float)this.Points.Min <UnitPointBulge>(x => x.Point.X); float minY = (float)this.Points.Min <UnitPointBulge>(x => x.Point.Y); return(ScreenUtils.GetRectangleF(new UnitPoint(minX, minY), new UnitPoint(maxX, maxY), thWidth / 2)); }
public INodePoint NodePoint(UnitPoint unitPoint) { float thresholdWidth = UCCanvas.GetThresholdWidth(); if (HitUtil.CircleHitPoint(this.P1, thresholdWidth, unitPoint)) { return(new NodePointLine(this, NodePointLine.LinePoint.P1)); } if (HitUtil.CircleHitPoint(this.P2, thresholdWidth, unitPoint)) { return(new NodePointLine(this, NodePointLine.LinePoint.P2)); } return(null); }
private void CalRowAndColCount(List <IDrawObject> ldrawObjects, out int rowCount, out int colCount) { float thresholdWidth = UCCanvas.GetThresholdWidth(); GetAllDrawingsMaxMinPoint(ldrawObjects, out UnitPoint maxpoint, out UnitPoint minpoint); double width = maxpoint.X - minpoint.X - thresholdWidth; double height = maxpoint.Y - minpoint.Y - thresholdWidth; double totalwidth = arrayFullModel.PlateWidth - arrayFullModel.PlateRetainEdge; double totalheight = arrayFullModel.PlateHeight - arrayFullModel.PlateRetainEdge; double offset = arrayFullModel.PartsSpacing; colCount = Math.Abs((int)Math.Floor((totalwidth) / (width + offset))); rowCount = Math.Abs((int)Math.Floor((totalheight) / (height + offset))); }
public INodePoint NodePoint(UnitPoint unitPoint) { float thWidth = UCCanvas.GetThresholdWidth(); for (int i = 0; i < this.MultiLinePoints.Count; i++) { if (HitUtil.PointInPoint(this.MultiLinePoints[i], unitPoint, thWidth)) { INodePoint nodePoint = new NodeMultiLine(this, i); this.currentNodeIndex = i; return(nodePoint); } } return(null); }
public bool PointInObject(UnitPoint unitPoint) { RectangleF rectangleF = this.GetBoundingRectangle(BoundingRectangleType.All); if (rectangleF.Contains(unitPoint.Point) == false) { return(false); } float thresholdWidth = UCCanvas.GetThresholdWidth(); if (HitUtil.PointInPoint(this.P1, unitPoint, thresholdWidth)) { return(true); } return(HitUtil.IsPointInCircle(this.P1, this.radius, unitPoint, thresholdWidth / 2)); }
public bool PointInObject(UnitPoint unitPoint) { float thresholdWidth = UCCanvas.GetThresholdWidth(); for (int i = 0; i < this.SideCount - 1; i++) { if (HitUtil.IsPointInLine(this.hexagonPoints[i], this.hexagonPoints[i + 1], unitPoint, thresholdWidth)) { return(true); } } if (HitUtil.IsPointInLine(this.hexagonPoints[0], this.hexagonPoints[SideCount - 1], unitPoint, thresholdWidth)) { return(true); } return(false); }
public override RectangleF GetBoundingRectangle(BoundingRectangleType rectangleType) { if (this.IsEditMode || this.IsCompleteDraw) { return(base.GetBoundingRectangle(rectangleType)); } float thWidth = UCCanvas.GetThresholdWidth(); float maxX = (float)this.Points.Max <UnitPointBulge>(x => x.Point.X); float maxY = (float)this.Points.Max <UnitPointBulge>(x => x.Point.Y); float minX = (float)this.Points.Min <UnitPointBulge>(x => x.Point.X); float minY = (float)this.Points.Min <UnitPointBulge>(x => x.Point.Y); if (this.CurrentPoint == MultiSegementLineCurrentPoint.EndPoint) { maxX = maxX > this.p3.X ? maxX : (float)p3.X; maxY = maxY > this.p3.Y ? maxY : (float)p3.Y; minX = minX < this.p3.X ? minX : (float)p3.X; minY = minY < this.p3.Y ? minY : (float)p3.Y; } return(ScreenUtils.GetRectangleF(new UnitPoint(minX, minY), new UnitPoint(maxX, maxY), thWidth / 2)); }
public bool PointInObject2(ref UnitPoint unitPoint) { float thresholdWidth = UCCanvas.GetThresholdWidth(); for (int i = 0; i < this.SideCount - 1; i++) { if (HitUtil.IsPointInLine(this.hexagonPoints[i], this.hexagonPoints[i + 1], unitPoint, thresholdWidth)) { this.StartMovePointIndex = i; unitPoint = HandleSideBoundError(unitPoint, this.hexagonPoints[i], this.hexagonPoints[i + 1], thresholdWidth); return(true); } } if (HitUtil.IsPointInLine(this.hexagonPoints[0], this.hexagonPoints[SideCount - 1], unitPoint, thresholdWidth)) { this.StartMovePointIndex = this.SideCount - 1; unitPoint = HandleSideBoundError(unitPoint, this.hexagonPoints[0], this.hexagonPoints[SideCount - 1], thresholdWidth); return(true); } return(false); }
public void UpdateStartMovePoint(UnitPoint unitPoint) { float threshWidth = UCCanvas.GetThresholdWidth(); if (HitUtil.IsPointInLine(this.LeftTopPoint, this.RightTopPoint, unitPoint, threshWidth)) { this.StartMovePosition = NodePosition.LeftTop; } if (HitUtil.IsPointInLine(this.RightTopPoint, this.RightBottomPoint, unitPoint, threshWidth)) { this.StartMovePosition = NodePosition.RightTop; } if (HitUtil.IsPointInLine(this.RightBottomPoint, this.LeftBottomPoint, unitPoint, threshWidth)) { this.StartMovePosition = NodePosition.RightBottom; } if (HitUtil.IsPointInLine(this.LeftBottomPoint, this.LeftTopPoint, unitPoint, threshWidth)) { this.StartMovePosition = NodePosition.LeftBottom; } }
public bool ObjectInRectangle(RectangleF rectangle, bool anyPoint) { RectangleF rect = HitUtil.CircleBoundingRectangle(this.P1, UCCanvas.GetThresholdWidth(this.radius)); if (anyPoint) { UnitPoint lp1 = new UnitPoint(rectangle.Left, rectangle.Top); UnitPoint lp2 = new UnitPoint(rectangle.Left, rect.Bottom); if (HitUtil.CircleIntersectWithLine(this.P1, 3, lp1, lp2)) { return(true); } lp1 = new UnitPoint(rectangle.Left, rectangle.Bottom); lp2 = new UnitPoint(rectangle.Right, rectangle.Bottom); if (HitUtil.CircleIntersectWithLine(this.P1, 3, lp1, lp2)) { return(true); } lp1 = new UnitPoint(rectangle.Left, rectangle.Top); lp2 = new UnitPoint(rectangle.Right, rectangle.Top); if (HitUtil.CircleIntersectWithLine(this.P1, 3, lp1, lp2)) { return(true); } lp1 = new UnitPoint(rectangle.Left, rectangle.Top); lp2 = new UnitPoint(rectangle.Right, rectangle.Top); if (HitUtil.CircleIntersectWithLine(this.P1, 3, lp1, lp2)) { return(true); } lp1 = new UnitPoint(rectangle.Right, rectangle.Top); lp2 = new UnitPoint(rectangle.Right, rectangle.Bottom); if (HitUtil.CircleIntersectWithLine(this.P1, 3, lp1, lp2)) { return(true); } } return(rectangle.Contains(rect)); }
public ISnapPoint SnapPoint(ICanvas canvas, UnitPoint unitPoint, List <IDrawObject> drawObjects, Type[] runningSnapTypes, Type userSnapType) { float thWidth = UCCanvas.GetThresholdWidth(); if (runningSnapTypes != null) { foreach (Type snaptype in runningSnapTypes) { if (snaptype == typeof(VertextSnapPoint)) { if (HitUtil.CircleHitPoint(this.LeftTopPoint, thWidth, unitPoint)) { return(new VertextSnapPoint(canvas, this, this.LeftTopPoint)); } if (HitUtil.CircleHitPoint(this.RightTopPoint, thWidth, unitPoint)) { return(new VertextSnapPoint(canvas, this, this.RightTopPoint)); } if (HitUtil.CircleHitPoint(this.RightBottomPoint, thWidth, unitPoint)) { return(new VertextSnapPoint(canvas, this, this.RightBottomPoint)); } if (HitUtil.CircleHitPoint(this.LeftBottomPoint, thWidth, unitPoint)) { return(new VertextSnapPoint(canvas, this, this.LeftBottomPoint)); } } if (snaptype == typeof(MidpointSnapPoint)) { UnitPoint p = MidPoint(this.LeftTopPoint, this.RightTopPoint, unitPoint); if (p != UnitPoint.Empty) { return(new MidpointSnapPoint(canvas, this, p)); } } } return(null); } return(null); }
public INodePoint NodePoint(UnitPoint unitPoint) { float thresholdWidth = UCCanvas.GetThresholdWidth(); if (HitUtil.PointInPoint(this.LeftTopPoint, unitPoint, thresholdWidth)) { return(new NodePointRectangle(this, NodePosition.LeftTop)); } if (HitUtil.PointInPoint(this.RightTopPoint, unitPoint, thresholdWidth)) { return(new NodePointRectangle(this, NodePosition.RightTop)); } if (HitUtil.PointInPoint(this.RightBottomPoint, unitPoint, thresholdWidth)) { return(new NodePointRectangle(this, NodePosition.RightBottom)); } if (HitUtil.PointInPoint(this.LeftBottomPoint, unitPoint, thresholdWidth)) { return(new NodePointRectangle(this, NodePosition.LeftBottom)); } return(null); }
public bool PointInObject(UnitPoint unitPoint) { float thresholdWidth = UCCanvas.GetThresholdWidth(); if (HitUtil.IsPointInLine(this.LeftTopPoint, this.RightTopPoint, unitPoint, thresholdWidth)) { return(true); } if (HitUtil.IsPointInLine(this.RightTopPoint, this.RightBottomPoint, unitPoint, thresholdWidth)) { return(true); } if (HitUtil.IsPointInLine(this.RightBottomPoint, this.LeftBottomPoint, unitPoint, thresholdWidth)) { return(true); } if (HitUtil.IsPointInLine(this.LeftBottomPoint, this.LeftTopPoint, unitPoint, thresholdWidth)) { return(true); } return(false); }
public RectangleF GetMaxUnit() { float thWidth = UCCanvas.GetThresholdWidth(); var tran = drawObjects[0] as IDrawTranslation; UnitPoint maxPoint = new UnitPoint(); maxPoint = tran.MaxValue; UnitPoint minPoint = new UnitPoint(); minPoint = tran.MinValue; for (int i = 1; i < drawObjects.Count; i++) { UnitPoint tempMax = ((IDrawTranslation)drawObjects[i]).MaxValue; UnitPoint tempMin = ((IDrawTranslation)drawObjects[i]).MinValue; if (tempMax.X > maxPoint.X) { maxPoint.X = tempMax.X; } if (tempMax.Y > maxPoint.Y) { maxPoint.Y = tempMax.Y; } if (tempMin.X < minPoint.X) { minPoint.X = tempMin.X; } if (tempMin.Y < minPoint.Y) { minPoint.Y = tempMin.Y; } } RectangleF rectangleLine = ScreenUtils.GetRectangleF(maxPoint, minPoint, thWidth / 2); return(rectangleLine); }