CogDisplay GetTransform Method Cognex VisionPro 9.10
Returns the transform from fromSpace to toSpace.

Namespace: Cognex.VisionPro.Display
Assembly: Cognex.VisionPro.Display.Controls (in Cognex.VisionPro.Display.Controls.dll) Version: 79.0.0.0 (79.0.0.0)
Syntax

public virtual ICogTransform2D GetTransform(
	string toSpace,
	string fromSpace
)

Parameters

toSpace
Type: System String
The destination space.
fromSpace
Type: System String
The source space.

Return Value

Type: ICogTransform2D
Exceptions

ExceptionCondition
AxHost InvalidActiveXStateException Thrown when the display control is invalid.
Remarks

GetTransform(String, String) lets you transform locations between the display's coordinate spaces and screen coordinates (which have the special name "*").

The values that you specify for fromSpace and toSpace must be one of the following:

Examples

private void btnDraw_Click(object sender, System.EventArgs e) {
    CogTransform2DLinear xform;
    CogRectangle aRect;
    CogPointMarker cross = new CogPointMarker();
    double dispX, dispY;
    int    rectIX;

    // Draw a crosshair marker in the center of a rectangle whose coordinate space is "<a href="6511d2e5-0ac6-4821-9069-1cc39c3c0ba5.htm">Cartesian</a>", 
    // but anchor it to the display coordinates ("*") so it does not move when you scroll

    xform = cogDisplay1.GetTransform("*", "Cartesian") as CogTransform2DLinear;

    // Find the interactive rectangle in the graphics group "rect"
    rectIX = cogDisplay1.InteractiveGraphics.FindItem("rect", Cognex.VisionPro.Display.CogDisplayZOrderConstants.Front);
    aRect = cogDisplay1.InteractiveGraphics[rectIX] as CogRectangle;

    // Map the point
    xform.MapPoint(aRect.CenterX, aRect.CenterY, out dispX, out dispY);

    // Draw the cross
    cross.GraphicType = Cognex.VisionPro.CogPointMarkerGraphicTypeConstants.Cross;
    cross.SizeInScreenPixels = 35;
    cross.X = dispX;
    cross.Y = dispY;
    cross.SelectedSpaceName = "*";
    cogDisplay1.StaticGraphics.Add(cross, "cross");
}
See Also