Esempio n. 1
0
        public override Anchor GetNearestAnchor(PointT p, int exitAngleMod8 = -1)
        {
            VectorT vec = p - Center, vecAbs = vec.Abs();
            bool    vert = vecAbs.Y / Size.Y > vecAbs.X / Size.X;
            Coord   frac = ((p.Y - Top) / (Bottom - Top)).PutInRange(0, 1);
            Anchor  a;

            if (vert)
            {
                frac = ((p.X - Left) / (Right - Left)).PutInRange(0, 1);
                if (vec.Y > 0)                 // bottom
                {
                    a = Anchor(() => new PointT(Left + frac * (Right - Left), Bottom), 7 << 5);
                }
                else                 // top
                {
                    a = Anchor(() => new PointT(Left + frac * (Right - Left), Top), 7 << 1);
                }
            }
            else
            {
                if (vec.X > 0)                 // right
                {
                    a = Anchor(() => new PointT(Right, Top + frac * (Bottom - Top)), 0x83);
                }
                else                 // left
                {
                    a = Anchor(() => new PointT(Left, Top + frac * (Bottom - Top)), 7 << 3);
                }
            }
            return(a);
        }
Esempio n. 2
0
 public LLMarker(DrawStyle style, PointT point, Coord radius, MarkerPolygon type)
     : base(style)
 {
     Point  = point;
     Radius = radius;
     Type   = type;
 }
Esempio n. 3
0
        internal Util.WinForms.HitTestResult HitTest(PointT mouseLoc)
        {
            var mouseSS    = ToShapeSpace(mouseLoc);          // SS=Shape Space
            var htRadiusSS = ToShapeSpace(HitTestRadius);

            Util.WinForms.HitTestResult best = null;
            bool bestSel    = false;
            int  bestZOrder = 0;

            foreach (IShapeWidget shapeW in WidgetsOnScreen(mouseLoc))
            {
                var shape  = shapeW as Shape;
                var result = shapeW.HitTest(mouseSS, htRadiusSS, GetSelType(shapeW as Shape));
                if (result != null)
                {
                    Debug.Assert(result.Shape == shapeW);
                    bool resultSel = shape == null || _selectedShapes.Contains(shape);
                    int  zOrder    = shape != null ? shape.HitTestZOrder : int.MaxValue;
                    // Prefer to hit test against an already-selected shape (unless
                    // it's a panel) or a non-Shape widget, otherwise the thing with
                    // the highest Z-order.
                    if (shape != null && shape.IsPanel)
                    {
                        resultSel = false;
                    }
                    if (best == null || (resultSel && !bestSel) || (bestSel == resultSel && bestZOrder < zOrder))
                    {
                        best       = result;
                        bestSel    = resultSel;
                        bestZOrder = zOrder;
                    }
                }
            }
            return(best);
        }
Esempio n. 4
0
        public override object HitTest(PointT point, Coord radius, out PointT projected)
        {
            var infl = Style.LineWidth * 0.5f + radius;

            projected = point.ProjectOnto(Rect);
            return(projected.X + projected.Y <= infl ? (float?)0 : null);
        }
Esempio n. 5
0
		public override HitTestResult HitTest(PointT pos, VectorT hitTestRadius, SelType sel)
		{
			var dif = pos.Sub(Point).Abs();
			if (dif.X <= hitTestRadius.X && dif.Y <= hitTestRadius.Y)
				return new HitTestResult(this, sel != SelType.No ? Cursors.SizeAll : Cursors.Arrow);
			return null;
		}
Esempio n. 6
0
        public override object HitTest(PointT point, float radius, out PointT projected)
        {
            LLShape bestShape  = null;
            object  bestResult = null;
            float   bestQuad   = float.PositiveInfinity;

            projected = default(PointT);
            foreach (var shape in _shapes)
            {
                PointT proj;
                var    r = shape.HitTest(point, radius, out proj);
                if (r != null)
                {
                    float quad = projected.Sub(point).Quadrance();
                    if (bestShape == null || quad < bestQuad)
                    {
                        bestShape  = shape;
                        bestResult = r;
                        bestQuad   = quad;
                        projected  = proj;
                    }
                }
            }
            return(new Pair <LLShape, object>(bestShape, bestResult));
        }
