(Leadtools.Annotations.Core)

Calibrate Method

Show in webframe
Example 





Known source length value
Units of sourceLength
What the destination length must be
Units of destinationUnit
Sets the ruler calibration scale.
Syntax
public void Calibrate( 
   LeadLengthD sourceLength,
   AnnUnit sourceUnit,
   LeadLengthD destinationLength,
   AnnUnit destinationUnit
)
Public Sub Calibrate( _
   ByVal sourceLength As LeadLengthD, _
   ByVal sourceUnit As AnnUnit, _
   ByVal destinationLength As LeadLengthD, _
   ByVal destinationUnit As AnnUnit _
) 
public void Calibrate( 
   LeadLengthD sourceLength,
   AnnUnit sourceUnit,
   LeadLengthD destinationLength,
   AnnUnit destinationUnit
)
-(void) calibrateSourceLength:(double) srcLen 
                   sourceUnit:(LTAnnUnit) srcUnit 
            destinationLength:(double) targetLen 
              destinationUnit:(LTAnnUnit) targetUnit;
            
public void calibrate(
   LeadLengthD sourceLength,
   AnnUnit sourceUnit,
   LeadLengthD destinationLength,
   AnnUnit destinationUnit
)
            
 function Leadtools.Annotations.Core.AnnContainerMapper.Calibrate( 
   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
Copy Code  
using Leadtools.Annotations.Automation;
using Leadtools.Annotations.Core;
using Leadtools.Codecs;

public void AnnContainerMapper_Calibrate()
{
   // Add a ruler with a length of 1 inch to the container
   AnnContainer container = _automation.Container;
   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
   _automation.Invalidate(LeadRectD.Empty);
   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
   _automation.Invalidate(LeadRectD.Empty);
   Debug.WriteLine("Calibrated, length is 6.5 cm");
}
using Leadtools.Converters;
using Leadtools.Annotations.Automation;
using Leadtools.Controls;
using Leadtools.Annotations.Core;
using Leadtools.Codecs;

[TestMethod]
public void AnnContainerMapper_Calibrate()
{
   // Add a ruler with a length of 1 inch to the container
   AnnContainer container = _automation.Container;
   double inch = 720;
   AnnPolyRulerObject rulerObj = new AnnPolyRulerObject();
   rulerObj.Points.Add(LeadPointDHelper.Create(1 * inch, 1 * inch));
   rulerObj.Points.Add(LeadPointDHelper.Create(2 * inch, 1 * inch));
   rulerObj.Stroke = AnnStroke.Create(AnnSolidColorBrush.Create("Red"), LeadLengthDHelper.Create(1));
   rulerObj.ShowGauge = true;
   rulerObj.ShowTickMarks = true;
   rulerObj.MeasurementUnit = AnnUnit.Inch;
   container.Children.Add(rulerObj);
   // Show the ruler
   _automation.Invalidate(LeadRectDHelper.Empty);
   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(
      LeadLengthDHelper.Create(length),   // Source length
      AnnUnit.Unit,                       // Source unit (container units)
      LeadLengthDHelper.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
   _automation.Invalidate(LeadRectDHelper.Empty);
   Debug.WriteLine("Calibrated, length is 6.5 cm");
}
Requirements

Target Platforms

See Also

Reference

AnnContainerMapper Class
AnnContainerMapper Members

 

 


Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.