GXLAYOUT class¶
-
class
GXLAYOUT
(handle=0)¶ GXLAYOUT class.
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
(rect_from, constr_from, rect_to, constr_to, o_mod, m_mod)¶ Add a constraint between any two rectangles or to one with absolute positioning
Parameters: - rect_from (int) – From rectangle (Or -1 for parent)
- constr_from (int) – LAYOUT_CONSTR constants From constraint flag
- rect_to (int) – To rectangle (Or -1 for parent Or -2 for absolute positioning)
- constr_to (int) – LAYOUT_CONSTR constants To constraint flag
- o_mod (float) – Offset modifier
- m_mod (float) – Multiplicative modifier
Returns: 0 - OK 1 - Error
Return type: int
New in version 6.3.
License: Geosoft End-User License
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 BThe 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 20Multiplicative 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 BYou 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 <geosoft.gxapi.LAYOUT_CONSTR_LEFT>`,-2,<ignored>,25,<ignored>,<ignored> Position left of A at position 25 A,`LAYOUT_CONSTR_WIDTH <geosoft.gxapi.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
(min_x, min_y, max_x, max_y)¶ Adds a rectangle as one of the layout’s children (Higer.
Parameters: - min_x (float) – Rectangle Min X (All 0’s for undefined allowed)
- min_y (float) – Rectangle Min Y
- max_x (float) – Rectangle Max X
- max_y (float) – Rectangle Max Y
Returns: Rectangle number, -1 on error
Return type: int
New in version 6.3.
License: Geosoft End-User License
-
calculate_rects
(min_x, min_y, max_x, max_y)¶ Calculate new positions based on initial conditions and constraints
Parameters: New in version 6.3.
License: Geosoft End-User License
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
()¶ Remove all children and constraints from layout
New in version 6.3.
License: Geosoft End-User License
-
clear_constraints
()¶ Remove all constraints from layout
New in version 6.3.
License: Geosoft End-User License
-
classmethod
create
(num, name)¶ Creates a layout calculation object
Parameters: - num (int) – Initial number of objects (may be 0)
- name (str) – Optional name of parent layout (may be empty)
Returns: GXLAYOUT
object.Return type: New in version 6.3.
License: Geosoft End-User License
-
get_rect_name
(rect, name)¶ Gets an optional name the current info for a rectangle or the parent layout
Parameters: - rect (int) – Rectangle to get info for (-1 for parent)
- name (str_ref) – Buffer for name of the rectangle
New in version 6.3.
License: Geosoft End-User License
-
get_rectangle
(rect, min_x, min_y, max_x, max_y)¶ Gets the current bounds for a rectangle or the parent layout
Parameters: New in version 6.3.
License: Geosoft End-User License
-
is_null
()¶ Check if this is a null (undefined) instance
Returns: True if this is a null (undefined) instance, False otherwise. Return type: bool
-
classmethod
null
()¶ A null (undefined) instance of
GXLAYOUT
Returns: A null GXLAYOUT
Return type: GXLAYOUT
-
num_rectangles
()¶ Returns the number of children in the list.
Returns: Number of rectangles not counting the parent Return type: int New in version 6.3.
License: Geosoft End-User License
-
set_rectangle
(rect, min_x, min_y, max_x, max_y)¶ Sets the current bounds for a rectangle previously added to the layout
Parameters: - rect (int) – Rectangle to set info for (-1 for parent)
- min_x (float) – Rectangle Min X
- min_y (float) – Rectangle Min Y
- max_x (float) – Rectangle Max X
- max_y (float) – Rectangle Max Y
New in version 6.3.
License: Geosoft End-User License
-
set_rectangle_name
(rect, p3)¶ Sets an optional name the current info for a rectangle or the parent layout
Parameters: - rect (int) – Rectangle to set info for (-1 for parent)
- p3 (str) – Name
New in version 6.3.
License: Geosoft End-User License
-
LAYOUT_CONSTR constants¶
Layout constraint specifiers
-
LAYOUT_CONSTR_LEFT
¶ Adjust rectangle’s left side
-
gxapi.
LAYOUT_CONSTR_LEFT
= 0
-
-
LAYOUT_CONSTR_RIGHT
¶ Adjust rectangle’s right side
-
gxapi.
LAYOUT_CONSTR_RIGHT
= 1
-
-
LAYOUT_CONSTR_TOP
¶ Adjust rectangle’s top side
-
gxapi.
LAYOUT_CONSTR_TOP
= 2
-
-
LAYOUT_CONSTR_BOTTOM
¶ Adjust rectangle’s bottom side
-
gxapi.
LAYOUT_CONSTR_BOTTOM
= 3
-
-
LAYOUT_CONSTR_WIDTH
¶ Adjust rectangle’s width
-
gxapi.
LAYOUT_CONSTR_WIDTH
= 4
-
-
LAYOUT_CONSTR_HEIGHT
¶ Adjust rectangle’s height
-
gxapi.
LAYOUT_CONSTR_HEIGHT
= 5
-
-
LAYOUT_CONSTR_HCENTER
¶ Center rectangle with respect to width
-
gxapi.
LAYOUT_CONSTR_HCENTER
= 6
-
-
LAYOUT_CONSTR_VCENTER
¶ Center rectangle with respect to height
-
gxapi.
LAYOUT_CONSTR_VCENTER
= 7
-
-
LAYOUT_CONSTR_MOVEL
¶ Move rectangle, with respect to left
-
gxapi.
LAYOUT_CONSTR_MOVEL
= 8
-
-
LAYOUT_CONSTR_MOVER
¶ Move rectangle, with respect to right
-
gxapi.
LAYOUT_CONSTR_MOVER
= 9
-
-
LAYOUT_CONSTR_MOVET
¶ Move rectangle, with respect to top
-
gxapi.
LAYOUT_CONSTR_MOVET
= 10
-
-
LAYOUT_CONSTR_MOVEB
¶ Move rectangle, with respect to bottom
-
gxapi.
LAYOUT_CONSTR_MOVEB
= 11
-