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

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

Detailed Description

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

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

Functions

GlgBoolean FitObject (GlgCoordType coord_type, GlgCube *box, GlgBoolean keep_ratio)
 Fits an object to the specified rectangular area. More...
 
GlgBoolean LayoutObjects (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 MoveObject (GlgCoordType coord_type, GlgPoint *start_point, GlgPoint *end_point)
 Moves an object by a move vector. More...
 
GlgBoolean MoveObjectBy (GlgCoordType coord_type, double x, double y, double z)
 Moves an object by the specified distances. More...
 
GlgBoolean PositionObject (GlgCoordType coord_type, GlgLong anchoring, double x, double y, double z)
 Positions an object at the specified location. More...
 
GlgBoolean RotateObject (GlgCoordType coord_type, GlgPoint *center, double x_angle, double y_angle, double z_angle)
 Rotates an object. More...
 
GlgBoolean ScaleObject (GlgCoordType coord_type, GlgPoint *center, double x_scale, double y_scale, double z_scale)
 Scales an object. More...
 
GlgBoolean TransformObject (GlgObjectC &xform, GlgCoordType coord_type, GlgObjectC *parent=NULL)
 ADVANCED: Transforms all control points of an object with an arbitrary transformation. More...
 

Function Documentation

◆ FitObject()

GlgBoolean FitObject ( GlgCoordType  coord_type,
GlgCube box,
GlgBoolean  keep_ratio 
)

Fits an object to the specified rectangular area.

This is a wrapper for GlgFitObject.

Parameters
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 method 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 method.

◆ LayoutObjects()

GlgBoolean LayoutObjects ( 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.

This is a wrapper for GlgLayoutObjects.

Parameters
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. See GlgLayoutObjects for a list of possible values.
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 control 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 method.

◆ MoveObject()

GlgBoolean MoveObject ( GlgCoordType  coord_type,
GlgPoint start_point,
GlgPoint end_point 
)

Moves an object by a move vector.

This is a wrapper for GlgMoveObject.

Parameters
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 method 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 method.

◆ MoveObjectBy()

GlgBoolean MoveObjectBy ( GlgCoordType  coord_type,
double  x,
double  y,
double  z 
)

Moves an object by the specified distances.

This is a wrapper for GlgMoveObjectBy.

Parameters
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 method 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 method.

◆ PositionObject()

GlgBoolean PositionObject ( GlgCoordType  coord_type,
GlgLong  anchoring,
double  x,
double  y,
double  z 
)

Positions an object at the specified location.

This is a wrapper for GlgPositionObject.

Parameters
coord_typeSpecifies the coordinate system for interpreting position 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_BOTTOM).

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 method positions the object, calculating new control point values. The object's hierarchy must be set up to use this method.

◆ RotateObject()

GlgBoolean RotateObject ( GlgCoordType  coord_type,
GlgPoint center,
double  x_angle,
double  y_angle,
double  z_angle 
)

Rotates an object.

This is a wrapper for GlgRotateObject.

Parameters
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.
Returns
Success or failure status.

This method rotates the object's control points by the specified rotation angles and relative to the specified center, calculating new control point values. If more than one rotation angle is specified, X rotation is applied the first, then Y and Z. The object's hierarchy must be set up to use this method.

◆ ScaleObject()

GlgBoolean ScaleObject ( GlgCoordType  coord_type,
GlgPoint center,
double  x_scale,
double  y_scale,
double  z_scale 
)

Scales an object.

This is a wrapper for GlgScaleObject.

Parameters
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 method 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 method.

◆ TransformObject()

GlgBoolean TransformObject ( GlgObjectC xform,
GlgCoordType  coord_type,
GlgObjectC parent = NULL 
)

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

This is a wrapper for GlgTransformObject.

Parameters
xformThe transformation to be applied to the object's points.
coord_typeThe coordinate system to interpret the transformation in:
  • GLG_SCREEN_COORD - the 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 this object is a G data object representing a control point. NULL may be passed in all other cases.
Returns
Success or failure status.

This method 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 method.