GXLAYOUT class

class geosoft.gx.GXLAYOUT
Layout class for generic relative layout calculation

The relative layout algorithm allows a logical organization of layout rectangles.
You can set constraints with English-like semantics. For example:

   "Set the left side of rectangle 1 equal to the right side of rectangle 2 plus 10 pixels."
   "Set the bottom of rectangle 1 to 25 percent of the height of rectangle 2."
   "Move node 1 such that its bottom is equal to the top of rectangle 2 minus 10 pixels."

The last constraint set would enjoy priority over any others as it would be
the last one that would influence the rectangle calculations. See the notes for iSetConstraint
for more details.
add_constraint((int)arg1, (int)arg2, (int)arg3, (int)arg4, (float)arg5, (float)arg6) → int:
Add a constraint between any two rectangles or to one with absolute positioning
Parameters:
  • arg1 (int) – From rectangle (Or -1 for parent)
  • arg2 (int) – LAYOUT_CONSTR constants From constraint flag
  • arg3 (int) – To rectangle (Or -1 for parent Or -2 for absolute positioning)
  • arg4 (int) – LAYOUT_CONSTR constants To constraint flag
  • arg5 (float) – Offset modifier
  • arg6 (float) – Multiplicative modifier
Returns:

0 - OK 1 - Error

Return type:

int

New in version 6.3.0.

Note:

Constraints can be applied between 2 rectangles in the layout, or to 1 rectangle with
absolute positioning. Use the constraints to control left, right, bottom, top,
width, height, or centering configurations. Examples:

(ordered as rectangle from, constraint from, rectangle to, constraint to, offset modifier, multiplicative modifier)

A, LAYOUT_CONSTR_LEFT, B, LAYOUT_CONSTR_LEFT, 0, 0, 1.0                             Set left position of A equal to left pos of B
A, LAYOUT_CONSTR_LEFT, B, LAYOUT_CONSTR_RIGHT, 0, 0, 1.0                            Set left pos of A equal to right of B

The offset modifier is used for additive manipulation of constraints
A, LAYOUT_CONSTR_LEFT, B, LAYOUT_CONSTR_LEFT, 10, 0, 1.0                            Set left pos of A equal to left of B, plus 10
A, LAYOUT_CONSTR_BOTTOM, B, LAYOUT_CONSTR_TOP, -20, 0, 1.0                  Set bottom of A equal to top of B, minus 20

Multiplicative manipulation of constraints
A, LAYOUT_CONSTR_WIDTH, B, LAYOUT_CONSTR_WIDTH, 0, 0.5                         Set the width of A equal to 0.5 times the width of B
A, LAYOUT_CONSTR_HEIGHT, B, LAYOUT_CONSTR_WIDTH, 0, 1.2                        Set the height of A equal to 1.2 times the width of B

You can use BOTH the multiplicative and offset modifiers in conjunction (multiplicative gets precedence)
A, LAYOUT_CONSTR_WIDTH, B, LAYOUT_CONSTR_WIDTH, 10, 0.5                        A(width) = (0.5 * B(width)) + 10
A, LAYOUT_CONSTR_LEFT, B, LAYOUT_CONSTR_WIDTH, -20, 0.1                        A(left) = (0.1 * B(width)) + (-20)

If second node is -2, use absolute positioning
A,LAYOUT_CONSTR_LEFT,-2,<ignored>,25,<ignored>,<ignored>                    Position left of A at position 25
A,LAYOUT_CONSTR_WIDTH,-2,<ignored>,30,<ignored>,<ignored>                   Set width of A to 30

Use the MOVE constraints to move an entire window without resizing
A, LAYOUT_CONSTR_MOVEL, B, LAYOUT_CONSTR_LEFT, 0, 0, 1.0                       Move node A, align left with left side of B
A, LAYOUT_CONSTR_MOVEL, B, LAYOUT_CONSTR_RIGHT, 0, 0, 1.0                   Move node A, align left with right side of B
A, LAYOUT_CONSTR_MOVET, B, LAYOUT_CONSTR_WIDTH, 0, 0, 1.0                   Move node A, align bottom to position equal to width of B
A, LAYOUT_CONSTR_MOVER, B, LAYOUT_CONSTR_RIGHT, 10, 1.1                        Move node A, align right to 1.1*right of B, plus 10
A, LAYOUT_CONSTR_MOVEL, NULL, 10, 0, 1.0                                      Move node A, align left at position 10
add_rectangle((float)arg1, (float)arg2, (float)arg3, (float)arg4) → int:
Adds a rectangle as one of the layout's children (Higer.
Parameters:
  • arg1 (float) – Rectangle Min X (All 0’s for undefined allowed)
  • arg2 (float) – Rectangle Min Y
  • arg3 (float) – Rectangle Max X
  • arg4 (float) – Rectangle Max Y
