GLG Toolkit, C / C++ API Library  Version 4.5
Object Geometry and Layout

This group contains functions for positioning objects in the drawing, as well as scaling and rotating them. More...

Detailed Description

This group contains functions for positioning objects in the drawing, as well as scaling and rotating them.

It also includes the GlgLayoutObjects function that can be used to align and distribute objects, as well as to set their width and height.

Functions

GlgBoolean GlgEnableAttachmentPoints (GlgBoolean state)
 Controls the use of attachment points to determine object extents when the objects are aligned. More...
 
GlgBoolean GlgFitObject (GlgObject object, GlgCoordType coord_type, GlgCube *box, GlgBoolean keep_ratio)
 Fits an object to the specified rectangular area. More...
 
GlgBoolean GlgLayoutObjects (GlgObject object, GlgObject anchor, GlgLayoutType type, double distance, GlgBoolean use_box, GlgBoolean process_subobjects)
 Performs operations ranging from setting an object's width and height to aligning and layout of groups of objects. More...
 
GlgBoolean GlgMoveObject (GlgObject object, GlgCoordType coord_type, GlgPoint *start_point, GlgPoint *end_point)
 Moves an object by a move vector. More...
 
GlgBoolean GlgMoveObjectBy (GlgObject object, GlgCoordType coord_type, double x, double y, double z)
 Moves an object by the specified distances. More...
 
GlgBoolean GlgPositionObject (GlgObject object, GlgCoordType coord_type, GlgLong anchoring, double x, double y, double z)
 Positions an object at the specified location. More...
 
GlgBoolean GlgRotateObject (GlgObject object, GlgCoordType coord_type, GlgPoint *center, double x_angle, double y_angle, double z_angle)
 Rotates an object. More...
 
GlgBoolean GlgScaleObject (GlgObject object, GlgCoordType coord_type, GlgPoint *center, double x_scale, double y_scale, double z_scale)
 Scales an object. More...
 
GlgBoolean GlgTransformObject (GlgObject object, GlgObject xform, GlgCoordType coord_type, GlgObject parent)
 ADVANCED: Transforms all control points of an object with an arbitrary transformation. More...
 

Function Documentation

◆ GlgEnableAttachmentPoints()

GlgBoolean GlgEnableAttachmentPoints ( GlgBoolean  state)

Controls the use of attachment points to determine object extents when the objects are aligned.

Parameters
stateSpecifies if attachment points should be used in addition to the control points to determine object extents when the objects are aligned using control points.
Returns
The previous state of the setting.

◆ GlgFitObject()

GlgBoolean GlgFitObject ( GlgObject  object,
GlgCoordType  coord_type,
GlgCube box,
GlgBoolean  keep_ratio 
)

Fits an object to the specified rectangular area.

Parameters
objectThe object to fit.
coord_typeSpecifies the coordinate system for interpreting coordinates of the area to fit to:
  • GLG_SCREEN_COORD - the coordinates are interpreted as screen pixels.
  • GLG_OBJECT_COORD - the coordinates are interpreted as the GLG world coordinates of the object, which includes all transformations applied to the object.
  • GLG_PARENT_COORD - the coordinates are interpreted as the GLG world coordinates of the parent object, which includes all transformations applied to the parent, but excludes transformations attached to the object.
boxThe area to fit the object to.
  • If the Z extent of the box is 0, 2D fitting is performed and the object is not scaled in the Z dimension.
  • If the Z extent is not 0, 3D fitting is performed.
keep_ratioControls how the object's X/Y ratio is handled:
  • True to preserve the object's X/Y ratio by using the smallest of the required X and Y scale factors for both directions.
  • False to use different scale factors for X and Y scaling to fit the object to the box more precisely.
Returns
Success or failure status.

This function transforms the object to fit it to the area defined by the box parameter, calculating new control point values. The object's hierarchy must be set up to use this function.

◆ GlgLayoutObjects()

GlgBoolean GlgLayoutObjects ( GlgObject  object,
GlgObject  anchor,
GlgLayoutType  type,
double  distance,
GlgBoolean  use_box,
GlgBoolean  process_subobjects 
)

Performs operations ranging from setting an object's width and height to aligning and layout of groups of objects.

