Calibrate Method (original) (raw)

Summary

Sets the ruler calibration scale.

Syntax

C#

Objective-C

C++/CLI

Java

Python

Parameters

sourceLength
Known source length value

destinationLength
What the destination length must be

Example

This example will draw a ruler with a length that is assumed is 6.5cm, it then uses Calibrate to set the mapper calibration scale.

using Leadtools.Annotations.Engine; public void AnnContainerMapper_Calibrate() { // Add a ruler with a length of 1 inch to the container AnnContainer container = new AnnContainer(); double inch = 720; AnnPolyRulerObject rulerObj = new AnnPolyRulerObject(); rulerObj.Points.Add(LeadPointD.Create(1 * inch, 1 * inch)); rulerObj.Points.Add(LeadPointD.Create(2 * inch, 1 * inch)); rulerObj.Stroke = AnnStroke.Create(AnnSolidColorBrush.Create("Red"), LeadLengthD.Create(1)); rulerObj.ShowGauge = true; rulerObj.ShowTickMarks = true; rulerObj.MeasurementUnit = AnnUnit.Inch; container.Children.Add(rulerObj); // Show the ruler Debug.WriteLine("Ruler to calibrate, length is 1 inch"); // Get the length of the ruler LeadPointD point1 = rulerObj.Points[0]; LeadPointD point2 = rulerObj.Points[1]; double length = Math.Sqrt(Math.Pow(Math.Abs(point2.X - point1.X), 2) + Math.Pow(Math.Abs(point2.Y - point1.Y), 2)); // Calibrate the container mapper container.Mapper.Calibrate( LeadLengthD.Create(length), // Source length AnnUnit.Unit, // Source unit (container units) LeadLengthD.Create(6.5), // Destination length AnnUnit.Centimeter); // Destination unit // Use the Centimeters as the measurement unit in the ruler rulerObj.MeasurementUnit = AnnUnit.Centimeter; // Now rulerObj should show 6.5 Centimeter as its length Debug.WriteLine("Calibrated, length is 6.5 cm"); }