LEADTOOLS JavaScript (Leadtools.Annotations.Core)
LEAD Technologies, Inc

Calibrate Method

Example 

Known source length value
Units of sourceLength
What the destination length must be
Units of destinationUnit
Sets the ruler calibration scale.
Syntax
 function Leadtools.Annotations.Core.AnnContainerMapper.calibrate( 
   sourceLength ,
   sourceUnit ,
   destinationLength ,
   destinationUnit 
)
!MISSING Scrap '_RTJavaScript_Method_SYNTAX'!

Parameters

ParameterTypeDescription
sourceLengthLeadLengthDKnown source length value
sourceUnitAnnUnitUnits of sourceLength
destinationLengthLeadLengthDWhat the destination length must be
destinationUnitAnnUnitUnits 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
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 Leadtools.Annotations.Core.AnnPolyRulerObject();
   rulerObj.get_points().add(Leadtools.LeadPointD.create(1 * inch, 1 * inch));
   rulerObj.get_points().add(Leadtools.LeadPointD.create(2 * inch, 1 * inch));
   rulerObj.set_stroke(Leadtools.Annotations.Core.AnnStroke.create(Leadtools.Annotations.Core.AnnSolidColorBrush.create("red"), Leadtools.LeadLengthD.create(1)));
   rulerObj.set_showGauge(true);
   rulerObj.set_showTickMarks(true);
   rulerObj.set_measurementUnit(Leadtools.Annotations.Core.AnnUnit.inch);
   container.get_children().add(rulerObj);

   // Show the ruler
   this._automation.invalidate(Leadtools.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(
      Leadtools.LeadLengthD.create(length),           // Source length
      Leadtools.Annotations.Core.AnnUnit.unit,        // Source unit (container units)
      Leadtools.LeadLengthD.create(6.5),              // Destination length
      Leadtools.Annotations.Core.AnnUnit.centimeter); // Destination unit 

   // Use the Centimeters as the measurement unit in the ruler
   rulerObj.set_measurementUnit(Leadtools.Annotations.Core.AnnUnit.centimeter);

   // Now rulerObj should show 6.5 Centimeter as its length
   this._automation.invalidate(Leadtools.LeadRectD.get_empty());
   alert("Calibrated, length is 6.5 cm");
},
See Also

Reference

AnnContainerMapper Object
AnnContainerMapper Members

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.