calibrate Method

Summary

Sets the ruler calibration scale.

Syntax
TypeScript
JavaScript
AnnContainerMapper.prototype.calibrate = function( 
   sourceLength, 
   sourceUnit, 
   destinationLength, 
   destinationUnit 
) 

Parameters

sourceLength

Known source length value

sourceUnit

Units of sourceLength

destinationLength

What the destination length must be

destinationUnit

Units of destinationUnit

Remarks

This method will use the parameters to calculate a new value for CalibrationScale. This value is used afterwards by all the existing ruler and new ruler objects created in this container.

Calibrating a ruler means assigning a specific length to it. For example, on a digital X-ray of a hand, you may draw an annotation ruler object along one of the fingers. You know that this distance is supposed to be exactly 6.5 cm. Using the new calibration functionality you can calibrate this ruler, all existing rulers, and all newly created rulers so that they would precisely measure this distance to be 6.5 cm. This is accomplished by first drawing a ruler on the container till it matches exactly the length of the finger - ignoring the values shown - then using Calibrate as shown in the example.

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.

TypeScript
JavaScript
// Add a ruler with a length of 1 inch to the container 
var container = this._automation.get_container(); 
var inch = 720; 
var rulerObj = new lt.Annotations.Engine.AnnPolyRulerObject(); 
rulerObj.get_points().add(lt.LeadPointD.create(1 * inch, 1 * inch)); 
rulerObj.get_points().add(lt.LeadPointD.create(2 * inch, 1 * inch)); 
rulerObj.set_stroke(lt.Annotations.Engine.AnnStroke.create(lt.Annotations.Engine.AnnSolidColorBrush.create("red"), lt.LeadLengthD.create(1))); 
rulerObj.set_showGauge(true); 
rulerObj.set_showTickMarks(true); 
rulerObj.set_measurementUnit(lt.Annotations.Engine.AnnUnit.inch); 
container.get_children().add(rulerObj); 
 
// Show the ruler 
this._automation.invalidate(lt.LeadRectD.get_empty()); 
alert("Ruler to calibrate, length is 1 inch"); 
 
// Get the length of the ruler 
var point1 = rulerObj.get_points().get_item(0); 
var point2 = rulerObj.get_points().get_item(1); 
var length = Math.sqrt(Math.pow(Math.abs(point2.get_x() - point1.get_x()), 2) + Math.pow(Math.abs(point2.get_y() - point1.get_y()), 2)); 
 
// Calibrate the container mapper 
container.get_mapper().calibrate( 
   lt.LeadLengthD.create(length),           // Source length 
   lt.Annotations.Engine.AnnUnit.unit,        // Source unit (container units) 
   lt.LeadLengthD.create(6.5),              // Destination length 
   lt.Annotations.Engine.AnnUnit.centimeter); // Destination unit  
 
// Use the Centimeters as the measurement unit in the ruler 
rulerObj.set_measurementUnit(lt.Annotations.Engine.AnnUnit.centimeter); 
 
// Now rulerObj should show 6.5 Centimeter as its length 
this._automation.invalidate(lt.LeadRectD.get_empty()); 
alert("Calibrated, length is 6.5 cm"); 
// Add a ruler with a length of 1 inch to the container 
const container: lt.Annotations.Engine.AnnContainer = this._automation.container; 
const inch: number = 720; 
const rulerObj: lt.Annotations.Engine.AnnPolyRulerObject = new lt.Annotations.Engine.AnnPolyRulerObject(); 
rulerObj.points.add(lt.LeadPointD.create(1 * inch, 1 * inch)); 
rulerObj.points.add(lt.LeadPointD.create(2 * inch, 1 * inch)); 
rulerObj.stroke = lt.Annotations.Engine.AnnStroke.create(lt.Annotations.Engine.AnnSolidColorBrush.create("red"), lt.LeadLengthD.create(1)); 
rulerObj.showGauge = true; 
rulerObj.showTickMarks = true; 
rulerObj.measurementUnit = lt.Annotations.Engine.AnnUnit.inch; 
container.children.add(rulerObj); 
 
// Show the ruler 
this._automation.invalidate(lt.LeadRectD.empty); 
alert("Ruler to calibrate, length is 1 inch"); 
 
// Get the length of the ruler 
const point1: lt.LeadPointD = rulerObj.points.item(0); 
const point2: lt.LeadPointD = rulerObj.points.item(1); 
const length: number = 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( 
   lt.LeadLengthD.create(length),           // Source length 
   lt.Annotations.Engine.AnnUnit.unit,        // Source unit (container units) 
   lt.LeadLengthD.create(6.5),              // Destination length 
   lt.Annotations.Engine.AnnUnit.centimeter); // Destination unit  
 
// Use the Centimeters as the measurement unit in the ruler 
rulerObj.measurementUnit = lt.Annotations.Engine.AnnUnit.centimeter; 
 
// Now rulerObj should show 6.5 Centimeter as its length 
this._automation.invalidate(lt.LeadRectD.empty); 
alert("Calibrated, length is 6.5 cm"); 

Requirements

Target Platforms

Help Version 20.0.2019.3.11
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2019 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Annotations.Engine Assembly