private static void AlignPointPerpendicular(GenericPosture posture, CalibrationHelper calibrationHelper, GenericPosturePerpendicularAlign impact) { // The point is moved so that it stays on a perpendicular segment relatively to another segment. if (impact == null) { return; } PointF pivot = posture.PointList[impact.Origin]; PointF leg1 = posture.PointList[impact.Leg1]; PointF pointToMove = posture.PointList[impact.PointToMove]; if (pivot == leg1) { return; } PointF pivotPlane = calibrationHelper.GetPoint(pivot); PointF leg1Plane = calibrationHelper.GetPoint(leg1); PointF pointPlane = calibrationHelper.GetPoint(pointToMove); PointF resultPlane = GeometryHelper.GetPointAtAngle(pivotPlane, leg1Plane, pointPlane, 90); PointF result = calibrationHelper.GetImagePoint(resultPlane); posture.PointList[impact.PointToMove] = result; }
private float ComputeCalibratedAngle(PointF o, PointF a, PointF b, bool signed, bool ccw, CalibrationHelper calibration) { if (calibration == null) { throw new InvalidProgramException(); } PointF o2 = calibration.GetPoint(o); PointF a2 = calibration.GetPoint(a); PointF b2 = calibration.GetPoint(b); float value = 0; if (ccw) { value = GeometryHelper.GetAngle(o2, a2, b2); } else { value = GeometryHelper.GetAngle(o2, b2, a2); } if (!signed && value < 0) { value = (float)(TAU + value); } return(value); }
public void WriteXml(XmlWriter w, SerializationFilter filter) { if (ShouldSerializeCore(filter)) { w.WriteElementString("Start", XmlHelper.WritePointF(points["a"])); w.WriteElementString("End", XmlHelper.WritePointF(points["b"])); TypeConverter enumConverter = TypeDescriptor.GetConverter(typeof(TrackExtraData)); string xmlExtraData = enumConverter.ConvertToString(trackExtraData); w.WriteElementString("ExtraData", xmlExtraData); w.WriteStartElement("MeasureLabel"); miniLabel.WriteXml(w); w.WriteEndElement(); } if (ShouldSerializeStyle(filter)) { w.WriteStartElement("DrawingStyle"); style.WriteXml(w); w.WriteEndElement(); } if (ShouldSerializeFading(filter)) { w.WriteStartElement("InfosFading"); infosFading.WriteXml(w); w.WriteEndElement(); } if (ShouldSerializeAll(filter)) { // Spreadsheet support. w.WriteStartElement("Measure"); PointF a = CalibrationHelper.GetPoint(new PointF(points["a"].X, points["a"].Y)); PointF b = CalibrationHelper.GetPoint(new PointF(points["b"].X, points["b"].Y)); float len = GeometryHelper.GetDistance(a, b); string value = String.Format("{0:0.00}", len); string valueInvariant = String.Format(CultureInfo.InvariantCulture, "{0:0.00}", len); w.WriteAttributeString("UserLength", value); w.WriteAttributeString("UserLengthInvariant", valueInvariant); w.WriteAttributeString("UserUnitLength", CalibrationHelper.GetLengthAbbreviation()); w.WriteEndElement(); } }
private static void MovePointHandleAlongParallel(GenericPosture posture, CalibrationHelper calibrationHelper, int handle, PointF point, GenericPostureConstraintParallelSlide constraint) { if (constraint == null) { return; } PointF a = posture.PointList[constraint.A]; PointF b = posture.PointList[constraint.B]; PointF c = posture.PointList[constraint.C]; PointF aPlane = calibrationHelper.GetPoint(a); PointF bPlane = calibrationHelper.GetPoint(b); PointF cPlane = calibrationHelper.GetPoint(c); PointF pointPlane = calibrationHelper.GetPoint(point); PointF resultPlane = GeometryHelper.GetPointOnParallel(aPlane, bPlane, cPlane, pointPlane); PointF result = calibrationHelper.GetImagePoint(resultPlane); posture.PointList[posture.Handles[handle].Reference] = result; }
public void Update(PointF o, PointF a, PointF b, int radius, Color color, CalibrationHelper calibration, IImageToViewportTransformer transformer) { if (o == a || o == b) { return; } Origin = o; Angle = ComputeAngle(o, a, b, false); Color = color; if (calibration == null) { CalibratedAngle = Angle; } else if (calibration.CalibratorType == CalibratorType.Plane) { PointF calibratedO = calibration.GetPoint(o); PointF calibratedA = calibration.GetPoint(a); PointF calibratedB = calibration.GetPoint(b); CalibratedAngle = ComputeAngle(calibratedO, calibratedA, calibratedB, true); } else if (calibration.CalibratorType == CalibratorType.Line) { // Note that direction of Y-axis is not the same that the one used for the uncalibrated space. PointF calibratedO = calibration.GetPoint(o); PointF calibratedA = calibration.GetPoint(a); PointF calibratedB = calibration.GetPoint(b); CalibratedAngle = ComputeAngle(calibratedO, calibratedA, calibratedB, true); } ComputeBoundingBox(o, a, b, (float)radius); ComputeTextPosition(Angle, transformer); ComputeHitRegion(BoundingBox, Angle); }
private static void SegmentCenter(GenericPosture posture, CalibrationHelper calibrationHelper, GenericPostureImpactSegmentCenter impact) { // The point is moved so that it stays at the center of the specified segment. // This should take perspective into account. if (impact == null) { return; } PointF p1 = posture.PointList[impact.Point1]; PointF p2 = posture.PointList[impact.Point2]; PointF p1Plane = calibrationHelper.GetPoint(p1); PointF p2Plane = calibrationHelper.GetPoint(p2); PointF resultPlane = GeometryHelper.GetMiddlePoint(p1Plane, p2Plane); PointF result = calibrationHelper.GetImagePoint(resultPlane); posture.PointList[impact.PointToMove] = result; }
private static void AlignPointParallel(GenericPosture posture, CalibrationHelper calibrationHelper, GenericPostureParallelAlign impact) { // The point is moved so that it stays on a segment parallel to another segment. if (impact == null) { return; } PointF a = posture.PointList[impact.A]; PointF b = posture.PointList[impact.B]; PointF c = posture.PointList[impact.C]; PointF pointToMove = posture.PointList[impact.PointToMove]; PointF aPlane = calibrationHelper.GetPoint(a); PointF bPlane = calibrationHelper.GetPoint(b); PointF cPlane = calibrationHelper.GetPoint(c); PointF pointPlane = calibrationHelper.GetPoint(pointToMove); PointF resultPlane = GeometryHelper.GetPointOnParallel(aPlane, bPlane, cPlane, pointPlane); PointF result = calibrationHelper.GetImagePoint(resultPlane); posture.PointList[impact.PointToMove] = result; }
private static void MovePointHandleAlongPerpendicular(GenericPosture posture, CalibrationHelper calibrationHelper, int handle, PointF point, GenericPostureConstraintPerpendicularSlide constraint) { if (constraint == null) { return; } PointF pivot = posture.PointList[constraint.Origin]; PointF leg1 = posture.PointList[constraint.Leg1]; if (pivot == leg1) { return; } PointF pivotPlane = calibrationHelper.GetPoint(pivot); PointF leg1Plane = calibrationHelper.GetPoint(leg1); PointF pointPlane = calibrationHelper.GetPoint(point); PointF resultPlane = GeometryHelper.GetPointAtAngle(pivotPlane, leg1Plane, pointPlane, 90); PointF result = calibrationHelper.GetImagePoint(resultPlane); posture.PointList[posture.Handles[handle].Reference] = result; }
public void WriteXml(XmlWriter w, SerializationFilter filter) { if (ShouldSerializeCore(filter)) { w.WriteElementString("CenterPoint", XmlHelper.WritePointF(points["0"])); TypeConverter enumConverter = TypeDescriptor.GetConverter(typeof(TrackExtraData)); string xmlExtraData = enumConverter.ConvertToString(trackExtraData); w.WriteElementString("ExtraData", xmlExtraData); w.WriteStartElement("MeasureLabel"); miniLabel.WriteXml(w); w.WriteEndElement(); } if (ShouldSerializeStyle(filter)) { w.WriteStartElement("DrawingStyle"); style.WriteXml(w); w.WriteEndElement(); } if (ShouldSerializeFading(filter)) { w.WriteStartElement("InfosFading"); infosFading.WriteXml(w); w.WriteEndElement(); } if (ShouldSerializeAll(filter)) { // Spreadsheet support. w.WriteStartElement("Coordinates"); PointF p = new PointF(points["0"].X, points["0"].Y); PointF coords = CalibrationHelper.GetPoint(p); w.WriteAttributeString("UserX", String.Format("{0:0.00}", coords.X)); w.WriteAttributeString("UserXInvariant", String.Format(CultureInfo.InvariantCulture, "{0:0.00}", coords.X)); w.WriteAttributeString("UserY", String.Format("{0:0.00}", coords.Y)); w.WriteAttributeString("UserYInvariant", String.Format(CultureInfo.InvariantCulture, "{0:0.00}", coords.Y)); w.WriteAttributeString("UserUnitLength", CalibrationHelper.GetLengthAbbreviation()); w.WriteEndElement(); } }
public void WriteXml(XmlWriter w, SerializationFilter filter) { if (ShouldSerializeCore(filter)) { w.WriteElementString("Start", XmlHelper.WritePointF(points["a"])); w.WriteElementString("End", XmlHelper.WritePointF(points["b"])); w.WriteElementString("MeasureVisible", ShowMeasurableInfo.ToString().ToLower()); } if (ShouldSerializeStyle(filter)) { w.WriteStartElement("DrawingStyle"); style.WriteXml(w); w.WriteEndElement(); } if (ShouldSerializeFading(filter)) { w.WriteStartElement("InfosFading"); infosFading.WriteXml(w); w.WriteEndElement(); } if (ShouldSerializeAll(filter)) { // Spreadsheet support. w.WriteStartElement("Measure"); PointF a = CalibrationHelper.GetPoint(new PointF(points["a"].X, points["a"].Y)); PointF b = CalibrationHelper.GetPoint(new PointF(points["b"].X, points["b"].Y)); float len = GeometryHelper.GetDistance(a, b); string value = String.Format("{0:0.00}", len); string valueInvariant = String.Format(CultureInfo.InvariantCulture, "{0:0.00}", len); w.WriteAttributeString("UserLength", value); w.WriteAttributeString("UserLengthInvariant", valueInvariant); w.WriteAttributeString("UserUnitLength", CalibrationHelper.GetLengthAbbreviation()); w.WriteEndElement(); } }
public void WriteXml(XmlWriter w, SerializationFilter filter) { if (ShouldSerializeCore(filter)) { w.WriteElementString("CenterPoint", XmlHelper.WritePointF(points["0"])); w.WriteElementString("CoordinatesVisible", ShowMeasurableInfo.ToString().ToLower()); } if (ShouldSerializeStyle(filter)) { w.WriteStartElement("DrawingStyle"); style.WriteXml(w); w.WriteEndElement(); } if (ShouldSerializeFading(filter)) { w.WriteStartElement("InfosFading"); infosFading.WriteXml(w); w.WriteEndElement(); } if (ShouldSerializeAll(filter)) { // Spreadsheet support. w.WriteStartElement("Coordinates"); PointF p = new PointF(points["0"].X, points["0"].Y); PointF coords = CalibrationHelper.GetPoint(p); w.WriteAttributeString("UserX", String.Format("{0:0.00}", coords.X)); w.WriteAttributeString("UserXInvariant", String.Format(CultureInfo.InvariantCulture, "{0:0.00}", coords.X)); w.WriteAttributeString("UserY", String.Format("{0:0.00}", coords.Y)); w.WriteAttributeString("UserYInvariant", String.Format(CultureInfo.InvariantCulture, "{0:0.00}", coords.Y)); w.WriteAttributeString("UserUnitLength", CalibrationHelper.GetLengthAbbreviation()); w.WriteEndElement(); } }
private void MoveVerticalAxis(PointF p) { PointF point = CalibrationHelper.GetPoint(p); points["0"] = CalibrationHelper.GetImagePoint(new PointF(point.X, 0)); }
private void MoveHorizontalAxis(PointF p) { PointF point = CalibrationHelper.GetPoint(p); points["0"] = CalibrationHelper.GetImagePoint(new PointF(0, point.Y)); }