Beispiel #1
0
        public void RemoveOperator_SourceOperatorWithConnection_operatorAndConnectionRemoved()
        {
            var metaCompOp = new MetaOperator(Guid.NewGuid());

            metaCompOp.AddOperator(MetaOperatorTests.CreateFloatMetaOperator(Guid.NewGuid()));
            metaCompOp.AddOperator(MetaOperatorTests.CreateFloatMetaOperator(Guid.NewGuid()));
            Operator op     = metaCompOp.CreateOperator(Guid.NewGuid());
            Operator float1 = op.InternalOps[0];
            Operator float2 = op.InternalOps[1];

            op.InsertConnectionAt(new Connection(float1, float1.Outputs[0], float2, float2.Inputs[0], 0));
            Assert.AreEqual(float1.Outputs[0], float2.Inputs[0].Connections[0]);

            List <System.EventArgs> eventArgs = new List <System.EventArgs>();

            op.ConnectionRemovedEvent += (o, e) => { eventArgs.Add(e); };
            op.OperatorRemovedEvent   += (o, e) => { eventArgs.Add(e); };

            op.RemoveOperator(float1);

            Assert.AreEqual(2, eventArgs.Count);
            var connectionChangedEventArgs = eventArgs[0] as ConnectionChangedEventArgs;

            Assert.AreNotEqual(null, connectionChangedEventArgs);
            Assert.AreEqual(float1, connectionChangedEventArgs.Connection.SourceOp);
            Assert.AreEqual(float1.Outputs[0], connectionChangedEventArgs.Connection.SourceOpPart);
            Assert.AreEqual(float2, connectionChangedEventArgs.Connection.TargetOp);
            Assert.AreEqual(float2.Inputs[0], connectionChangedEventArgs.Connection.TargetOpPart);
            Assert.AreNotEqual(null, eventArgs[1] as OperatorChangedEventArgs);
            Assert.AreEqual(1, op.InternalOps.Count);
            Assert.AreEqual(float2, op.InternalOps[0]);
            Assert.AreEqual(0, float2.Inputs[0].Connections.Count);
        }
Beispiel #2
0
        public static Operator CreateEmptyOperator()
        {
            var metaOp = new MetaOperator(Guid.NewGuid())
            {
                Name = "Empty"
            };

            return(metaOp.CreateOperator(Guid.NewGuid()));
        }
Beispiel #3
0
        public TransformGizmo()
        {
            MetaOperator sceneTransformGizmoDefinition = MetaManager.Instance.GetMetaOperator(Guid.Parse("2e56b389-a983-42fe-a015-61d9f9532af4"));

            _sceneTransformGizmoOperator = sceneTransformGizmoDefinition.CreateOperator(Guid.Empty);

            GizmoParts = new GizmoPart[]
            {
                new AxisGizmoPart(0, Vector3.Zero, Vector3.UnitX, new[] { _translateXParam, _translateYParam, _translateZParam }),
                new AxisGizmoPart(1, Vector3.Zero, Vector3.UnitY, new[] { _translateXParam, _translateYParam, _translateZParam }),
                new AxisGizmoPart(2, Vector3.Zero, Vector3.UnitZ, new[] { _translateXParam, _translateYParam, _translateZParam }),
                new PlaneGizmoPart(3, Vector3.Zero, new Vector3(1, 1, 0), new[] { _translateXParam, _translateYParam, _translateZParam }),
                new PlaneGizmoPart(4, Vector3.Zero, new Vector3(1, 0, 1), new[] { _translateXParam, _translateYParam, _translateZParam }),
                new PlaneGizmoPart(5, Vector3.Zero, new Vector3(0, 1, 1), new[] { _translateXParam, _translateYParam, _translateZParam }),
            };
        }
Beispiel #4
0
        public void InsertConnectionAt_Inserting2ndConnectionAtIndex0ToMultiInput_connectionIsInsertedAtFront()
        {
            var metaCompOp = new MetaOperator(Guid.NewGuid());

            metaCompOp.AddOperator(MetaOperatorTests.CreateGenericMultiInputMetaOperator());
            metaCompOp.AddOperator(MetaOperatorTests.CreateFloatMetaOperator(Guid.NewGuid()));
            metaCompOp.AddOperator(MetaOperatorTests.CreateFloatMetaOperator(Guid.NewGuid()));
            Operator op       = metaCompOp.CreateOperator(Guid.NewGuid());
            Operator multiply = op.InternalOps[0];
            Operator float1   = op.InternalOps[1];
            Operator float2   = op.InternalOps[2];

            op.InsertConnectionAt(new Connection(float1, float1.Outputs[0], multiply, multiply.Inputs[0], 0));
            op.InsertConnectionAt(new Connection(float2, float2.Outputs[0], multiply, multiply.Inputs[0], 0));

            Assert.AreEqual(multiply.Inputs[0].Connections[0], float2.Outputs[0]);
        }