コード例 #1
0
        private static void MovePointHandle(GenericPosture posture, CalibrationHelper calibrationHelper, int handle, PointF point, Keys modifiers)
        {
            // Constraints. (position of the point managed by this handle).
            GenericPostureAbstractConstraint constraint = posture.Handles[handle].Constraint;
            PointF old = posture.PointList[posture.Handles[handle].Reference];

            PrepareImpacts(posture, handle);

            if (constraint == null ||
                (!string.IsNullOrEmpty(constraint.OptionGroup) && !posture.OptionGroups[constraint.OptionGroup]))
            {
                MovePointHandleFreely(posture, handle, point);
            }
            else
            {
                switch (constraint.Type)
                {
                case ConstraintType.None:
                    MovePointHandleFreely(posture, handle, point);
                    break;

                case ConstraintType.LineSlide:
                    MovePointHandleAlongLine(posture, handle, point, constraint as GenericPostureConstraintLineSlide);
                    break;

                case ConstraintType.VerticalSlide:
                    MovePointHandleAlongVertical(posture, calibrationHelper, handle, point);
                    break;

                case ConstraintType.HorizontalSlide:
                    MovePointHandleAlongHorizontal(posture, handle, point);
                    break;

                case ConstraintType.DistanceToPoint:
                    MovePointHandleAtDistance(posture, handle, point, constraint as GenericPostureConstraintDistanceToPoint, modifiers);
                    break;

                case ConstraintType.RotationSteps:
                    MovePointHandleByRotationSteps(posture, calibrationHelper, handle, point, constraint as GenericPostureConstraintRotationSteps);
                    break;

                case ConstraintType.PerpendicularSlide:
                    MovePointHandleAlongPerpendicular(posture, calibrationHelper, handle, point, constraint as GenericPostureConstraintPerpendicularSlide);
                    break;

                case ConstraintType.ParallelSlide:
                    MovePointHandleAlongParallel(posture, calibrationHelper, handle, point, constraint as GenericPostureConstraintParallelSlide);
                    break;

                case ConstraintType.LockedInPlace:
                    break;
                }
            }

            ProcessPointImpacts(posture, calibrationHelper, handle, old);
        }
コード例 #2
0
        private static void MoveCircleHandle(GenericPosture posture, int handle, PointF point)
        {
            // Constraints. (position of the point managed by this handle).
            GenericPostureAbstractConstraint constraint = posture.Handles[handle].Constraint;

            if (!IsActive(constraint, posture))
            {
                MoveCircleHandleFreely(posture, handle, point);
            }
            else
            {
                switch (constraint.Type)
                {
                case ConstraintType.None:
                    MoveCircleHandleFreely(posture, handle, point);
                    break;
                }
            }
        }
コード例 #3
0
        private static bool IsActive(GenericPostureAbstractConstraint constraint, GenericPosture posture)
        {
            if (constraint == null)
            {
                return(false);
            }

            string value = constraint.OptionGroup;

            if (string.IsNullOrEmpty(value))
            {
                return(true);
            }

            string[] keys = value.Split(new char[] { '|' });

            // We only implement the "AND" logic at the moment:
            // in case of multiple options on the object, they all need to be active for the object to be active.
            bool active = true;

            foreach (string key in keys)
            {
                if (!posture.Options.ContainsKey(key))
                {
                    continue;
                }

                if (!posture.Options[key].Value)
                {
                    active = false;
                    break;
                }
            }

            return(active);
        }
コード例 #4
0
        private static void MoveSegmentHandle(GenericPosture posture, CalibrationHelper calibrationHelper, int handle, PointF point)
        {
            int    start    = posture.Segments[posture.Handles[handle].Reference].Start;
            int    end      = posture.Segments[posture.Handles[handle].Reference].End;
            PointF oldStart = posture.PointList[start];
            PointF oldEnd   = posture.PointList[end];

            // Constraints. (position of the point managed by this handle).
            GenericPostureAbstractConstraint constraint = posture.Handles[handle].Constraint;

            if (!IsActive(constraint, posture))
            {
                MoveSegmentHandleFreely(posture, handle, point);
            }
            else
            {
                switch (constraint.Type)
                {
                case ConstraintType.None:
                    MoveSegmentHandleFreely(posture, handle, point);
                    break;

                case ConstraintType.HorizontalSlide:
                    MoveSegmentHandleAlongHorizontal(posture, handle, point);
                    break;

                case ConstraintType.VerticalSlide:
                    MoveSegmentHandleAlongVertical(posture, handle, point);
                    break;

                case ConstraintType.LockedInPlace:
                    break;
                }
            }

            // Impacts. (positions of other points).
            foreach (GenericPostureAbstractImpact impact in posture.Handles[handle].Impacts)
            {
                switch (impact.Type)
                {
                case ImpactType.HorizontalSymmetry:
                    MoveSegmentSymmetrically(posture, impact as GenericPostureImpactHorizontalSymmetry);
                    break;
                }
            }

            // Check if segments start and end points are handles, and apply impacts.
            foreach (GenericPostureHandle h in posture.Handles)
            {
                if (h.Type != HandleType.Point)
                {
                    continue;
                }

                int handleReference = h.Reference;

                if (handleReference == start)
                {
                    PrepareImpacts(posture, handleReference);
                    ProcessPointImpacts(posture, calibrationHelper, handleReference, oldStart);
                }
                else if (h.Reference == end)
                {
                    PrepareImpacts(posture, handleReference);
                    ProcessPointImpacts(posture, calibrationHelper, handleReference, oldEnd);
                }
            }
        }