public Type[] GetTargetTypes(NewPrimitive source)
 {
     Contract.Requires(source != null);
     Contract.Ensures(Contract.Result <Type[]>() != null);
     Contract.Ensures(Contract.ForAll(Contract.Result <Type[]>(), type => type != null));
     Contract.Ensures(Contract.Result <Type[]>().Contains(source.GetType()));
     return(null);
 }
        public void DuplicateSnapped(SnappedPrimitive primitiveData, out NewPrimitive newPrimitive, out NewPrimitive clone)
        {
            newPrimitive = primitivesConverter.SnappedToNew(primitiveData);
            newPrimitive.UpdateCurvesGeometry();

            sessionData.NewPrimitives.Add(newPrimitive);
            clone = primitivesConverter.NewToNew(newPrimitive, newPrimitive.GetType(), new Vector3D(0, 0, 0));
            SelectPrimitive(newPrimitive);
        }
示例#3
0
        public Type[] GetTargetTypes(NewPrimitive source)
        {
            var query =
                from key in newConvertersRegistry.Keys
                where key.Item1 == source.GetType()
                select key.Item2;

            return(query.ToArray());
        }
示例#4
0
        SnappedPrimitive IPrimitiveSnapper.Create(NewPrimitive newPrimitive)
        {
            Contract.Requires(newPrimitive != null);
            Contract.Requires(NewPrimitiveType.IsAssignableFrom(newPrimitive.GetType()));

            Contract.Ensures(Contract.Result <SnappedPrimitive>() != null);
            Contract.Ensures(SnappedPrimitiveType.IsAssignableFrom(Contract.Result <SnappedPrimitive>().GetType()));

            return(null);
        }
示例#5
0
        SnappedPrimitive IPrimitiveSnapper.Create(PointsSequence[] selectedCurves, NewPrimitive newPrimitive)
        {
            Contract.Requires(selectedCurves != null);
            Contract.Requires(Contract.ForAll(selectedCurves, c => c != null));
            Contract.Requires(newPrimitive != null);
            Contract.Requires(NewPrimitiveType.IsAssignableFrom(newPrimitive.GetType()));

            Contract.Ensures(Contract.Result <SnappedPrimitive>() != null);
            Contract.Ensures(SnappedPrimitiveType.IsAssignableFrom(Contract.Result <SnappedPrimitive>().GetType()));

            return(null);
        }
        public void CycleDuplicates(NewPrimitive originalDuplicate, ref NewPrimitive currentDuplicate, Vector3D currentDragVector)
        {
            var targetTypes = primitivesConverter.GetTargetTypes(originalDuplicate);
            var currIndex   = Array.IndexOf(targetTypes, currentDuplicate.GetType());
            var nextIndex   = (currIndex + 1) % targetTypes.Length;

            sessionData.NewPrimitives.Remove(currentDuplicate);
            currentDuplicate = primitivesConverter.NewToNew(originalDuplicate, targetTypes[nextIndex], currentDragVector);

            currentDuplicate.UpdateCurvesGeometry();
            sessionData.NewPrimitives.Add(currentDuplicate);

            SelectPrimitive(currentDuplicate);
        }
        public SnappedPrimitive Create(NewPrimitive newPrimitive)
        {
            Contract.Requires(newPrimitive != null);
            Contract.Ensures(Contract.Result <SnappedPrimitive>() != null);

            // find appropriate type snapper
            var newPrimitiveType = newPrimitive.GetType();
            var snapper          =
                snappers
                .Where(s => s.NewPrimitiveType.IsAssignableFrom(newPrimitiveType))
                .FirstOrDefault();

            if (snapper == null)
            {
                throw new InvalidOperationException("Cannot find snapper that can snap new primitives of type " + newPrimitiveType);
            }

            // return the snapper's result
            return(snapper.Create(newPrimitive));
        }
示例#8
0
 public void ApplyMovement(NewPrimitive source, NewPrimitive target, Vector3D moveVector)
 {
     Contract.Requires(source != null && source.GetType() == SourceType);
     Contract.Requires(target != null && target.GetType() == TargetType);
 }
示例#9
0
 public NewPrimitive Convert(NewPrimitive source, Vector3D moveVector)
 {
     Contract.Requires(source != null && source.GetType() == SourceType);
     Contract.Ensures(Contract.Result <NewPrimitive>() != null && Contract.Result <NewPrimitive>().GetType() == TargetType);
     return(null);
 }
 public void ApplyMovement(NewPrimitive source, NewPrimitive target, Vector3D moveVector)
 {
     Contract.Requires(source != null);
     Contract.Requires(target != null);
     Contract.Requires(GetTargetTypes(source).Contains(target.GetType()));
 }
示例#11
0
 private static NewConverterKey GetKey(NewPrimitive source, NewPrimitive target)
 {
     return(Tuple.Create(source.GetType(), target.GetType()));
 }