Esempio n. 7
0
		public HitTestResult HitTest(PointT pos, VectorT hitTestRadius, SelType sel)
		{
			var c = Center;
			if (c.Sub(pos).Length() > _radius)
				return null;

			return new HitTestResult(this, Cursors.SizeAll);
		}
Esempio n. 8
0
 public Marker(DiagramDrawStyle style, PointT point, float radius, MarkerPolygon type)
 {
     LL = new LLMarker(style, point, radius, type)
     {
         ZOrder = NextZOrder++
     };
     Style = style;
 }
Esempio n. 9
0
 public override object HitTest(PointT point, Coord radius, out PointT projected)
 {
     projected = point;
     if (!BBox.Inflated(radius, radius).Contains(point))
     {
         return(null);
     }
     return(HitTestPolyline(point, radius, Points, Divisions, out projected));
 }
Esempio n. 10
0
        public override Util.WinForms.HitTestResult HitTest(PointT pos, VectorT hitTestRadius, SelType sel)
        {
            if (!BBox.Inflated(hitTestRadius.X, hitTestRadius.Y).Contains(pos))
            {
                return(null);
            }

            if (sel == SelType.Partial)
            {
                if (PointsAreNear(pos, Points[0], hitTestRadius))
                {
                    return(new HitTestResult(this, Cursors.SizeAll, 0));
                }
                if (PointsAreNear(pos, Points[Points.Count - 1], hitTestRadius))
                {
                    return(new HitTestResult(this, Cursors.SizeAll, Points.Count - 1));
                }
            }
            else if (sel == SelType.Yes)
            {
                for (int i = 0; i < Points.Count; i++)
                {
                    if (PointsAreNear(pos, Points[i], hitTestRadius))
                    {
                        return(new HitTestResult(this, Cursors.SizeAll, i));
                    }
                }
            }

            PointT projected;

            float?where = LLShape.HitTestPolyline(pos, hitTestRadius.X, Points, EmptyList <int> .Value, out projected);
            if (where != null)
            {
                if (sel == SelType.Yes)
                {
                    int seg   = (int)where.Value;
                    var angle = AngleMod8(Points[seg + 1].Sub(Points[seg]));
                    switch (angle & 3)
                    {
                    case 0: return(new HitTestResult(this, Cursors.SizeNS, seg));

                    case 1: return(new HitTestResult(this, Cursors.SizeNESW, seg));

                    case 2: return(new HitTestResult(this, Cursors.SizeWE, seg));

                    case 3: return(new HitTestResult(this, Cursors.SizeNWSE, seg));
                    }
                }
                else
                {
                    return(new HitTestResult(this, Cursors.Arrow, -1));
                }
            }
            return(null);
        }
Esempio n. 11
0
        public override HitTestResult HitTest(PointT pos, VectorT hitTestRadius, SelType sel)
        {
            var dif = pos.Sub(Point).Abs();

            if (dif.X <= hitTestRadius.X && dif.Y <= hitTestRadius.Y)
            {
                return(new HitTestResult(this, sel != SelType.No ? Cursors.SizeAll : Cursors.Arrow));
            }
            return(null);
        }
Esempio n. 12
0
        public Anchor GetBestAnchor(PointT input, int exitAngleMod8 = -1)
        {
            var candidates =
                from shape in _doc.Shapes
                let anchor = shape.GetNearestAnchor(input, exitAngleMod8)
                             where anchor != null && anchor.Point.Sub(input).Quadrance() <= MathEx.Square(AnchorSnapDistance)
                             select anchor;

            return(candidates.MinOrDefault(a => a.Point.Sub(input).Quadrance()));
        }
