Ejemplo n.º 1
0
        /// <summary>
        /// Returns true if the object is visible on the view.
        /// </summary>
        /// <returns>true</returns>
        /// <c>false</c>
        /// <param name="view">View.</param>
        /// <param name="zoom"></param>
        public override bool IsVisibleIn(View2D view, float zoom)
        {
            if (this.MinZoom > zoom || this.MaxZoom < zoom)
            { // outside of zoom bounds!
                return(false);
            }

            return(_bounds.Overlaps(view.OuterBox));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns true if the given rectangle overlaps with this view.
        /// </summary>
        /// <returns><c>true</c>, if with rectangle overlaps, <c>false</c> otherwise.</returns>
        /// <param name="left">Left.</param>
        /// <param name="top">Top.</param>
        /// <param name="right">Right.</param>
        /// <param name="bottom">Bottom.</param>
        public bool OverlapsWithBox(double left, double top, double right, double bottom)
        {
            BoxF2D box = new BoxF2D(left, top, right, bottom);

            if (box.Overlaps(_rectangle.BoundingBox))
            {
                return(_rectangle.Overlaps(box));
            }
            return(false);
        }
Ejemplo n.º 3
0
        public void TestRectangleF2DOverlaps()
        {
            double       delta     = 0.00001;
            RectangleF2D rectangle = new RectangleF2D(1, 1, System.Math.Sqrt(2) * 2,
                                                      System.Math.Sqrt(2) * 2, 45);

            double[] converted = rectangle.TransformFrom(100, 100, false, false,
                                                         new double[] { 25, 75 });
            Assert.AreEqual(2, converted.Length);
            Assert.AreEqual(3, converted[0], delta);
            Assert.AreEqual(2, converted[1], delta);
            double[] convertedBack = rectangle.TransformTo(100, 100, false, false,
                                                           converted);
            Assert.AreEqual(2, convertedBack.Length);
            Assert.AreEqual(25, convertedBack[0], delta);
            Assert.AreEqual(75, convertedBack[1], delta);

            Assert.IsFalse(rectangle.Overlaps(new BoxF2D(5, 3, 6, 4)));
            Assert.IsTrue(rectangle.Overlaps(new BoxF2D(3.5, 1.5, 4.5, 2.5)));
            Assert.IsTrue(rectangle.Overlaps(new BoxF2D(2, 0.5, 3, 1.5)));
            Assert.IsTrue(rectangle.Overlaps(new BoxF2D(0, -2, 4, 6)));
            Assert.IsTrue(rectangle.Overlaps(new BoxF2D(4, -2, 6, 4)));
            Assert.IsTrue(rectangle.Overlaps(new BoxF2D(1.5, -2, 2.5, 4)));
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Returns true if the object is visible on the view.
 /// </summary>
 /// <returns>true</returns>
 /// <c>false</c>
 /// <param name="view">View.</param>
 /// <param name="zoom"></param>
 public override bool IsVisibleIn(View2D view, float zoom)
 { // TODO: refine this visible check.
     return(_bounds.Overlaps(view.OuterBox));
 }