GLG Toolkit, C# Class Library  Version 4.6
Coordinate Conversion

This group contains methods for converting coordinate values between the screen and GLG world coordinate systems. More...

Detailed Description

This group contains methods for converting coordinate values between the screen and GLG world coordinate systems.

It also contains methods for handling Matrix objects used by the Toolkit to perform geometrical transformations.

Functions

GlgObject CreateInversedMatrix ()
 ADVANCED: Inverts the matrix object. More...
 
GlgObject GetDrawingMatrix ()
 ADVANCED: Returns transformation matrix used to draw the object. More...
 
GlgMatrixData GetMatrixData (GlgMatrixData matrix_data)
 ADVANCED: Queries matrix coefficients of the matrix. More...
 
static bool RootToScreenCoord (GlgObject viewport, GlgPoint point)
 Converts screen coordinates relative to the root window to the screen coordinates in the specified viewport. More...
 
bool ScreenToWorld (bool inside_vp, GlgPoint in_point, GlgPoint out_point)
 Converts a point's screen coordinates to the GLG world coordinate system. More...
 
void SetMatrixData (GlgMatrixData matrix_data)
 ADVANCED: Sets matrix's coefficients to the supplied values. More...
 
void TransformPoint (GlgPoint in_point, GlgPoint out_point)
 Transforms a single point using the matrix object the method is invoked on. More...
 
static bool TranslatePointOrigin (GlgObject from_viewport, GlgObject to_viewport, GlgPoint point)
 Converts screen coordinates of a point in one viewport to the screen coordinates of another viewport. More...
 
bool WorldToScreen (bool inside_vp, GlgPoint in_point, GlgPoint out_point)
 Converts a point's coordinates from the GLG world coordinate system to the screen coordinate system. More...
 

Function Documentation

◆ CreateInversedMatrix()

GlgObject CreateInversedMatrix ( )

ADVANCED: Inverts the matrix object.

Returns
The inverse of the matrix.

This method may be used to invert the drawing transformation obtained using GetDrawingMatrix. While the drawing transformation converts world to screen coordinates, the inverse of it may be used to convert the screen coordinates of objects and object bounding boxes back to world coordinates.

◆ GetDrawingMatrix()

GlgObject GetDrawingMatrix ( )

ADVANCED: Returns transformation matrix used to draw the object.

Returns
A matrix object that combines matrices of all transformations used to draw the object.

Transformation matrices are only used for geometric transformations, so this method may be called only for graphical objects, like polygons, arcs and text objects. This method must be called after the object has been drawn. (That is, after its hierarchy has been set up.)

The method returns the internal matrix object which is valid only immediately after the method call and should not be modified. To store a matrix for future use, create a copy of it to prevent it from being modified.

Querying the drawing matrix of a viewport returns the drawing matrix used to position the viewport's control points, and not the matrix used to render the objects inside it. To get the drawing matrix the viewport uses to draw objects inside it, query the drawing list of the viewport (the Array resource of the viewport) and use it as a parameter of the GetDrawingMatrix method.

◆ GetMatrixData()

GlgMatrixData GetMatrixData ( GlgMatrixData  matrix_data)

ADVANCED: Queries matrix coefficients of the matrix.

Parameters
matrix_dataThe GlgMatrixData object that will be returned after being filled with matrix data. If null is passed, a new GlgMatrixData object containing matrix data will be returned.
Returns
GlgMatrixData object containing matrix data. See GlgMatrixData for details.

◆ RootToScreenCoord()

static bool RootToScreenCoord ( GlgObject  viewport,
GlgPoint  point 
)
static

Converts screen coordinates relative to the root window to the screen coordinates in the specified viewport.

Parameters
viewportThe viewport whose screen coordinate system to convert to.
pointThe point to be converted. The converted values are placed back into the point.
Returns
Success or failure status.

The viewport's hierarchy must be set up to use this method.

◆ ScreenToWorld()

bool ScreenToWorld ( bool  inside_vp,
GlgPoint  in_point,
GlgPoint  out_point 
)

Converts a point's screen coordinates to the GLG world coordinate system.

The method uses the world coordinate system of the object it is invoked on, which includes the effect of all drawing transformations attached to the object and all its parents.

Parameters
inside_vp

If the object is a viewport or a light viewport, inside_vp specifies which world coordinate system to use:

  • true to will use the world coordinate system used to draw objects inside this viewport object.
  • false, to use the world coordinate system used to draw this viewport object inside its parent viewport.

The value of this parameter is ignored for objects other than a viewport or light viewport.

in_pointThe point to be converted.
out_pointThe point that will receive converted world coordinates.
Returns
Success or failure status.

The object's hierarchy must be set up to use this method.

When converting the cursor position to world coordinates, add COORD_MAPPING_ADJ to the cursor's X and Y screen coordinates for precise mapping.

◆ SetMatrixData()

void SetMatrixData ( GlgMatrixData  matrix_data)

ADVANCED: Sets matrix's coefficients to the supplied values.

Parameters
matrix_dataGlgMatrixData object containing new matrix values.

◆ TransformPoint()

void TransformPoint ( GlgPoint  in_point,
GlgPoint  out_point 
)

Transforms a single point using the matrix object the method is invoked on.

Parameters
in_pointThe input point to be transformed.
out_pointThe transformed point.

This method applies the transformation matrix to the in_point parameter, and returns the result in out_point.

◆ TranslatePointOrigin()

static bool TranslatePointOrigin ( GlgObject  from_viewport,
GlgObject  to_viewport,
GlgPoint  point 
)
static

Converts screen coordinates of a point in one viewport to the screen coordinates of another viewport.

Parameters
from_viewportThe viewport in which the point's screen coordinates are defined.
to_viewportThe viewport whose screen coordinate system to convert to.
pointThe point to be converted. The converted values are placed back into the point.
Returns
Success or failure status.

The objects's hierarchy must be set up to use this method.

◆ WorldToScreen()

bool WorldToScreen ( bool  inside_vp,
GlgPoint  in_point,
GlgPoint  out_point 
)

Converts a point's coordinates from the GLG world coordinate system to the screen coordinate system.

The method uses the world coordinate system of the object it is invoked on, which includes the effect of all drawing transformations attached to the object and all its parents.

Parameters
inside_vp

If the object is a viewport or a light viewport, inside_vp specifies which world coordinate system to use:

  • true to will use the world coordinate system used to draw objects inside this viewport object.
  • false, to use the world coordinate system used to draw this viewport object inside its parent viewport.

The value of this parameter is ignored for objects other than a viewport or light viewport.

in_pointThe point to be converted.
out_pointThe point that will receive converted screen coordinates.
Returns
Success or failure status.

The object's hierarchy must be set up to use this method.