Esempio n. 13
0
        internal void Zoom(float factor)
        {
            var    size   = ClientSize;
            PointT center = ToShapeSpace(new PointT(size.Width / 2, size.Height / 2));

            _scrollZoom.Translate(center.X, center.Y);
            _scrollZoom.Scale(factor, factor);
            _scrollZoom.Translate(-center.X, -center.Y);
            MatrixChanged();
        }
Esempio n. 14
0
        public HitTestResult HitTest(PointT pos, VectorT hitTestRadius, SelType sel)
        {
            var c = Center;

            if (c.Sub(pos).Length() > _radius)
            {
                return(null);
            }

            return(new HitTestResult(this, Cursors.SizeAll));
        }
Esempio n. 15
0
        private void Flatten(PointT a, PointT b, PointT c, ArraySlice <PointF> @out, Coord per)
        {
            @out[0] = a.AsBCL();
            Coord frac = per;

            for (int i = 1; i < @out.Count; i++, frac += per)
            {
                PointT d = a.To(b).PointAlong(frac), e = b.To(c).PointAlong(frac);
                @out[i] = d.To(e).PointAlong(frac).AsBCL();
            }
        }
Esempio n. 16
0
 public static Coord?HitTestPolygon(PointT point, Coord radius, IEnumerable <PointT> points, IList <int> divisions, out PointT projected)
 {
     if (PolygonMath.GetWindingNumber(points, point) != 0)
     {
         projected = point;
         return(-1);
     }
     else
     {
         return(HitTestPolyline(point, radius, points, divisions, out projected));
     }
 }
Esempio n. 17
0
        private void AddCornerAdorner(ICollection <LLShape> list, PointT point, VectorT vector)
        {
            VectorT up = new VectorT(0, -vector.Y), down = new VectorT(0, vector.Y);
            VectorT left = new VectorT(-vector.X, 0), right = new VectorT(vector.X, 0);
            var     points = new[] {
                point, point.Add(up), point.Add(up).Add(right),
                point.Add(vector), point.Add(left).Add(down), point.Add(left)
            };

            list.Add(new LLPolygon(SelAdornerFillStyle, points));
            list.Add(new LLPolyline(SelAdornerLineStyle, points.Slice(1).AsList()));
        }
Esempio n. 18
0
        public override object HitTest(PointT point, Coord radius, out PointT projected)
        {
            projected = point;
            if (!BBox.Inflated(radius, radius).Contains(point))
            {
                return(null);
            }
            AutoFlatten();
            float?result = HitTestPolyline(point, radius, Flattened.Select(p => p.AsLoyc()), EmptyList <int> .Value, out projected);

            return(result / _pointsPerSeg);
        }
Esempio n. 19
0
 public override object HitTest(PointT point, Coord radius, out PointT projected)
 {
     projected = Point;
     if (point.Sub(Point).Quadrance() <= MathEx.Square(radius + Radius))
     {
         return(0);
     }
     else
     {
         return(null);
     }
 }
Esempio n. 20
0
 public override object HitTest(PointT point, Coord radius, out PointT projected)
 {
     projected = point;
     if (!BBox.Inflated(radius, radius).Contains(point))
     {
         return(null);
     }
     if (PolygonMath.GetWindingNumber(Points, point) != 0)
     {
         projected = point;
         return(-1);
     }
     return(HitTestPolyline(point, radius, Points, Divisions, out projected));
 }
Esempio n. 21
0
        public override object HitTest(PointT point, Coord radius, out PointT projected)
        {
            var size = MeasuredSize;

            projected = point;
            Coord x = point.X, y = point.Y;

            if (HitTest1D(ref x, Location.X, size.X, MaxSize.HasValue ? MaxSize.Value.X : size.X, Justify.Alignment) ||
                HitTest1D(ref y, Location.Y, size.Y, MaxSize.HasValue ? MaxSize.Value.Y : size.Y, Justify.LineAlignment))
            {
                return(0f);
            }
            projected = new PointT(x, y);
            return(null);
        }