Returns:

Rectangle number, -1 on error

Return type:

int

New in version 6.3.0.

calculate_rects((float_ref)arg1, (float_ref)arg2, (float_ref)arg3, (float_ref)arg4) → None:
Calculate new positions based on initial conditions and constraints
Parameters:
Returns:

Nothing

Return type:

None

New in version 6.3.0.

Note:

Use iGetRectangle to obtain the results for the other rectangles. Depending
on the constraints set the parent rectangle may also change
after the calculation (returned here for convenience).
clear_all() → None:
Remove all children and constraints from layout
Returns:Nothing
Return type:None

New in version 6.3.0.

clear_constraints() → None:
Remove all constraints from layout
Returns:Nothing
Return type:None

New in version 6.3.0.

static create((GXContext)ctx, (int)arg1, (str)arg2) → GXLAYOUT:
Creates a layout calculation object
Parameters:
  • ctx (geosoft.gx.GXContext) – The GX execution context
  • arg1 (int) – Initial number of objects (may be 0)
  • arg2 (str) – Optional name of parent layout (may be empty)
Returns:

LAYOUT object.

Return type:

geosoft.gx.GXLAYOUT

New in version 6.3.0.

get_rect_name((int)arg1, (str_ref)arg2) → None:
Gets an optional name the current info for a rectangle or the parent layout
Parameters:
  • arg1 (int) – Rectangle to get info for (-1 for parent)
  • arg2 (geosoft.gx.str_ref) – Buffer for name of the rectangle
Returns:

Nothing

Return type:

None

New in version 6.3.0.

get_rectangle((int)arg1, (float_ref)arg2, (float_ref)arg3, (float_ref)arg4, (float_ref)arg5) → None:
Gets the current bounds for a rectangle or the parent layout
Parameters:
Returns:

Nothing

Return type:

None

New in version 6.3.0.

is_null() → bool

Check if the instance of geosoft.gx.GXLAYOUT is null (undefined)

Returns:True if this is a null instance of geosoft.gx.GXLAYOUT, False otherwise.
Return type:bool`
static null() → GXLAYOUT

A null (undefined) instance of geosoft.gx.GXLAYOUT

Returns:A null geosoft.gx.GXLAYOUT
Return type:geosoft.gx.GXLAYOUT
num_rectangles() → int:
Returns the number of children in the list.
Returns:Number of rectangles not counting the parent
Return type:int

New in version 6.3.0.

set_rectangle((int)arg1, (float)arg2, (float)arg3, (float)arg4, (float)arg5) → None:
Sets the current bounds for a rectangle previously added to the layout
Parameters:
  • arg1 (int) – Rectangle to set info for (-1 for parent)
  • arg2 (float) – Rectangle Min X
  • arg3 (float) – Rectangle Min Y
  • arg4 (float) – Rectangle Max X
  • arg5 (float) – Rectangle Max Y
Returns:

Nothing

Return type:

None

New in version 6.3.0.

set_rectangle_name((int)arg1, (str)arg2) → None:
Sets an optional name the current info for a rectangle or the parent layout
Parameters:
  • arg1 (int) – Rectangle to set info for (-1 for parent)
  • arg2 (str) – Name
Returns:

Nothing

Return type:

None

New in version 6.3.0.

LAYOUT_CONSTR constants

Layout constraint specifiers
gx.LAYOUT_CONSTR_LEFT = 0
adjust rectangle's left side
gx.LAYOUT_CONSTR_RIGHT = 1
adjust rectangle's right side
gx.LAYOUT_CONSTR_TOP = 2
adjust rectangle's top side
gx.LAYOUT_CONSTR_BOTTOM = 3
adjust rectangle's bottom side
gx.LAYOUT_CONSTR_WIDTH = 4
adjust rectangle's width
gx.LAYOUT_CONSTR_HEIGHT = 5
adjust rectangle's height
gx.LAYOUT_CONSTR_HCENTER = 6
center rectangle with respect to width
gx.LAYOUT_CONSTR_VCENTER = 7
center rectangle with respect to height
gx.LAYOUT_CONSTR_MOVEL = 8
move rectangle, with respect to left
gx.LAYOUT_CONSTR_MOVER = 9
move rectangle, with respect to right
gx.LAYOUT_CONSTR_MOVET = 10
move rectangle, with respect to top
gx.LAYOUT_CONSTR_MOVEB = 11
move rectangle, with respect to bottom