Parameters
objectThe object or the group of objects to perform the requested operations upon.
anchorThe anchor object for alignment operations. If NULL, the first encountered object in the specified alignment direction is used.
typeThe type of the layout action to perform:
  • GLG_ALIGN_LEFT - aligns the left edge of elements within the group with the left edge of the anchor element.
  • GLG_ALIGN_RIGHT - aligns the right edge of elements within the group with the right edge of the anchor element.
  • GLG_ALIGN_HCENTER - aligns the center of elements within the group with the center of the anchor element horizontally.
  • GLG_ALIGN_TOP - aligns the top edge of elements within the group with the top edge of the anchor element.
  • GLG_ALIGN_BOTTOM - aligns the bottom edge of elements within the group with the bottom edge of the anchor element.
  • GLG_ALIGN_VCENTER - aligns the center of elements within the group with the center of the anchor element vertically.
  • GLG_SET_EQUAL_VSIZE - sets the height of elements within the group to the height of the anchor.
  • GLG_SET_EQUAL_HSIZE - sets the width of elements within the group to the width of the anchor.
  • GLG_SET_EQUAL_SIZE - sets the width and height of elements within the group to the width and height of the anchor.
  • GLG_SET_EQUAL_VDISTANCE - equally distributes the group's elements in vertical direction as measured by the distance between their centers.
  • GLG_SET_EQUAL_HDISTANCE - equally distributes the group's elements in horizontal direction as measured by the distance between their centers.
  • GLG_SET_EQUAL_VSPACE - equally distributes space gaps between group's elements in vertical direction.
  • GLG_SET_EQUAL_HSPACE - equally distributes space gaps between group's elements in horizontal direction.
  • GLG_SET_VSIZE - sets the height of an object or of all objects in the object group to the value specified by the distance parameter:
    • if process_subobjects=False, sets the object's height
    • if process_subobjects=True, sets the height of all elements within the object group.
  • GLG_SET_HSIZE - sets the width of the object or of all objects in the object group to the value specified by the distance parameter:
    • if process_subobjects=False, sets the object's width
    • if process_subobjects=True, sets the width of all elements within the object group.
  • GLG_SET_VDISTANCE - sets the vertical distance between centers of the group's elements to a value specified by the distance parameter.
  • GLG_SET_HDISTANCE - sets the horizontal distance between centers of the group's elements to a value specified by the distance parameter.
  • GLG_SET_VSPACE - sets the space gaps between group's elements in vertical direction to a value specified by the distance parameter.
  • GLG_SET_HSPACE - sets space gaps between group's elements in horizontal direction to a value specified by the distance parameter.
distanceThe distance in screen coordinates for positioning objects, it is interpreted depending on the layout action.
use_boxControls how the objects extent is determined:
  • True to use the object's real bounding box to align objects
  • False to use the object's control points to determine the object's extent, which could be different from the real bounding box for objects such as a Text object with a single conrol point.
process_subobjectsControls how to apply the layout action if the object is a group:
  • True to apply the action to all objects contained in the group
  • False the apply the action (such as GLG_SET_HSIZE) to the group itself.
Returns
  • False if errors were encountered during the requested layout action,
  • True if the requested action was successfully executed.

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

◆ GlgMoveObject()

GlgBoolean GlgMoveObject ( GlgObject  object,
GlgCoordType  coord_type,
GlgPoint start_point,
GlgPoint end_point 
)

Moves an object by a move vector.

Parameters
objectThe object to move.
coord_typeSpecifies the coordinate system for interpreting the move vector:
  • GLG_SCREEN_COORD - the move vector is considered to be defined using screen pixels.
  • GLG_OBJECT_COORD - the move vector coordinates are interpreted in the GLG world coordinates of the object, which includes all transformations applied to the object.
  • GLG_PARENT_COORD - the move vector coordinates are interpreted in the GLG world coordinates of the parent object, which includes all transformations applied to the parent, but excludes transformations attached to the object.
start_pointThe start point of the move vector. If NULL, (0,0,0) is used as the start point.
end_pointThe end point of the move vector.
Returns
Success or failure status.

This function moves an object's control points by the distance defined by the move vector, calculating new control point values. The object's hierarchy must be set up to use this function.

◆ GlgMoveObjectBy()

GlgBoolean GlgMoveObjectBy ( GlgObject  object,
GlgCoordType  coord_type,
double  x,
double  y,
double  z 
)

Moves an object by the specified distances.

Parameters
objectThe object to move.
coord_typeSpecifies the coordinate system for interpreting move distances:
  • GLG_SCREEN_COORD - move distances are considered to be in screen pixels.
  • GLG_OBJECT_COORD - move distances are considered to be in the GLG world coordinates of the object, which includes all transformations applied to the object.
  • GLG_PARENT_COORD - move distances are considered to be in the GLG world coordinates of the parent object, which includes all transformations applied to the parent, but excludes transformations attached to the object.
x,y,zThe X, Y and Z move distances.
Returns
Success or failure status.

This function moves an object's control points by the specified X, Y and Z distances, calculating new control point values. The object's hierarchy must be set up to use this function.

◆ GlgPositionObject()

GlgBoolean GlgPositionObject ( GlgObject  object,
GlgCoordType  coord_type,
GlgLong  anchoring,
double  x,
double  y,
double  z 
)

Positions an object at the specified location.