Esempio n. 22
0
        public override void AddAdornersTo(ICollection <LLShape> list, SelType selMode, VectorT hitTestRadius)
        {
            PointT tl = BBox.MinPoint, tr = new PointT(Right, Top);
            PointT br = BBox.MaxPoint, bl = new PointT(Left, Bottom);

            if (selMode == SelType.Yes)
            {
                AddCornerAdorner(list, tl, hitTestRadius.Neg());
                AddCornerAdorner(list, br, hitTestRadius);
            }
            if (selMode != SelType.No)
            {
                hitTestRadius = hitTestRadius.Rot90();
                AddCornerAdorner(list, bl, hitTestRadius);
                AddCornerAdorner(list, tr, hitTestRadius.Neg());
            }
        }
Esempio n. 23
0
        List <int> FindReversals(List <PointT> points, int stopAfter)
        {
            var reversals = new List <int>();

            for (int i = 1, c = points.Count; i < c - 1; i++)
            {
                PointT  p0 = points[i - 1], p1 = points[i], p2 = points[i + 1];
                VectorT v1 = p1.Sub(p0), v2 = p2.Sub(p1);
                if (v1.Dot(v2) < 0 && MathEx.Mod(v1.AngleDeg() - v2.AngleDeg(), 360).IsInRange(150, 210))
                {
                    reversals.Add(i);
                    if (reversals.Count >= stopAfter)
                    {
                        break;
                    }
                }
            }
            return(reversals);
        }
Esempio n. 24
0
        public override Util.WinForms.HitTestResult HitTest(PointT pos, VectorT hitTestRadius, SelType sel)
        {
            if (sel != SelType.No)
            {
                var    bbox2 = BBox.Inflated(hitTestRadius.X, hitTestRadius.Y);
                PointT tl = BBox.MinPoint, tr = new PointT(Right, Top);
                PointT br = BBox.MaxPoint, bl = new PointT(Left, Bottom);
                if (PointsAreNear(pos, tr, hitTestRadius))
                {
                    return(new HitTestResult(this, Cursors.SizeNESW, RF.Top | RF.Right));
                }
                if (PointsAreNear(pos, bl, hitTestRadius))
                {
                    return(new HitTestResult(this, Cursors.SizeNESW, RF.Bottom | RF.Left));
                }
                if (sel == SelType.Yes)
                {
                    if (PointsAreNear(pos, tl, hitTestRadius))
                    {
                        return(new HitTestResult(this, Cursors.SizeNWSE, RF.Top | RF.Left));
                    }
                    if (PointsAreNear(pos, br, hitTestRadius))
                    {
                        return(new HitTestResult(this, Cursors.SizeNWSE, RF.Bottom | RF.Right));
                    }
                }
            }
            if (sel != SelType.No || (BoxType != BoxType.Borderless && !_isPanel))
            {
                if (sel != SelType.Yes)
                {
                    hitTestRadius *= 2;
                }
                var bbox2 = BBox.Deflated(hitTestRadius.X, hitTestRadius.Y);
                if (bbox2.Contains(pos))
                {
                    return(new HitTestResult(this, Cursors.SizeAll, RF.Top | RF.Bottom | RF.Left | RF.Right));
                }
            }

            return(BBox.Contains(pos) ? new HitTestResult(this, Cursors.Arrow, 0) : null);
        }
Esempio n. 25
0
		public override Anchor GetNearestAnchor(PointT p, int exitAngleMod8 = -1)
		{
			VectorT vec = p - Center, vecAbs = vec.Abs();
			bool vert = vecAbs.Y / Size.Y > vecAbs.X / Size.X;
			Coord frac = Range.PutInRange((p.Y - Top) / (Bottom - Top), 0, 1);
			Anchor a;
			if (vert) {
				frac = Range.PutInRange((p.X - Left) / (Right - Left), 0, 1);
				if (vec.Y > 0) // bottom
					a = Anchor(() => new PointT(Left + frac * (Right - Left), Bottom), 7 << 5);
				else // top
					a = Anchor(() => new PointT(Left + frac * (Right - Left), Top), 7 << 1);
			} else {
				if (vec.X > 0) // right
					a = Anchor(() => new PointT(Right, Top + frac * (Bottom - Top)), 0x83);
				else // left
					a = Anchor(() => new PointT(Left, Top + frac * (Bottom - Top)), 7 << 3);
			}
			return a;
		}
