public virtual INodePoint NodePoint(ICanvas canvas, UnitPoint point) { float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel); if (HitUtil.PointInPoint(m_center, point, thWidth)) { return(new NodePointArcCenter(this)); } if (HitUtil.PointInPoint(StartAnglePoint, point, thWidth)) { m_curPoint = eCurrentPoint.startAngle; m_lastPoint = m_center; return(new NodePointArcAngle(this)); } if (HitUtil.PointInPoint(EndAnglePoint, point, thWidth)) { m_curPoint = eCurrentPoint.endAngle; m_lastPoint = m_center; return(new NodePointArcAngle(this)); } if (HitUtil.PointInPoint(RadiusPoint, point, thWidth)) { m_curPoint = eCurrentPoint.radius; m_lastPoint = m_center; return(new NodePointArcRadius(this)); } return(null); }
public override INodePoint NodePoint(ICanvas canvas, UnitPoint point) { float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel); if (HitUtil.PointInPoint(Center, point, thWidth)) { return(new NodePointArcCenter(this)); } bool radiushit = HitUtil.PointInPoint(AnglePoint(0), point, thWidth); if (radiushit == false) { radiushit = HitUtil.PointInPoint(AnglePoint(90), point, thWidth); } if (radiushit == false) { radiushit = HitUtil.PointInPoint(AnglePoint(180), point, thWidth); } if (radiushit == false) { radiushit = HitUtil.PointInPoint(AnglePoint(270), point, thWidth); } if (radiushit) { m_curPoint = eCurrentPoint.radius; m_lastPoint = Center; return(new NodePointArcRadius(this)); } return(null); }
public bool PointInObject(ICanvas canvas, UnitPoint point) { float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel); return(m_crv.PointOnCurve(new float[2] { (float)point.X, (float)point.Y }, thWidth)); }
public RectangleF GetBoundingRect(ICanvas canvas) { float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel); RectangleF rect = m_crv.GetBoundingBox(); rect.Inflate(thWidth, thWidth); return(rect); }
public ISnapPoint SnapPoint(ICanvas canvas, UnitPoint point, List <IDrawObject> otherobj, Type[] runningsnaptypes, Type usersnaptype) { float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel); if (runningsnaptypes != null) { foreach (Type snaptype in runningsnaptypes) { UnitPoint ptemp = UnitPoint.Empty; if (snaptype == typeof(VertextSnapPoint)) { ptemp = GetPointFromVertexId(eVertexId.LeftTopCorner); if (HitUtil.CircleHitPoint(ptemp, thWidth, point)) { return(new VertextSnapPoint(canvas, this, ptemp, (int)eVertexId.LeftTopCorner));//left top corner } ptemp = GetPointFromVertexId(eVertexId.RightBottomCorner); if (HitUtil.CircleHitPoint(ptemp, thWidth, point)) { return(new VertextSnapPoint(canvas, this, ptemp, (int)eVertexId.RightBottomCorner));//right bottom corner } } if (snaptype == typeof(MidpointSnapPoint)) { ptemp = GetPointFromVertexId(eVertexId.BottomEdgeMidPoint); if (HitUtil.CircleHitPoint(ptemp, thWidth, point)) { return(new MidpointSnapPoint(canvas, this, ptemp, (int)eVertexId.BottomEdgeMidPoint));//bottom edge center } ptemp = GetPointFromVertexId(eVertexId.TopEdgeMidPoint); if (HitUtil.CircleHitPoint(ptemp, thWidth, point)) { return(new MidpointSnapPoint(canvas, this, ptemp, (int)eVertexId.TopEdgeMidPoint));//top edge center } ptemp = GetPointFromVertexId(eVertexId.LeftEdgeMidPoint); if (HitUtil.CircleHitPoint(ptemp, thWidth, point)) { return(new MidpointSnapPoint(canvas, this, ptemp, (int)eVertexId.LeftEdgeMidPoint));//left edge center } ptemp = GetPointFromVertexId(eVertexId.RigthEdgeMidPoint); if (HitUtil.CircleHitPoint(ptemp, thWidth, point)) { return(new MidpointSnapPoint(canvas, this, ptemp, (int)eVertexId.RigthEdgeMidPoint));//right edge center } } if (snaptype == typeof(CenterSnapPoint)) { if (HitUtil.PointInPoint(m_center, point, thWidth)) { return(new CenterSnapPoint(canvas, this, m_center)); } } } } return(null); }
UnitPoint MidPoint(ICanvas canvas, UnitPoint p1, UnitPoint p2, UnitPoint hitpoint) { UnitPoint mid = HitUtil.LineMidpoint(p1, p2); float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel); if (HitUtil.CircleHitPoint(mid, thWidth, hitpoint)) { return(mid); } return(UnitPoint.Empty); }
public RectangleF GetBoundingRect(ICanvas canvas) { if (m_pathFinder == null) { return(RectangleF.Empty); } float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel); RectangleF rect = m_pathFinder.BoundingBox; rect.Inflate(thWidth, thWidth); return(rect); }
public ISnapPoint SnapPoint(ICanvas canvas, UnitPoint testPt, List <IDrawObject> otherobj, Type[] runningsnaptypes, Type usersnaptype) { float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel); if (runningsnaptypes != null) { foreach (Type snaptype in runningsnaptypes) { if (snaptype == typeof(VertextSnapPoint)) { if (HitUtil.CircleHitPoint(m_p1, thWidth, testPt)) { return(new VertextSnapPoint(canvas, this, m_p1)); } if (HitUtil.CircleHitPoint(m_p2, thWidth, testPt)) { return(new VertextSnapPoint(canvas, this, m_p2)); } } if (snaptype == typeof(MidpointSnapPoint)) { if (HitUtil.CircleHitPoint(m_center, thWidth, testPt)) { return(new MidpointSnapPoint(canvas, this, m_center)); } } } return(null); } if (usersnaptype == typeof(MidpointSnapPoint)) { float[] midPt = { 0.0f, 0.0f }; m_crv.Eval(0.5f, ref midPt[0], ref midPt[1]); return(new MidpointSnapPoint(canvas, this, new UnitPoint(midPt[0], midPt[1]))); } if (usersnaptype == typeof(VertextSnapPoint)) { double d1 = HitUtil.Distance(testPt, m_p1); double d2 = HitUtil.Distance(testPt, m_p2); if (d1 <= d2) { return(new VertextSnapPoint(canvas, this, m_p1)); } return(new VertextSnapPoint(canvas, this, m_p2)); } if (usersnaptype == typeof(CenterSnapPoint)) { return(new CenterSnapPoint(canvas, this, m_center)); } return(null); }
/// <summary> /// 判断指定点是否在绘图对象中 /// </summary> /// <param name="canvas"></param> /// <param name="point"></param> /// <returns></returns> public virtual bool PointInObject(ICanvas canvas, UnitPoint point) { RectangleF boundingrect = GetBoundingRect(canvas); if (boundingrect.Contains(point.Point) == false) { return(false); } float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel); if (HitUtil.PointInPoint(m_center, point, thWidth)) { return(true); } return(HitUtil.IsPointInCircle(m_center, m_radius, point, thWidth / 2)); }
public bool PointInObject(ICanvas canvas, UnitPoint point) { if (m_allPts == null || m_allPts.Count < 1) { return(false); } float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel); for (int ii = 0; ii < m_allPts.Count - 1; ++ii) { if (HitUtil.IsPointInLine(m_allPts[ii], m_allPts[ii + 1], point, thWidth)) { return(true); } } return(false); }
public INodePoint NodePoint(ICanvas canvas, UnitPoint point) { float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel); if (HitUtil.CircleHitPoint(m_p1, thWidth, point)) { return(new NodePointRectBase(this, NodePointRectBase.ePoint.P1)); } if (HitUtil.CircleHitPoint(m_p3, thWidth, point)) { return(new NodePointRectBase(this, NodePointRectBase.ePoint.P3)); } if (HitUtil.CircleHitPoint(m_center, thWidth, point)) { return(new NodePointRectBase(this, NodePointRectBase.ePoint.Center)); } return(null); }
public INodePoint NodePoint(ICanvas canvas, UnitPoint point) { float thWidth = 0.0f; if (canvas != null) { thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel); } if (HitUtil.CircleHitPoint(m_p1, thWidth, point)) { return(new NodePointMultiConnectionLine(this, NodePointMultiConnectionLine.ePoint.P1)); } if (HitUtil.CircleHitPoint(m_p2, thWidth, point)) { return(new NodePointMultiConnectionLine(this, NodePointMultiConnectionLine.ePoint.P2)); } return(null); }
public RectangleF GetBoundingRect(ICanvas canvas) { float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel); if (thWidth < Width) { thWidth = Width; } float r = m_radius + thWidth / 2; RectangleF rect = HitUtil.CircleBoundingRect(m_center, r); // if drawing either angle then include the mouse point in the ractangle - this is to redraw (erase) the line drawn // from center point to mouse point if (m_curPoint == eCurrentPoint.startAngle || m_curPoint == eCurrentPoint.endAngle) { rect = RectangleF.Union(rect, new RectangleF(m_lastPoint.Point, new SizeF(0, 0))); } return(rect); }
public virtual INodePoint NodePoint(ICanvas canvas, UnitPoint point) { float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel); if (HitUtil.PointInPoint(P1, point, thWidth)) { m_lastPoint = P1; return(new NodePointArc3PointPoint(this, eCurrentPoint.p1)); } if (HitUtil.PointInPoint(P2, point, thWidth)) { m_lastPoint = P2; return(new NodePointArc3PointPoint(this, eCurrentPoint.p2)); } if (HitUtil.PointInPoint(P3, point, thWidth)) { m_lastPoint = P3; return(new NodePointArc3PointPoint(this, eCurrentPoint.p3)); } UnitPoint p = StartAngleNodePoint(canvas); if (HitUtil.PointInPoint(p, point, thWidth)) { m_lastPoint = p; return(new NodePointArc3PointPoint(this, eCurrentPoint.startangle)); } p = EndAngleNodePoint(canvas); if (HitUtil.PointInPoint(p, point, thWidth)) { m_lastPoint = p; return(new NodePointArc3PointPoint(this, eCurrentPoint.endangle)); } p = RadiusNodePoint(canvas); if (HitUtil.PointInPoint(p, point, thWidth)) { m_lastPoint = p; return(new NodePointArc3PointPoint(this, eCurrentPoint.radius)); } return(null); }
/// <summary> /// 获取用户图像选择周围的边界矩形的坐标 /// </summary> /// <param name="canvas"></param> /// <returns></returns> public RectangleF GetBoundingRect(ICanvas canvas) { float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel); if (thWidth < Width) { thWidth = Width; } RectangleF rect = RectangleF.Empty; //如果其中一个点是空的,那么绘制一条直线,因此返回一条直线的边界。 if (m_p2.IsEmpty || m_p3.IsEmpty) { rect = ScreenUtils.GetRect(m_p1, m_lastPoint, thWidth); } if (rect.IsEmpty) { float r = m_radius + thWidth / 2; rect = HitUtil.CircleBoundingRect(m_center, r); if (Selected) { float w = (float)canvas.ToUnit(20); // include space for the 'extern' nodes rect.Inflate(w, w); } } //如果绘制任一角度,则在矩形中包含鼠标点-这是重新绘制(擦除)绘制的线。 //从中心点到鼠标点 //if (m_curPoint == eCurrentPoint.startAngle || m_curPoint == eCurrentPoint.endAngle) if (m_lastPoint.IsEmpty == false) { rect = RectangleF.Union(rect, new RectangleF(m_lastPoint.Point, new SizeF(0, 0))); } return(rect); }
public RectangleF GetBoundingRect(ICanvas canvas) { float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel); if (thWidth < Width) { thWidth = Width; } RectangleF rect = RectangleF.Empty; // if one of the points is empty, then a straight line is drawn, so return bounding rect for a line if (m_p2.IsEmpty || m_p3.IsEmpty) { rect = ScreenUtils.GetRect(m_p1, m_lastPoint, thWidth); } if (rect.IsEmpty) { float r = m_radius + thWidth / 2; rect = HitUtil.CircleBoundingRect(m_center, r); if (Selected) { float w = (float)canvas.ToUnit(20); // include space for the 'extern' nodes rect.Inflate(w, w); } } // if drawing either angle then include the mouse point in the rectangle - this is to redraw (erase) the line drawn // from center point to mouse point //if (m_curPoint == eCurrentPoint.startAngle || m_curPoint == eCurrentPoint.endAngle) if (m_lastPoint.IsEmpty == false) { rect = RectangleF.Union(rect, new RectangleF(m_lastPoint.Point, new SizeF(0, 0))); } return(rect); }
public RectangleF GetBoundingRect(ICanvas canvas) { float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel); return(ScreenUtils.GetRect(m_p1, m_p3, thWidth)); }
public virtual INodePoint NodePoint(ICanvas canvas, UnitPoint point) { //Console.WriteLine(m_p1.X+" "+m_p1.Y); float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel); if (HitUtil.PointInPoint(Center, point, thWidth))//圓心位移 { return(new NodePointCircleCenter(this)); } bool radiushit = HitUtil.PointInPoint(m_p1, point, thWidth); if (radiushit == false) { radiushit = HitUtil.PointInPoint(m_p2, point, thWidth); } if (radiushit == false) { radiushit = HitUtil.PointInPoint(m_p3, point, thWidth); } if (radiushit) { m_curPoint = eCurrentPoint.radius; m_lastPoint = Center; return(new NodePointCircleRadius(this)); } return(null); //float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel); //if (HitUtil.PointInPoint(P1, point, thWidth)) //{ // m_lastPoint = P1; // return new NodePointArc3PointPoint(this, eCurrentPoint.p1); //} //if (HitUtil.PointInPoint(P2, point, thWidth)) //{ // m_lastPoint = P2; // return new NodePointArc3PointPoint(this, eCurrentPoint.p2); //} //if (HitUtil.PointInPoint(P3, point, thWidth)) //{ // m_lastPoint = P3; // return new NodePointArc3PointPoint(this, eCurrentPoint.p3); //} //UnitPoint p = StartAngleNodePoint(canvas); //if (HitUtil.PointInPoint(p, point, thWidth)) //{ // m_lastPoint = p; // return new NodePointArc3PointPoint(this, eCurrentPoint.startangle); //} //p = EndAngleNodePoint(canvas); //if (HitUtil.PointInPoint(p, point, thWidth)) //{ // m_lastPoint = p; // return new NodePointArc3PointPoint(this, eCurrentPoint.endangle); //} //p = RadiusNodePoint(canvas); //if (HitUtil.PointInPoint(p, point, thWidth)) //{ // m_lastPoint = p; // return new NodePointArc3PointPoint(this, eCurrentPoint.radius); //} return(null); }
public virtual ISnapPoint SnapPoint(ICanvas canvas, UnitPoint point, List <IDrawObject> otherobj, Type[] runningsnaptypes, Type usersnaptype) { float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel); if (runningsnaptypes != null) { foreach (Type snaptype in runningsnaptypes) { if (snaptype == typeof(QuadrantSnapPoint)) { UnitPoint p = HitUtil.NearestPointOnCircle(m_center, m_radius, point, 90); if (p != UnitPoint.Empty && HitUtil.PointInPoint(p, point, thWidth)) { return(new QuadrantSnapPoint(canvas, this, p)); } } //if (snaptype == typeof(DivisionSnapPoint)) //{ // double angle = 360 / 8; // UnitPoint p = HitUtil.NearestPointOnCircle(m_center, m_radius, point, angle); // if (p != UnitPoint.Empty && HitUtil.PointInPoint(p, point, thWidth)) // return new DivisionSnapPoint(canvas, this, p); //} if (snaptype == typeof(CenterSnapPoint)) { if (HitUtil.PointInPoint(m_center, point, thWidth)) { return(new CenterSnapPoint(canvas, this, m_center)); } } if (snaptype == typeof(VertextSnapPoint)) { if (HitUtil.PointInPoint(P1, point, thWidth)) { return(new VertextSnapPoint(canvas, this, P1)); } if (HitUtil.PointInPoint(P3, point, thWidth)) { return(new VertextSnapPoint(canvas, this, P3)); } } } return(null); } if (usersnaptype == typeof(NearestSnapPoint)) { UnitPoint p = HitUtil.NearestPointOnCircle(m_center, m_radius, point, 0); if (p != UnitPoint.Empty) { return(new NearestSnapPoint(canvas, this, p)); } } if (usersnaptype == typeof(PerpendicularSnapPoint)) { UnitPoint p = HitUtil.NearestPointOnCircle(m_center, m_radius, point, 0); if (p != UnitPoint.Empty) { return(new PerpendicularSnapPoint(canvas, this, p)); } } if (usersnaptype == typeof(QuadrantSnapPoint)) { UnitPoint p = HitUtil.NearestPointOnCircle(m_center, m_radius, point, 90); if (p != UnitPoint.Empty) { return(new QuadrantSnapPoint(canvas, this, p)); } } if (usersnaptype == typeof(TangentSnapPoint)) { IDrawObject drawingObject = canvas.CurrentObject; UnitPoint p = UnitPoint.Empty; if (drawingObject is LineEdit) { UnitPoint mousepoint = point; point = ((LineEdit)drawingObject).P1; UnitPoint p1 = HitUtil.TangentPointOnCircle(m_center, m_radius, point, false); UnitPoint p2 = HitUtil.TangentPointOnCircle(m_center, m_radius, point, true); double d1 = HitUtil.Distance(mousepoint, p1); double d2 = HitUtil.Distance(mousepoint, p2); if (d1 <= d2) { return(new TangentSnapPoint(canvas, this, p1)); } else { return(new TangentSnapPoint(canvas, this, p2)); } } //if (p != PointF.Empty) return(new TangentSnapPoint(canvas, this, p)); } if (usersnaptype == typeof(CenterSnapPoint)) { return(new CenterSnapPoint(canvas, this, m_center)); } return(null); }
public virtual INodePoint NodePoint(ICanvas canvas, UnitPoint point) { float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel); if (HitUtil.PointInPoint(Center, point, thWidth)) { return(new NodePointArcCenter(this)); } bool radiushit = HitUtil.PointInPoint(AnglePoint(0), point, thWidth); if (radiushit == false) { radiushit = HitUtil.PointInPoint(AnglePoint(90), point, thWidth); } if (radiushit == false) { radiushit = HitUtil.PointInPoint(AnglePoint(180), point, thWidth); } if (radiushit == false) { radiushit = HitUtil.PointInPoint(AnglePoint(270), point, thWidth); } if (radiushit) { m_curPoint = eCurrentPoint.radius; m_lastPoint = Center; return(new NodePointArcRadius(this)); } return(null); //float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel); //if (HitUtil.PointInPoint(P1, point, thWidth)) //{ // m_lastPoint = P1; // return new NodePointArc3PointPoint(this, eCurrentPoint.p1); //} //if (HitUtil.PointInPoint(P2, point, thWidth)) //{ // m_lastPoint = P2; // return new NodePointArc3PointPoint(this, eCurrentPoint.p2); //} //if (HitUtil.PointInPoint(P3, point, thWidth)) //{ // m_lastPoint = P3; // return new NodePointArc3PointPoint(this, eCurrentPoint.p3); //} //UnitPoint p = StartAngleNodePoint(canvas); //if (HitUtil.PointInPoint(p, point, thWidth)) //{ // m_lastPoint = p; // return new NodePointArc3PointPoint(this, eCurrentPoint.startangle); //} //p = EndAngleNodePoint(canvas); //if (HitUtil.PointInPoint(p, point, thWidth)) //{ // m_lastPoint = p; // return new NodePointArc3PointPoint(this, eCurrentPoint.endangle); //} //p = RadiusNodePoint(canvas); //if (HitUtil.PointInPoint(p, point, thWidth)) //{ // m_lastPoint = p; // return new NodePointArc3PointPoint(this, eCurrentPoint.radius); //} //return null; }