Parameters
objectThe object to position.
coord_typeSpecifies the coordinate system for interpreting postion coordinates:
  • GLG_SCREEN_COORD - the coordinates are interpreted as screen pixels.
  • GLG_OBJECT_COORD - the coordinates are interpreted as the GLG world coordinates of the object, which includes all transformations applied to the object.
  • GLG_PARENT_COORD - the coordinates are interpreted as the GLG world coordinates of the parent object, which includes all transformations applied to the parent, but excludes transformations attached to the object.
anchoring

Specifies what part of the object's bounding box will be anchored at the specified position. It is formed as a bitwise OR of the horizontal anchoring constant (GLG_HLEFT, GLG_HCENTER or GLG_HRIGHT) with the vertical anchoring constants (GLG_VTOP, GLG_VCENTER or GLG_VBOTTOM).

For example, using ( GLG_VTOP | GLG_HLEFT ) causes the upper left corner of the object's bounding box to be positioned at the specified location.

x,y,zThe X, Y and Z coordinates of the desired object position.
Returns
Success or failure status.

This function positions the object, calculating new control point values. The object's hierarchy must be set up to use this function.

◆ GlgRotateObject()

GlgBoolean GlgRotateObject ( GlgObject  object,
GlgCoordType  coord_type,
GlgPoint center,
double  x_angle,
double  y_angle,
double  z_angle 
)

Rotates an object.

Parameters
objectThe object to rotate.
coord_typeSpecifies the coordinate system for interpreting the rotation's center:
  • GLG_SCREEN_COORD - the rotation's center coordinates are interpreted as screen pixels.
  • GLG_OBJECT_COORD - the rotation's center coordinates are interpreted as the GLG world coordinates of the object, which includes all transformations applied to the object.
  • GLG_PARENT_COORD - the rotation's center coordinates are interpreted as the GLG world coordinates of the parent object, which includes all transformations applied to the parent, but excludes transformations attached to the object.
centerThe center of rotation. If the parameter is NULL, the object is rotated relative to the center of its bounding box.
x_angle,y_angle,z_angleThe X, Y and Z rotation angles in degrees. Only one rotation at a time can be performed (only one angle can have non-zero value).
Returns
Success or failure status.

This function rotates the object's control points by the specified rotation angles and relative to the specified center, calculating new control point values. The object's hierarchy must be set up to use this function.

◆ GlgScaleObject()

GlgBoolean GlgScaleObject ( GlgObject  object,
GlgCoordType  coord_type,
GlgPoint center,
double  x_scale,
double  y_scale,
double  z_scale 
)

Scales an object.

Parameters
objectThe object to scale.
coord_typeSpecifies the coordinate system for interpreting the scale center:
  • GLG_SCREEN_COORD - the scale center coordinates are interpreted as screen pixels.
  • GLG_OBJECT_COORD - the scale center coordinates are interpreted as the GLG world coordinates of the object, which includes all transformations applied to the object.
  • GLG_PARENT_COORD - the scale center coordinates are interpreted as the GLG world coordinates of the parent object, which includes all transformations applied to the parent, but excludes transformations attached to the object.
centerThe center of scaling. If the parameter is NULL, the object is scaled relative to the center of its bounding box.
x_scale,y_scale,z_scaleThe X, Y and Z scaling factors. Use the same value for all three factors to scale the object uniformly in all dimensions.
Returns
Success or failure status.

This function scales the object's control points by the specified scale factors and relative to the specified center, calculating new control point values. The object's hierarchy must be set up to use this function.

◆ GlgTransformObject()

GlgBoolean GlgTransformObject ( GlgObject  object,
GlgObject  xform,
GlgCoordType  coord_type,
GlgObject  parent 
)

ADVANCED: Transforms all control points of an object with an arbitrary transformation.

Parameters
objectThe object to transform: a drawable object or a G data object representing a control point.
xformThe transformation (a GLG_XFORM object) to be applied to the object's points.
coord_typeThe coordinate system to interpret the transformation in:
  • GLG_SCREEN_COORD - parameters of the transformation are considered to be in screen pixels.
    For example, this may be used to move the object by the number of screen pixels as defined by the mouse move. The start and end coordinates of the mouse move can be supplied using the GLG_TRANSLATE_XF transformation as the xform parameter.
  • GLG_OBJECT_COORD - transformation parameters are interpreted in the GLG world coordinates of the object, which includes all transformations applied to the object.
  • GLG_PARENT_COORD - transformation parameters are interpreted in the GLG world coordinates of the parent object, which includes all transformations applied to the parent, but excludes transformations attached to the object.
parentThe object's parent. It is required if coord_type=GLG_PARENT_COORD, or if the object is a G data object representing a control point. NULL may be passed in all other cases.
Returns
Success or failure status.

This function applies the given transformation to an object's control points, calculating new control point values. The object's hierarchy must be set up to use this function.