Esempio n. 26
0
        public static Coord?HitTestPolyline(PointT point, Coord radius, IEnumerable <PointT> points, IList <int> divisions, out PointT projected)
        {
            var    maxQuadrance = radius * radius;
            int    i            = 0;
            Coord? bestHit      = null;
            PointT bestProj     = point;

            foreach (var line in points.AdjacentPairsCircular())
            {
                Coord  frac;
                PointT p;
                var    q = QuadranceTo(point, line, out frac, out p);
                if (q < maxQuadrance)
                {
                    maxQuadrance = q;
                    bestHit      = i + frac;
                    bestProj     = p;
                }
                i++;
            }
            projected = bestProj;
            return(bestHit);
        }
Esempio n. 27
0
 public void Flatten()
 {
     if (Points.Count <= 2)
     {
         Flattened = Points.SelectArray(p => p.AsBCL());
     }
     else
     {
         int totalCount = PointsPerSeg * (Points.Count - 1) + 1;
         Flattened = new PointF[totalCount];
         int   offs = 0;
         Coord per  = 1f / PointsPerSeg;
         for (int i = 0; i < Points.Count - 2; i++)
         {
             bool   last = i == Points.Count - 2;
             PointT a = Points[i], b = Points[i + 1], c = Points[i + 2];
             PointT a_ = i == 0 ? a : a.To(b).Midpoint();
             PointT c_ = last ? c : b.To(c).Midpoint();
             Flatten(a_, b, c_, Flattened.Slice(offs, PointsPerSeg), per);
             offs += PointsPerSeg;
         }
         Flattened[Flattened.Length - 1] = Points[Points.Count - 1].AsBCL();
     }
 }
Esempio n. 28
0
		public Marker(DiagramDrawStyle style, PointT point, float radius, MarkerPolygon type)
		{
			LL = new LLMarker(style, point, radius, type) { ZOrder = NextZOrder++ };
			Style = style;
		}
Esempio n. 29
0
 protected static Coord QuadranceTo(PointT p, LineSegmentT seg, out Coord frac, out PointT proj)
 {
     frac = p.GetFractionAlong(seg);
     proj = seg.PointAlong(frac);
     return(p.Sub(proj).Quadrance());
 }
Esempio n. 30
0
		public override Util.WinForms.HitTestResult HitTest(PointT pos, VectorT hitTestRadius, SelType sel)
		{
			if (sel != SelType.No) {
				var bbox2 = BBox.Inflated(hitTestRadius.X, hitTestRadius.Y);
				PointT tl = BBox.MinPoint, tr = new PointT(Right, Top);
				PointT br = BBox.MaxPoint, bl = new PointT(Left, Bottom);
				if (PointsAreNear(pos, tr, hitTestRadius))
					return new HitTestResult(this, Cursors.SizeNESW, RF.Top | RF.Right);
				if (PointsAreNear(pos, bl, hitTestRadius))
					return new HitTestResult(this, Cursors.SizeNESW, RF.Bottom | RF.Left);
				if (sel == SelType.Yes) {
					if (PointsAreNear(pos, tl, hitTestRadius))
						return new HitTestResult(this, Cursors.SizeNWSE, RF.Top | RF.Left);
					if (PointsAreNear(pos, br, hitTestRadius))
						return new HitTestResult(this, Cursors.SizeNWSE, RF.Bottom | RF.Right);
				}
			}
			if (sel != SelType.No || (BoxType != BoxType.Borderless && !_isPanel))
			{
				if (sel != SelType.Yes)
					hitTestRadius *= 2;
				var bbox2 = BBox.Deflated(hitTestRadius.X, hitTestRadius.Y);
				if (bbox2.Contains(pos))
					return new HitTestResult(this, Cursors.SizeAll, RF.Top | RF.Bottom | RF.Left | RF.Right);
			}

			return BBox.Contains(pos) ? new HitTestResult(this, Cursors.Arrow, 0) : null;
		}
