The AnnTransformer class is an Annotation support class which provides functionality for converting annotation points, rectangles, lengths, etc. from one coordinate system to another.
[SerializableAttribute()]
public class AnnTransformer : Transformer
<SerializableAttribute()>
Public Class AnnTransformer
Inherits Leadtools.Drawing.Leadtools.Drawing.Transformer
[SerializableAttribute()]
public ref class AnnTransformer : public Leadtools.Drawing.Leadtools.Drawing.Transformer
This class derives from the Leadtools.Drawing.Transformer class and provides extra functionality to deal with annotation-specific objects. The units of measure are taken into consideration and transformed objects retain the same units as the originals.
This example converts an annotation's point, length, size and rectangle from one unit of measure to another.
using Leadtools;
using Leadtools.Annotations;
using Leadtools.Codecs;
using Leadtools.WinForms;
public void AnnTransformer_AnnTransformer()
{
// set up a new unit converter with 96 DPI
AnnUnitConverter converter = new AnnUnitConverter(96, 96);
// set up a new matrix, scale it by 2,2 around the origin
Matrix transform = new Matrix();
transform.Scale(2, 2);
// set up the AnnTransformer
AnnTransformer transformer = new AnnTransformer(converter, transform);
// declare a new AnnPoint at 4, 5 inches
// transform it to physical coordinate using the transformer and show it in pixels
// then transform it back to its original logical coordinates
Console.WriteLine("Point{0}--------", Environment.NewLine);
AnnPoint pt1 = new AnnPoint(4, 5, AnnUnit.Inch);
PrintOut(converter, " Original: ", pt1);
AnnPoint pt2 = transformer.PointToPhysical(pt1);
PrintOut(converter, " Physical: ", pt2);
AnnPoint pt3 = transformer.PointToLogical(pt2);
PrintOut(converter, " Logical : ", pt3);
// declare an array of AnnPoints, do the same
Console.WriteLine("Points{0}--------", Environment.NewLine);
AnnPoint[] pts1 =
{
new AnnPoint(4, 5, AnnUnit.Inch),
new AnnPoint(5.2f, 3, AnnUnit.Inch),
new AnnPoint(2, 7.83f, AnnUnit.Inch),
};
PrintOut(converter, " Original: ", pts1);
AnnPoint[] pts2 = transformer.PointToPhysical(pts1);
PrintOut(converter, " Physical: ", pts2);
AnnPoint[] pts3 = transformer.PointToLogical(pts2);
PrintOut(converter, " Logical : ", pts3);
// declare a rectangle, do the same
Console.WriteLine("Rectangle{0}--------", Environment.NewLine);
AnnRectangle rc1 = new AnnRectangle(2, 3, 4, 1, AnnUnit.Inch);
PrintOut(converter, " Original: ", rc1);
AnnRectangle rc2 = transformer.RectangleToPhysical(rc1);
PrintOut(converter, " Physical: ", rc2);
AnnRectangle rc3 = transformer.RectangleToLogical(rc2);
PrintOut(converter, " Logical : ", rc3);
// declare a length, do the same
Console.WriteLine("Length{0}--------", Environment.NewLine);
AnnLength l1 = new AnnLength(10.5f, AnnUnit.Inch);
PrintOut(converter, " Original: ", l1);
AnnLength l2 = transformer.LengthToPhysical(l1);
PrintOut(converter, " Physical: ", l2);
AnnLength l3 = transformer.LengthToLogical(l2);
PrintOut(converter, " Logical : ", l3);
transform.Dispose();
}
private void PrintOut(AnnUnitConverter converter, string text, AnnPoint pt)
{
Console.WriteLine("{0}{1}({2})",
text,
pt.ConvertTo(converter, AnnUnit.Inch),
pt.ConvertTo(converter, AnnUnit.Pixel));
}
private void PrintOut(AnnUnitConverter converter, string text, AnnPoint[] pts)
{
Console.WriteLine(text);
for (int i = 0; i < pts.Length; i++)
{
Console.WriteLine(" {0}. {1}({2})",
i,
pts[i].ConvertTo(converter, AnnUnit.Inch),
pts[i].ConvertTo(converter, AnnUnit.Pixel));
}
}
private void PrintOut(AnnUnitConverter converter, string text, AnnRectangle rc)
{
Console.WriteLine("{0}{1}({2})",
text,
rc.ConvertTo(converter, AnnUnit.Inch),
rc.ConvertTo(converter, AnnUnit.Pixel));
}
private void PrintOut(AnnUnitConverter converter, string text, AnnLength ln)
{
Console.WriteLine("{0}{1}({2})",
text,
new AnnLength(ln.Converted(converter, AnnUnit.Inch), AnnUnit.Inch),
new AnnLength(ln.Converted(converter, AnnUnit.Pixel), AnnUnit.Pixel));
}
Imports Leadtools
Imports Leadtools.Annotations
Imports Leadtools.Codecs
Imports Leadtools.WinForms
Public Sub AnnTransformer_AnnTransformer()
' set up a new unit converter with 96 DPI
Dim converter As AnnUnitConverter = New AnnUnitConverter(96, 96)
' set up a new matrix, scale it by 2,2 around the origin
Dim transform As Matrix = New Matrix()
transform.Scale(2, 2)
' set up the AnnTransformer
Dim transformer As AnnTransformer = New AnnTransformer(converter, transform)
' declare a new AnnPoint at 4, 5 inches
' transform it to physical coordinate using the transformer and show it in pixels
' then transform it back to its original logical coordinates
Console.WriteLine("Point{0}--------", Environment.NewLine)
Dim pt1 As AnnPoint = New AnnPoint(4, 5, AnnUnit.Inch)
PrintOut(converter, " Original: ", pt1)
Dim pt2 As AnnPoint = transformer.PointToPhysical(pt1)
PrintOut(converter, " Physical: ", pt2)
Dim pt3 As AnnPoint = transformer.PointToLogical(pt2)
PrintOut(converter, " Logical : ", pt3)
' declare an array of AnnPoints, do the same
Console.WriteLine("Points{0}--------", Environment.NewLine)
Dim pts1() As AnnPoint =
{
New AnnPoint(4, 5, AnnUnit.Inch),
New AnnPoint(5.2F, 3, AnnUnit.Inch),
New AnnPoint(2, 7.83F, AnnUnit.Inch)
}
PrintOut(converter, " Original: ", pts1)
Dim pts2 As AnnPoint() = transformer.PointToPhysical(pts1)
PrintOut(converter, " Physical: ", pts2)
Dim pts3 As AnnPoint() = transformer.PointToLogical(pts2)
PrintOut(converter, " Logical : ", pts3)
' declare a rectangle, do the same
Console.WriteLine("Rectangle{0}--------", Environment.NewLine)
Dim rc1 As AnnRectangle = New AnnRectangle(2, 3, 4, 1, AnnUnit.Inch)
PrintOut(converter, " Original: ", rc1)
Dim rc2 As AnnRectangle = transformer.RectangleToPhysical(rc1)
PrintOut(converter, " Physical: ", rc2)
Dim rc3 As AnnRectangle = transformer.RectangleToLogical(rc2)
PrintOut(converter, " Logical : ", rc3)
' declare a length, do the same
Console.WriteLine("Length{0}--------", Environment.NewLine)
Dim l1 As AnnLength = New AnnLength(10.5F, AnnUnit.Inch)
PrintOut(converter, " Original: ", l1)
Dim l2 As AnnLength = transformer.LengthToPhysical(l1)
PrintOut(converter, " Physical: ", l2)
Dim l3 As AnnLength = transformer.LengthToLogical(l2)
PrintOut(converter, " Logical : ", l3)
transform.Dispose()
End Sub
Private Sub PrintOut(ByVal converter As AnnUnitConverter, ByVal text As String, ByVal pt As AnnPoint)
Console.WriteLine("{0}{1}({2})", text, pt.ConvertTo(converter, AnnUnit.Inch), pt.ConvertTo(converter, AnnUnit.Pixel))
End Sub
Private Sub PrintOut(ByVal converter As AnnUnitConverter, ByVal text As String, ByVal pts As AnnPoint())
Console.WriteLine(text)
Dim i As Integer = 0
Do While i < pts.Length
Console.WriteLine(" {0}. {1}({2})", i, pts(i).ConvertTo(converter, AnnUnit.Inch), pts(i).ConvertTo(converter, AnnUnit.Pixel))
i += 1
Loop
End Sub
Private Sub PrintOut(ByVal converter As AnnUnitConverter, ByVal text As String, ByVal rc As AnnRectangle)
Console.WriteLine("{0}{1}({2})", text, rc.ConvertTo(converter, AnnUnit.Inch), rc.ConvertTo(converter, AnnUnit.Pixel))
End Sub
Private Sub PrintOut(ByVal converter As AnnUnitConverter, ByVal text As String, ByVal ln As AnnLength)
Console.WriteLine("{0}{1}({2})", text, New AnnLength(ln.Converted(converter, AnnUnit.Inch), AnnUnit.Inch), New AnnLength(ln.Converted(converter, AnnUnit.Pixel), AnnUnit.Pixel))
End Sub
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET