Beispiel #1
0
        public void PinchTextMaintainsWrapping()
        {
            AggContext.StaticData = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData"));
            MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4));

            var root = new Object3D();
            var text = new TextObject3D();

            root.Children.Add(text);
            text.Invalidate(new InvalidateArgs(text, InvalidateType.Properties, null));
            Assert.AreEqual(5, root.Descendants().Count());

            // now add a pinch
            var pinch1 = new PinchObject3D();

            pinch1.WrapItems(new List <IObject3D>()
            {
                text
            });
            root.Children.Remove(text);
            root.Children.Add(pinch1);
            Assert.AreEqual(10, root.Descendants().Count());

            // now remove pinch
            pinch1.Remove(null);
            Assert.AreEqual(5, root.Descendants().Count());
            Assert.AreEqual(1, root.Children.Count());

            // now add it again
            var first = root.Children.First();             // the wrap made a copy so set text to be the current text

            Assert.IsTrue(first is TextObject3D);
            pinch1 = new PinchObject3D();
            pinch1.WrapItems(new List <IObject3D>()
            {
                first
            });
            root.Children.Remove(first);
            root.Children.Add(pinch1);
            Assert.AreEqual(10, root.Descendants().Count());
        }
Beispiel #2
0
        public void PinchChangesMesh()
        {
            AggContext.StaticData = new FileSystemStaticData(TestContext.CurrentContext.ResolveProjectPath(4, "StaticData"));
            MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4));

            var root = new Object3D();
            var cube = new CubeObject3D();

            root.Children.Add(cube);
            cube.Invalidate(new InvalidateArgs(cube, InvalidateType.Properties));
            Assert.AreEqual(1, root.Descendants().Count());

            // now add a pinch
            var pinch1 = new PinchObject3D();

            pinch1.WrapItems(new List <IObject3D>()
            {
                cube
            });
            root.Children.Remove(cube);
            root.Children.Add(pinch1);
            Assert.AreEqual(3, root.Descendants().Count());
        }
Beispiel #3
0
        public void AabbCalculatedCorrectlyForPinchedFitObjects()
        {
            // build without pinch
            {
                var root = new Object3D();
                var cube = new CubeObject3D(20, 20, 20);
                root.Children.Add(cube);
                Assert.IsTrue(root.GetAxisAlignedBoundingBox().Equals(new AxisAlignedBoundingBox(new Vector3(-10, -10, -10), new Vector3(10, 10, 10)), .001));
                root.Children.Remove(cube);
                var fit = FitToBoundsObject3D_2.Create(cube);

                fit.SizeX = 50;
                fit.SizeY = 20;
                fit.SizeZ = 20;
                root.Children.Add(fit);
                var rootAabb = root.GetAxisAlignedBoundingBox();
                Assert.IsTrue(rootAabb.Equals(new AxisAlignedBoundingBox(new Vector3(-25, -10, -10), new Vector3(25, 10, 10)), .001));
            }

            // build with pinch
            {
                var root = new Object3D();
                var cube = new CubeObject3D(20, 20, 20);
                root.Children.Add(cube);
                var fit = FitToBoundsObject3D_2.Create(cube);

                fit.SizeX = 50;
                fit.SizeY = 20;
                fit.SizeZ = 20;

                var pinch = new PinchObject3D();
                pinch.Children.Add(fit);
                root.Children.Add(pinch);
                var rootAabb = root.GetAxisAlignedBoundingBox();
                Assert.IsTrue(rootAabb.Equals(new AxisAlignedBoundingBox(new Vector3(-10, -10, -10), new Vector3(10, 10, 10)), .001));
            }

            // build with translate
            {
                var root = new Object3D();
                var cube = new CubeObject3D(20, 20, 20);

                var translate = new TranslateObject3D(cube, 11, 0, 0);

                root.Children.Add(translate);
                var rootAabb = root.GetAxisAlignedBoundingBox();
                Assert.IsTrue(rootAabb.Equals(new AxisAlignedBoundingBox(new Vector3(1, -10, -10), new Vector3(21, 10, 10)), .001));
            }

            // build with pinch and translate
            {
                var root = new Object3D();
                var cube = new CubeObject3D(20, 20, 20);

                var translate = new TranslateObject3D(cube, 11, 0, 0);

                var pinch = new PinchObject3D();
                pinch.Children.Add(translate);
                root.Children.Add(pinch);
                pinch.Invalidate(new InvalidateArgs(pinch, InvalidateType.Properties));
                var rootAabb = root.GetAxisAlignedBoundingBox();
                Assert.IsTrue(rootAabb.Equals(new AxisAlignedBoundingBox(new Vector3(1, -10, -10), new Vector3(21, 10, 10)), .001));
            }

            // build with pinch and translate
            {
                var root = new Object3D();
                var cube = new CubeObject3D(20, 20, 20);
                var fit  = FitToBoundsObject3D_2.Create(cube);

                fit.SizeX = 50;
                fit.SizeY = 20;
                fit.SizeZ = 20;

                var translate = new TranslateObject3D(fit, 11, 0, 0);

                var pinch = new PinchObject3D();
                pinch.Children.Add(translate);
                pinch.Invalidate(new InvalidateArgs(pinch, InvalidateType.Properties));
                root.Children.Add(pinch);
                var rootAabb = root.GetAxisAlignedBoundingBox();
                Assert.IsTrue(rootAabb.Equals(new AxisAlignedBoundingBox(new Vector3(1, -10, -10), new Vector3(21, 10, 10)), .001));
            }
        }