calibrate Method

Summary

Sets the ruler calibration scale.

Syntax

JavaScript Syntax
AnnContainerMapper.prototype.calibrate = function(sourceLength, sourceUnit, destinationLength, destinationUnit) 
TypeScript Syntax
calibrate(sourceLength: LeadLengthD, sourceUnit: AnnUnit, destinationLength: LeadLengthD, destinationUnit: AnnUnit): void; 

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.

JavaScript Example
example: function SiteLibrary_DefaultPage$example() { 
   // 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.Core.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.Core.AnnStroke.create(lt.Annotations.Core.AnnSolidColorBrush.create("red"), lt.LeadLengthD.create(1))); 
   rulerObj.set_showGauge(true); 
   rulerObj.set_showTickMarks(true); 
   rulerObj.set_measurementUnit(lt.Annotations.Core.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.Core.AnnUnit.unit,        // Source unit (container units) 
      lt.LeadLengthD.create(6.5),              // Destination length 
      lt.Annotations.Core.AnnUnit.centimeter); // Destination unit  
 
   // Use the Centimeters as the measurement unit in the ruler 
   rulerObj.set_measurementUnit(lt.Annotations.Core.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"); 
}, 

Requirements

Target Platforms

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Annotations.Core Assembly