Esempio n. 31
0
		public IEnumerable<IShapeWidget> WidgetsOnScreen(PointT mousePos) { return _widgets.Concat(_doc.Shapes); }
Esempio n. 32
0
		internal Util.WinForms.HitTestResult HitTest(PointT mouseLoc)
		{
			var mouseSS = ToShapeSpace(mouseLoc); // SS=Shape Space
			var htRadiusSS = ToShapeSpace(HitTestRadius);
			Util.WinForms.HitTestResult best = null;
			bool bestSel = false;
			int bestZOrder = 0;
			foreach (IShapeWidget shapeW in WidgetsOnScreen(mouseLoc))
			{
				var shape = shapeW as Shape;
				var result = shapeW.HitTest(mouseSS, htRadiusSS, GetSelType(shapeW as Shape));
				if (result != null)
				{
					Debug.Assert(result.Shape == shapeW);
					bool resultSel = shape == null || _selectedShapes.Contains(shape);
					int zOrder = shape != null ? shape.HitTestZOrder : int.MaxValue;
					// Prefer to hit test against an already-selected shape (unless 
					// it's a panel) or a non-Shape widget, otherwise the thing with 
					// the highest Z-order.
					if (shape != null && shape.IsPanel)
						resultSel = false;
					if (best == null || (resultSel && !bestSel) || (bestSel == resultSel && bestZOrder < zOrder))
					{
						best = result;
						bestSel = resultSel;
						bestZOrder = zOrder;
					}
				}
			}
			return best;
		}
Esempio n. 33
0
		internal Point<float>? _lastClickLocation; // shape space. used to let user click blank space and start typing

		internal PointT ToShapeSpace(PointT px) { return _shapeGroup.InverseTransform.Transform(px); }
Esempio n. 34
0
 public override Anchor GetNearestAnchor(PointT p, int exitAngleMod8 = -1)
 {
     return(Anchor(() => this.Point));
 }
Esempio n. 35
0
 public LLMarkerRotated(DrawStyle style, PointT point, Coord radius, MarkerPolygon type, Coord angleDeg) : base(style, point, radius, type)
 {
     AngleDeg = angleDeg;
 }
Esempio n. 36
0
 public LLTextShape(DrawStyle style, string text, StringFormat justify, PointT location, VectorT?maxSize = null)
     : base(style)
 {
     Text = text; Justify = justify ?? Justify; Location = location; MaxSize = maxSize;
 }
Esempio n. 37
0
		public override Anchor GetNearestAnchor(PointT p, int exitAngleMod8 = -1)
		{
			return Anchor(() => this.Point);
		}
