示例#1
0
        private void OnValueChanged()
        {
            if (_isUpdating)
            {
                return;
            }
            if (Value == null)
            {
                return;
            }

            _vectorType = Value.GetType();

            _isUpdating = true;
            try
            {
                if (_vectorType == typeof(Vector2))
                {
                    var v = (Vector2)Value;
                    X = Vector3Editor.SafeConvertToDouble(v.X);
                    Y = Vector3Editor.SafeConvertToDouble(v.Y);
                }
                else if (_vectorType == typeof(Vector2F))
                {
                    var v = (Vector2F)Value;
                    X = Vector3Editor.SafeConvertToDouble(v.X);
                    Y = Vector3Editor.SafeConvertToDouble(v.Y);
                }
                else if (_vectorType == typeof(Vector2D))
                {
                    var v = (Vector2D)Value;
                    X = v.X;
                    Y = v.Y;
                }
                else
                {
                    if (Value != null)
                    {
                        throw new NotSupportedException("Vector2Editor.Value must be a Vector2, Vector2F or Vector2D.");
                    }

                    X = 0;
                    Y = 0;
                }
            }
            finally
            {
                _isUpdating = false;
            }
        }
示例#2
0
        private void OnValueChanged()
        {
            if (_isUpdating)
            {
                return;
            }
            if (Value == null)
            {
                return;
            }

            _valueType = Value.GetType();

            _isUpdating = true;
            try
            {
                if (_valueType == typeof(Pose))
                {
                    var p = (Pose)Value;
                    X   = Vector3Editor.SafeConvertToDouble(p.Position.X);
                    Y   = Vector3Editor.SafeConvertToDouble(p.Position.Y);
                    Z   = Vector3Editor.SafeConvertToDouble(p.Position.Z);
                    M00 = Vector3Editor.SafeConvertToDouble(p.Orientation.M00);
                    M01 = Vector3Editor.SafeConvertToDouble(p.Orientation.M01);
                    M02 = Vector3Editor.SafeConvertToDouble(p.Orientation.M02);
                    M10 = Vector3Editor.SafeConvertToDouble(p.Orientation.M10);
                    M11 = Vector3Editor.SafeConvertToDouble(p.Orientation.M11);
                    M12 = Vector3Editor.SafeConvertToDouble(p.Orientation.M12);
                    M20 = Vector3Editor.SafeConvertToDouble(p.Orientation.M20);
                    M21 = Vector3Editor.SafeConvertToDouble(p.Orientation.M21);
                    M22 = Vector3Editor.SafeConvertToDouble(p.Orientation.M22);
                }
                else if (_valueType == typeof(PoseD))
                {
                    var p = (PoseD)Value;
                    X   = p.Position.X;
                    Y   = p.Position.Y;
                    Z   = p.Position.Z;
                    M00 = p.Orientation.M00;
                    M01 = p.Orientation.M01;
                    M02 = p.Orientation.M02;
                    M10 = p.Orientation.M10;
                    M11 = p.Orientation.M11;
                    M12 = p.Orientation.M12;
                    M20 = p.Orientation.M20;
                    M21 = p.Orientation.M21;
                    M22 = p.Orientation.M22;
                }
                else
                {
                    if (Value != null)
                    {
                        throw new NotSupportedException("PoseEditor.Value must be a Pose or a PoseD.");
                    }

                    X = 0;
                    Y = 0;
                    Z = 0;
                }
            }
            finally
            {
                _isUpdating = false;
            }
        }
        private void OnValueChanged()
        {
            if (_isUpdating)
            {
                return;
            }
            if (Value == null)
            {
                return;
            }

            _vectorType = Value.GetType();

            _isUpdating = true;
            try
            {
                if (_vectorType == typeof(Vector4))
                {
                    var v = (Vector4)Value;
                    X = Vector3Editor.SafeConvertToDouble(v.X);
                    Y = Vector3Editor.SafeConvertToDouble(v.Y);
                    Z = Vector3Editor.SafeConvertToDouble(v.Z);
                    W = Vector3Editor.SafeConvertToDouble(v.W);
                }
                else if (_vectorType == typeof(Quaternion))
                {
                    var v = (Quaternion)Value;
                    X = Vector3Editor.SafeConvertToDouble(v.X);
                    Y = Vector3Editor.SafeConvertToDouble(v.Y);
                    Z = Vector3Editor.SafeConvertToDouble(v.Z);
                    W = Vector3Editor.SafeConvertToDouble(v.W);
                }
                else if (_vectorType == typeof(Vector4F))
                {
                    var v = (Vector4F)Value;
                    X = Vector3Editor.SafeConvertToDouble(v.X);
                    Y = Vector3Editor.SafeConvertToDouble(v.Y);
                    Z = Vector3Editor.SafeConvertToDouble(v.Z);
                    W = Vector3Editor.SafeConvertToDouble(v.W);
                }
                else if (_vectorType == typeof(Vector4D))
                {
                    var v = (Vector4D)Value;
                    X = v.X;
                    Y = v.Y;
                    Z = v.Z;
                    W = v.W;
                }
                else if (_vectorType == typeof(QuaternionF))
                {
                    var v = (QuaternionF)Value;
                    X = Vector3Editor.SafeConvertToDouble(v.X);
                    Y = Vector3Editor.SafeConvertToDouble(v.Y);
                    Z = Vector3Editor.SafeConvertToDouble(v.Z);
                    W = Vector3Editor.SafeConvertToDouble(v.W);
                }
                else if (_vectorType == typeof(QuaternionD))
                {
                    var v = (QuaternionD)Value;
                    X = v.X;
                    Y = v.Y;
                    Z = v.Z;
                    W = v.W;
                }
                else
                {
                    if (Value != null)
                    {
                        throw new NotSupportedException("Vector4Editor.Value must be a Vector4, Quaternion, Vector4F, Vector4D, QuaternionF of QuaternionD.");
                    }

                    X = 0;
                    Y = 0;
                    Z = 0;
                }
            }
            finally
            {
                _isUpdating = false;
            }
        }