5.8.4 SizeConstraint objects

SizeConstraint objects can be passed into the constructor of an array slot to constrain its size. There are two variants, the LinearSizeConstraint and the UserSizeConstraint. The former constrains an array slot to a size that linearly depends on the size of another array slot, whereas the latter receives its size from the user.

class LinearSizeConstraint( ctrlslot, a=1, b=0)
This class depends its size linearly on the size of another slot.

ctrlslot is an array slot whose size determines the size of the constraint.

a and b are two coefficients that are used to calculate the constraint size which is $a \cdot s + b$ where s is the size of ctrlslot.

getCoeffs( )
Returns a tuple (a, b) with the current coefficients.

setCoeffs( a, b)
Set new coefficients for the constraint. The operation might raise an exception if the new coefficients are not compatible with another constraint. In this case, the old coefficients remain active.

class UserSizeConstraint( size=0)
This class stores a size that can be manually set by the user.

size is the initial size of the constraint.

setSize( size)
Set a new constraint size. All slots that are constrained by this object will be resized. Note that the operation might fail and an exception is thrown when the resize operation is not allowed (usually because there are other slots involved that are also size constrained).