Esempio n. 38
0
        public static Coord?HitTestLine(PointF point_, Coord radius, LineSegmentT line, out PointT proj)
        {
            Coord frac;

            if (QuadranceTo(point_.AsLoyc(), line, out frac, out proj) <= radius * radius)
            {
                return(frac);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 39
0
 /// <summary>Determines whether a test point is close to the shape.</summary>
 /// <param name="point">The test point.</param>
 /// <param name="radius">Maximum distance between the shape and the test point</param>
 /// <param name="projected">The point on the shape that is closest to the test point</param>
 /// <returns>null if not hit; if hit, an object that represents part of the shape that was hit.</returns>
 /// <remarks>
 /// Complex shapes should automatically track their bounding box to
 /// optimize hit-testing.
 /// <para/>
 /// For polylines, the return value represents the line segment
 /// that was hit plus the fraction along that segment, e.g. 3.33
 /// represents one-third of the distance from the beginning of the
 /// fourth segment (between point 3 and 4). For polygons, the return
 /// value should be negative for the inside of the polygon, or
 /// positive for one of the edges (number determined as for a line
 /// string.)
 /// </remarks>
 public abstract object HitTest(PointT point, Coord radius, out PointT projected);
Esempio n. 40
0
		public override void AddAdornersTo(ICollection<LLShape> list, SelType selMode, VectorT hitTestRadius)
		{
			PointT tl = BBox.MinPoint, tr = new PointT(Right, Top);
			PointT br = BBox.MaxPoint, bl = new PointT(Left, Bottom);
			if (selMode == SelType.Yes)
			{
				AddCornerAdorner(list, tl, hitTestRadius.Neg());
				AddCornerAdorner(list, br, hitTestRadius);
			}
			if (selMode != SelType.No)
			{
				hitTestRadius = hitTestRadius.Rot90();
				AddCornerAdorner(list, bl, hitTestRadius);
				AddCornerAdorner(list, tr, hitTestRadius.Neg());
			}
		}
Esempio n. 41
0
		internal PointT ToPixelSpace(PointT px) { return _shapeGroup.Transform.Transform(px); }
Esempio n. 42
0
		private void AddCornerAdorner(ICollection<LLShape> list, PointT point, VectorT vector)
		{
			VectorT up = new VectorT(0, -vector.Y), down = new VectorT(0, vector.Y);
			VectorT left = new VectorT(-vector.X, 0), right = new VectorT(vector.X, 0);
			var points = new[] { 
				point, point.Add(up), point.Add(up).Add(right), 
				point.Add(vector), point.Add(left).Add(down), point.Add(left)
			};
			list.Add(new LLPolygon(SelAdornerFillStyle, points));
			list.Add(new LLPolyline(SelAdornerLineStyle, points.Slice(1).AsList()));
		}
Esempio n. 43
0
		// TODO optimization: return a cached subset rather than all shapes
		public IEnumerable<Shape> ShapesOnScreen(PointT mousePos) { return _doc.Shapes; }
Esempio n. 44
0
		public override Util.WinForms.HitTestResult HitTest(PointT pos, VectorT hitTestRadius, SelType sel)
		{
			if (!BBox.Inflated(hitTestRadius.X, hitTestRadius.Y).Contains(pos))
				return null;
			
			if (sel == SelType.Partial) {
				if (PointsAreNear(pos, Points[0], hitTestRadius))
					return new HitTestResult(this, Cursors.SizeAll, 0);
				if (PointsAreNear(pos, Points[Points.Count-1], hitTestRadius))
					return new HitTestResult(this, Cursors.SizeAll, Points.Count-1);
			} else if (sel == SelType.Yes) {
				for (int i = 0; i < Points.Count; i++)
				{
					if (PointsAreNear(pos, Points[i], hitTestRadius))
						return new HitTestResult(this, Cursors.SizeAll, i);
				}
			}
			
			PointT projected;
			float? where = LLShape.HitTestPolyline(pos, hitTestRadius.X, Points, EmptyList<int>.Value, out projected);
			if (where != null)
			{
				if (sel == SelType.Yes) {
					int seg = (int)where.Value;
					var angle = AngleMod8(Points[seg+1].Sub(Points[seg]));
					switch (angle & 3) {
						case 0: return new HitTestResult(this, Cursors.SizeNS, seg);
						case 1: return new HitTestResult(this, Cursors.SizeNESW, seg);
						case 2: return new HitTestResult(this, Cursors.SizeWE, seg);
						case 3: return new HitTestResult(this, Cursors.SizeNWSE, seg);
					}
				} else {
					return new HitTestResult(this, Cursors.Arrow, -1);
				}
			}
			return null;
		}
Esempio n. 45
0
		public Anchor GetBestAnchor(PointT input, int exitAngleMod8 = -1)
		{
			var candidates =
				from shape in _doc.Shapes
				let anchor = shape.GetNearestAnchor(input, exitAngleMod8)
				where anchor != null && anchor.Point.Sub(input).Quadrance() <= MathEx.Square(AnchorSnapDistance)
				select anchor;
			return candidates.MinOrDefault(a => a.Point.Sub(input).Quadrance());
		}
Esempio n. 46
0
		private void AddAdorner(ICollection<LLShape> list, PointT point, VectorT hitTestRadius)
		{
			list.Add(new LLMarker(SelAdornerStyle, point, hitTestRadius.X, MarkerPolygon.Square));
		}