GLG Toolkit, C / C++ API Library  Version 4.5
Coordinate Conversion

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

Detailed Description

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

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

Functions

GlgObject GlgCreateInversedMatrix (GlgObject matrix)
 Inverts a matrix object. More...
 
GlgObject GlgGetDrawingMatrix (GlgObject object)
 ADVANCED: Returns transformation matrix used to draw the object. More...
 
void GlgGetMatrixData (GlgObject matrix, GlgMatrixData *matrix_data)
 ADVANCED: Queries matrix coefficients. More...
 
GlgBoolean GlgRootToScreenCoord (GlgObject viewport, GlgPoint2 *point)
 Converts screen coordinates relative to the root window to the screen coordinates in the specified viewport. More...
 
GlgBoolean GlgScreenToWorld (GlgObject object, GlgBoolean inside_vp, GlgPoint *in_point, GlgPoint *out_point)
 Converts a point's screen coordinates to the GLG world coordinate system. More...
 
void GlgSetMatrixData (GlgObject matrix, GlgMatrixData *matrix_data)
 ADVANCED: Sets matrix coefficients. More...
 
void GlgTransformPoint (GlgObject matrix, GlgPoint *in_point, GlgPoint *out_point)
 Transforms a single point. More...
 
GlgBoolean GlgTranslatePointOrigin (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...
 
GlgBoolean GlgWorldToScreen (GlgObject object, GlgBoolean 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

◆ GlgCreateInversedMatrix()

GlgObject GlgCreateInversedMatrix ( GlgObject  matrix)

Inverts a matrix object.

Parameters
matrixThe matrix to be inverted.
Returns
The inverse of the input matrix. The returned matrix must be dereferenced using GlgDropObject when not needed any more.

This function may be used to invert the drawing transformation obtained using GlgGetDrawingMatrix. 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.

◆ GlgGetDrawingMatrix()

GlgObject GlgGetDrawingMatrix ( GlgObject  object)

ADVANCED: Returns transformation matrix used to draw the object.

Parameters
objectThe object to query.
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 function may be called only for graphical objects, like polygons, arcs and text objects. This function must be called after the object has been drawn. (That is, after its hierarchy has been set up.)

The function returns the internal matrix object which is valid only immediately after the function call. The matrix should not be modified or destroyed. To prevent the matrix from being destroyed, you may reference it with GlgReferenceObject (and dereference later with GlgDropObject), or, even better, create a copy of it to prevent the matrix 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 GlgGetDrawingMatrix function.

◆ GlgGetMatrixData()

void GlgGetMatrixData ( GlgObject  matrix,
GlgMatrixData matrix_data 
)

ADVANCED: Queries matrix coefficients.

Parameters
matrixThe matrix object to query.
matrix_dataThe structure that will receive the returned matrix coefficients.

See GlgMatrixData for details.

◆ GlgRootToScreenCoord()

GlgBoolean GlgRootToScreenCoord ( GlgObject  viewport,
GlgPoint2 point 
)

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 result is placed back into the structure pointed by this pointer.
Returns
Success or failure status.

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

◆ GlgScreenToWorld()

GlgBoolean GlgScreenToWorld ( GlgObject  object,
GlgBoolean  inside_vp,
GlgPoint in_point,
GlgPoint out_point 
)

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

Parameters
objectThe object whose world coordinate system to convert to. The world coordinate system of an object includes the effect of all drawing transformations attached to the object and all its parents.
inside_vpIf 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 structure that will receive converted world coordinates.
Returns
Success or failure status.

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

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

◆ GlgSetMatrixData()

void GlgSetMatrixData ( GlgObject  matrix,
GlgMatrixData matrix_data 
)

ADVANCED: Sets matrix coefficients.

Parameters
matrixThe matrix object.
matrix_dataThe new matrix's coefficients.

See GlgMatrixData for details.

◆ GlgTransformPoint()

void GlgTransformPoint ( GlgObject  matrix,
GlgPoint in_point,
GlgPoint out_point 
)

Transforms a single point.

Parameters
matrixThe matrix to be applied to the input point.
in_pointThe input point to be transformed.
out_pointThe transformed point.

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

◆ GlgTranslatePointOrigin()

GlgBoolean GlgTranslatePointOrigin ( GlgObject  from_viewport,
GlgObject  to_viewport,
GlgPoint point 
)

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 result is placed back into the structure pointed by this pointer.
Returns
Success or failure status. In the GTK version on Linux, the conversion will fail if the viewports belong to different top level windows, in which case the function will return False.

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

◆ GlgWorldToScreen()

GlgBoolean GlgWorldToScreen ( GlgObject  object,
GlgBoolean  inside_vp,
GlgPoint in_point,
GlgPoint out_point 
)

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

Parameters
objectThe object whose world coordinate system to convert from. The world coordinate system of an object includes the effect of all drawing transformations attached to the object and all its parents.
inside_vp

If 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 structure that will receive converted screen coordinates.
Returns
Success or failure status.

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