Example #1
0
        private static void PivotPoints(GenericPosture posture, float radians, GenericPostureImpactPivot impact)
        {
            // Rotates a series of point around a pivot point.
            PointF pivot = posture.PointList[impact.Pivot];

            foreach (int pointRef in impact.Impacted)
            {
                posture.PointList[pointRef] = GeometryHelper.Pivot(pivot, posture.PointList[pointRef], radians);
            }
        }
Example #2
0
        private static void ProcessPointImpact(GenericPosture posture, CalibrationHelper calibrationHelper, GenericPostureAbstractImpact impact, int handle, PointF old)
        {
            switch (impact.Type)
            {
            case ImpactType.LineAlign:
                AlignPointSegment(posture, impact as GenericPostureImpactLineAlign);
                break;

            case ImpactType.VerticalAlign:
                AlignPointVertical(posture, calibrationHelper, handle, impact as GenericPostureImpactVerticalAlign);
                break;

            case ImpactType.HorizontalAlign:
                AlignPointHorizontal(posture, handle, impact as GenericPostureImpactHorizontalAlign);
                break;

            case ImpactType.Pivot:
                // Get rotation that was applied. Apply same rotation on all points.
                GenericPostureImpactPivot impactPivot = impact as GenericPostureImpactPivot;
                if (impact != null)
                {
                    PointF a       = posture.PointList[impactPivot.Pivot];
                    PointF b       = old;
                    PointF c       = posture.PointList[posture.Handles[handle].Reference];
                    float  radians = GeometryHelper.GetAngle(a, b, c);
                    PivotPoints(posture, radians, impact as GenericPostureImpactPivot);
                }
                break;

            case ImpactType.KeepAngle:
                KeepPointAngle(posture, impact as GenericPostureImpactKeepAngle);
                break;

            case ImpactType.SegmentCenter:
                SegmentCenter(posture, calibrationHelper, impact as GenericPostureImpactSegmentCenter);
                break;

            case ImpactType.PerdpendicularAlign:
                AlignPointPerpendicular(posture, calibrationHelper, impact as GenericPosturePerpendicularAlign);
                break;

            case ImpactType.ParallelAlign:
                AlignPointParallel(posture, calibrationHelper, impact as GenericPostureParallelAlign);
                break;
            }
        }
        private void ParseImpacts(XmlReader r)
        {
            r.ReadStartElement();

            while (r.NodeType == XmlNodeType.Element)
            {
                if (r.Name == "Align")
                {
                    GenericPostureImpactLineAlign impact = new GenericPostureImpactLineAlign(r);
                    if (impact != null)
                    {
                        Impacts.Add(impact);
                    }
                }
                else if (r.Name == "VerticalAlign")
                {
                    GenericPostureImpactVerticalAlign impact = new GenericPostureImpactVerticalAlign(r);
                    if (impact != null)
                    {
                        Impacts.Add(impact);
                    }
                }
                else if (r.Name == "HorizontalAlign")
                {
                    GenericPostureImpactHorizontalAlign impact = new GenericPostureImpactHorizontalAlign(r);
                    if (impact != null)
                    {
                        Impacts.Add(impact);
                    }
                }
                else if (r.Name == "Pivot")
                {
                    GenericPostureImpactPivot impact = new GenericPostureImpactPivot(r);
                    if (impact != null)
                    {
                        Impacts.Add(impact);
                    }
                }
                else if (r.Name == "KeepAngle")
                {
                    GenericPostureImpactKeepAngle impact = new GenericPostureImpactKeepAngle(r);
                    if (impact != null)
                    {
                        Impacts.Add(impact);
                    }
                }
                else if (r.Name == "HorizontalSymmetry")
                {
                    GenericPostureImpactHorizontalSymmetry impact = new GenericPostureImpactHorizontalSymmetry(r);
                    if (impact != null)
                    {
                        Impacts.Add(impact);
                    }
                }
                else if (r.Name == "SegmentCenter")
                {
                    GenericPostureImpactSegmentCenter impact = new GenericPostureImpactSegmentCenter(r);
                    if (impact != null)
                    {
                        Impacts.Add(impact);
                    }
                }
                else if (r.Name == "PerdpendicularAlign")
                {
                    GenericPosturePerpendicularAlign impact = new GenericPosturePerpendicularAlign(r);
                    if (impact != null)
                    {
                        Impacts.Add(impact);
                    }
                }
                else if (r.Name == "ParallelAlign")
                {
                    GenericPostureParallelAlign impact = new GenericPostureParallelAlign(r);
                    if (impact != null)
                    {
                        Impacts.Add(impact);
                    }
                }
                else
                {
                    string outerXml = r.ReadOuterXml();
                    log.DebugFormat("Unparsed content in XML: {0}", outerXml);
                }
            }

            r.ReadEndElement();
        }