private static bool EntityPoints(PicTypedDrawable entity, Vector2D pt, ref Vector2D pt0, ref Vector2D pt1) { PicSegment seg = entity as PicSegment; if (null != seg) { if ((pt - seg.Pt0).GetLength() < (pt - seg.Pt1).GetLength()) { pt0 = seg.Pt0; pt1 = seg.Pt1; } else { pt0 = seg.Pt1; pt1 = seg.Pt0; } } PicArc arc = entity as PicArc; if (null != arc) { if ((pt - arc.Source).GetLength() < (pt - arc.Target).GetLength()) { pt0 = arc.Source; pt1 = arc.Target; } else { pt1 = arc.Target; pt0 = arc.Source; } } return((pt0 - pt).GetLength() < _epsilon); }
private static Vector2D OppositePoint(PicTypedDrawable entity, Vector2D pt) { PicSegment seg = entity as PicSegment; if (null != seg) { if ((seg.Pt0 - pt).GetLength() < (seg.Pt1 - pt).GetLength()) { return(seg.Pt1); } else { return(seg.Pt0); } } PicArc arc = entity as PicArc; if (null != arc) { if ((arc.Source - pt).GetLength() < (arc.Target - pt).GetLength()) { return(arc.Target); } else { return(arc.Source); } } return(Vector2D.Zero); }
public static PicSegment CreateNewSegment(uint id, PicGraphics.LT lType, Vector2D pt0, Vector2D pt1) { PicSegment segment = new PicSegment(id, lType); segment._pt0 = pt0; segment._pt1 = pt1; return segment; }
public override PicEntity Clone(IEntityContainer factory) { PicSegment segment = new PicSegment(factory.GetNewEntityId(), LineType); segment._pt0 = this._pt0; segment._pt1 = this._pt1; return segment; }
private static double DistanceEntityPt(PicTypedDrawable entity, Vector2D pt) { PicSegment seg = entity as PicSegment; if (null != seg) { return(Math.Min((seg.Pt0 - pt).GetLength(), (seg.Pt1 - pt).GetLength())); } PicArc arc = entity as PicArc; if (null != arc) { return(Math.Min((arc.Source - pt).GetLength(), (arc.Target - pt).GetLength())); } return(0.0); }
public void CreateEntities(PicFactory factory) { if (null == _entities) { return; } // show entities for (int i = 0; i < Math.Min(_entities.Count, trackBarEntities.Value); ++i) { PicTypedDrawable entity = _entities[i]; PicSegment seg = entity as PicSegment; if (null != seg) { factory.AddSegment(seg.LineType, seg.Group, seg.Layer, seg.Pt0, seg.Pt1); } PicArc arc = entity as PicArc; if (null != arc) { factory.AddArc(arc.LineType, arc.Group, arc.Layer, arc.Center, arc.Radius, arc.AngleBeg, arc.AngleEnd); } } }
/// <summary> /// instantiate the tool with 2 segments and a radius /// </summary> /// <param name="seg0">first segment (order does not matter)</param> /// <param name="seg1">second segment (order does not matter)</param> /// <param name="radius"></param> public PicToolRound(PicEntity seg0, PicEntity seg1, double radius) { _picSeg0 = seg0 as PicSegment; _picSeg1 = seg1 as PicSegment; _radius = radius; }