API reference - Class DTrans

Notation used in Ruby API documentation

Module: db

Description: A simple transformation

Simple transformations only provide rotations about angles which a multiples of 90 degree. Together with the mirror options, this results in 8 distinct orientations (fixpoint transformations). These can be combined with a displacement which is applied after the rotation/mirror. This version acts on floating-point coordinates. A version for integer coordinates is Trans.

Here are some examples for using the DTrans class:

t = RBA::DTrans::new(0, 100)  # displacement by 100 DBU in y direction
# the inverse: -> "r0 0,-100"
t.inverted.to_s
# concatenation: -> "r90 -100,0"
(RBA::DTrans::new(RBA::DTrans::R90) * t).to_s
# apply to a point: -> "0,100"
RBA::DTrans::new(RBA::DTrans::R90).trans(RBA::DPoint::new(100, 0))

See The Database API for more details about the database objects.

Public constructors

new DTrans ptrnew(const Trans trans)Creates a floating-point coordinate transformation from an integer coordinate transformation
new DTrans ptrnewCreates a unit transformation
new DTrans ptrnew(const DTrans c,
const DVector u = 0,0)
Creates a transformation from another transformation plus a displacement
new DTrans ptrnew(const DTrans c,
double x,
double y)
Creates a transformation from another transformation plus a displacement
new DTrans ptrnew(int rot,
bool mirr = false,
const DVector u = 0,0)
Creates a transformation using angle and mirror flag
new DTrans ptrnew(int rot,
bool mirr,
double x,
double y)
Creates a transformation using angle and mirror flag and two coordinate values for displacement
new DTrans ptrnew(const DVector u)Creates a transformation using a displacement only
new DTrans ptrnew(double x,
double y)
Creates a transformation using a displacement given as two coordinates

Public methods

[const]bool!=(const DTrans other)Tests for inequality
[const]double*(double d)Transforms a distance
[const]DPoint*(const DPoint p)Transforms a point
[const]DVector*(const DVector v)Transforms a vector
[const]DBox*(const DBox box)Transforms a box
[const]DEdge*(const DEdge edge)Transforms an edge
[const]DPolygon*(const DPolygon polygon)Transforms a polygon
[const]DPath*(const DPath path)Transforms a path
[const]DText*(const DText text)Transforms a text
[const]DTrans*(const DTrans t)Returns the concatenated transformation
[const]bool<(const DTrans other)Provides a 'less' criterion for sorting
[const]bool==(const DTrans other)Tests for equality
void_createEnsures the C++ object is created
void_destroyExplicitly destroys the object
[const]bool_destroyed?Returns a value indicating whether the object was already destroyed
[const]bool_is_const_object?Returns a value indicating whether the reference is a const reference
void_manageMarks the object as managed by the script side.
void_unmanageMarks the object as no longer owned by the script side.
[const]intangleGets the angle in units of 90 degree
voidangle=(int a)Sets the angle in units of 90 degree
voidassign(const DTrans other)Assigns another object to self
[const]doublectrans(double d)Transforms a distance
[const]DVectordispGets to the displacement vector
voiddisp=(const DVector u)Sets the displacement
[const]new DTrans ptrdupCreates a copy of self
[const]unsigned longhashComputes a hash value
DTransinvertInverts the transformation (in place)
[const]DTransinvertedReturns the inverted transformation
[const]boolis_mirror?Gets the mirror flag
voidmirror=(bool m)Sets the mirror flag
[const]introtGets the angle/mirror code
voidrot=(int r)Sets the angle/mirror code
[const]Transto_itype(double dbu = 1)Converts the transformation to an integer coordinate transformation
[const]stringto_s(double dbu = 0)String conversion
[const]DPointtrans(const DPoint p)Transforms a point
[const]DVectortrans(const DVector v)Transforms a vector
[const]DBoxtrans(const DBox box)Transforms a box
[const]DEdgetrans(const DEdge edge)Transforms an edge
[const]DPolygontrans(const DPolygon polygon)Transforms a polygon
[const]DPathtrans(const DPath path)Transforms a path
[const]DTexttrans(const DText text)Transforms a text

Public static methods and constants

DTransM0A constant giving "mirrored at the x-axis" transformation
DTransM135A constant giving "mirrored at the 135 degree axis" transformation
DTransM45A constant giving "mirrored at the 45 degree axis" transformation
DTransM90A constant giving "mirrored at the y (90 degree) axis" transformation
DTransR0A constant giving "unrotated" (unit) transformation
DTransR180A constant giving "rotated by 180 degree counterclockwise" transformation
DTransR270A constant giving "rotated by 270 degree counterclockwise" transformation
DTransR90A constant giving "rotated by 90 degree counterclockwise" transformation
new DTrans ptrfrom_s(string s)Creates a transformation from a string

Deprecated methods (protected, public, static, non-static and constructors)

voidcreateUse of this method is deprecated. Use _create instead
voiddestroyUse of this method is deprecated. Use _destroy instead
[const]booldestroyed?Use of this method is deprecated. Use _destroyed? instead
[static]new DTrans ptrfrom_itrans(const Trans trans)Use of this method is deprecated. Use new instead
[const]boolis_const_object?Use of this method is deprecated. Use _is_const_object? instead

Detailed description

!=

Signature: [const] bool != (const DTrans other)

Description: Tests for inequality

*

(1) Signature: [const] double * (double d)

Description: Transforms a distance

d:The distance to transform
Returns:The transformed distance

The "ctrans" method transforms the given distance. e = t(d). For the simple transformations, there is no magnification and no modification of the distance therefore.

The product '*' has been added as a synonym in version 0.28.

Python specific notes:
This method also implements '__rmul__'.

(2) Signature: [const] DPoint * (const DPoint p)

Description: Transforms a point

p:The point to transform
Returns:The transformed point

The "trans" method or the * operator transforms the given point. q = t(p)

The * operator has been introduced in version 0.25.

Python specific notes:
This method also implements '__rmul__'.

(3) Signature: [const] DVector * (const DVector v)

Description: Transforms a vector

v:The vector to transform
Returns:The transformed vector

The "trans" method or the * operator transforms the given vector. w = t(v)

Vector transformation has been introduced in version 0.25.

Python specific notes:
This method also implements '__rmul__'.

(4) Signature: [const] DBox * (const DBox box)

Description: Transforms a box

box:The box to transform
Returns:The transformed box

't*box' or 't.trans(box)' is equivalent to box.transformed(t).

This convenience method has been introduced in version 0.25.

Python specific notes:
This method also implements '__rmul__'.

(5) Signature: [const] DEdge * (const DEdge edge)

Description: Transforms an edge

edge:The edge to transform
Returns:The transformed edge

't*edge' or 't.trans(edge)' is equivalent to edge.transformed(t).

This convenience method has been introduced in version 0.25.

Python specific notes:
This method also implements '__rmul__'.

(6) Signature: [const] DPolygon * (const DPolygon polygon)

Description: Transforms a polygon

polygon:The polygon to transform
Returns:The transformed polygon

't*polygon' or 't.trans(polygon)' is equivalent to polygon.transformed(t).

This convenience method has been introduced in version 0.25.

Python specific notes:
This method also implements '__rmul__'.

(7) Signature: [const] DPath * (const DPath path)

Description: Transforms a path

path:The path to transform
Returns:The transformed path

't*path' or 't.trans(path)' is equivalent to path.transformed(t).

This convenience method has been introduced in version 0.25.

Python specific notes:
This method also implements '__rmul__'.

(8) Signature: [const] DText * (const DText text)

Description: Transforms a text

text:The text to transform
Returns:The transformed text

't*text' or 't.trans(text)' is equivalent to text.transformed(t).

This convenience method has been introduced in version 0.25.

Python specific notes:
This method also implements '__rmul__'.

(9) Signature: [const] DTrans * (const DTrans t)

Description: Returns the concatenated transformation

t:The transformation to apply before
Returns:The modified transformation

The * operator returns self*t ("t is applied before this transformation").

<

Signature: [const] bool < (const DTrans other)

Description: Provides a 'less' criterion for sorting

This method is provided to implement a sorting order. The definition of 'less' is opaque and might change in future versions.

==

Signature: [const] bool == (const DTrans other)

Description: Tests for equality

M0

Signature: [static] DTrans M0

Description: A constant giving "mirrored at the x-axis" transformation

The previous integer constant has been turned into a transformation in version 0.25.

Python specific notes:
The object exposes a readable attribute 'M0'. This is the getter.

M135

Signature: [static] DTrans M135

Description: A constant giving "mirrored at the 135 degree axis" transformation

The previous integer constant has been turned into a transformation in version 0.25.

Python specific notes:
The object exposes a readable attribute 'M135'. This is the getter.

M45

Signature: [static] DTrans M45

Description: A constant giving "mirrored at the 45 degree axis" transformation

The previous integer constant has been turned into a transformation in version 0.25.

Python specific notes:
The object exposes a readable attribute 'M45'. This is the getter.

M90

Signature: [static] DTrans M90

Description: A constant giving "mirrored at the y (90 degree) axis" transformation

The previous integer constant has been turned into a transformation in version 0.25.

Python specific notes:
The object exposes a readable attribute 'M90'. This is the getter.

R0

Signature: [static] DTrans R0

Description: A constant giving "unrotated" (unit) transformation

The previous integer constant has been turned into a transformation in version 0.25.

Python specific notes:
The object exposes a readable attribute 'R0'. This is the getter.

R180

Signature: [static] DTrans R180

Description: A constant giving "rotated by 180 degree counterclockwise" transformation

The previous integer constant has been turned into a transformation in version 0.25.

Python specific notes:
The object exposes a readable attribute 'R180'. This is the getter.

R270

Signature: [static] DTrans R270

Description: A constant giving "rotated by 270 degree counterclockwise" transformation

The previous integer constant has been turned into a transformation in version 0.25.

Python specific notes:
The object exposes a readable attribute 'R270'. This is the getter.

R90

Signature: [static] DTrans R90

Description: A constant giving "rotated by 90 degree counterclockwise" transformation

The previous integer constant has been turned into a transformation in version 0.25.

Python specific notes:
The object exposes a readable attribute 'R90'. This is the getter.

_create

Signature: void _create

Description: Ensures the C++ object is created

Use this method to ensure the C++ object is created, for example to ensure that resources are allocated. Usually C++ objects are created on demand and not necessarily when the script object is created.

_destroy

Signature: void _destroy

Description: Explicitly destroys the object

Explicitly destroys the object on C++ side if it was owned by the script interpreter. Subsequent access to this object will throw an exception. If the object is not owned by the script, this method will do nothing.

_destroyed?

Signature: [const] bool _destroyed?

Description: Returns a value indicating whether the object was already destroyed

This method returns true, if the object was destroyed, either explicitly or by the C++ side. The latter may happen, if the object is owned by a C++ object which got destroyed itself.

_is_const_object?

Signature: [const] bool _is_const_object?

Description: Returns a value indicating whether the reference is a const reference

This method returns true, if self is a const reference. In that case, only const methods may be called on self.

_manage

Signature: void _manage

Description: Marks the object as managed by the script side.

After calling this method on an object, the script side will be responsible for the management of the object. This method may be called if an object is returned from a C++ function and the object is known not to be owned by any C++ instance. If necessary, the script side may delete the object if the script's reference is no longer required.

Usually it's not required to call this method. It has been introduced in version 0.24.

_unmanage

Signature: void _unmanage

Description: Marks the object as no longer owned by the script side.

Calling this method will make this object no longer owned by the script's memory management. Instead, the object must be managed in some other way. Usually this method may be called if it is known that some C++ object holds and manages this object. Technically speaking, this method will turn the script's reference into a weak reference. After the script engine decides to delete the reference, the object itself will still exist. If the object is not managed otherwise, memory leaks will occur.

Usually it's not required to call this method. It has been introduced in version 0.24.

angle

Signature: [const] int angle

Description: Gets the angle in units of 90 degree

This value delivers the rotation component. In addition, a mirroring at the x axis may be applied before if the is_mirror? property is true.

Python specific notes:
The object exposes a readable attribute 'angle'. This is the getter.

angle=

Signature: void angle= (int a)

Description: Sets the angle in units of 90 degree

a:The new angle

This method was introduced in version 0.20.

Python specific notes:
The object exposes a writable attribute 'angle'. This is the setter.

assign

Signature: void assign (const DTrans other)

Description: Assigns another object to self

create

Signature: void create

Description: Ensures the C++ object is created

Use of this method is deprecated. Use _create instead

Use this method to ensure the C++ object is created, for example to ensure that resources are allocated. Usually C++ objects are created on demand and not necessarily when the script object is created.

ctrans

Signature: [const] double ctrans (double d)

Description: Transforms a distance

d:The distance to transform
Returns:The transformed distance

The "ctrans" method transforms the given distance. e = t(d). For the simple transformations, there is no magnification and no modification of the distance therefore.

The product '*' has been added as a synonym in version 0.28.

Python specific notes:
This method also implements '__rmul__'.

destroy

Signature: void destroy

Description: Explicitly destroys the object

Use of this method is deprecated. Use _destroy instead

Explicitly destroys the object on C++ side if it was owned by the script interpreter. Subsequent access to this object will throw an exception. If the object is not owned by the script, this method will do nothing.

destroyed?

Signature: [const] bool destroyed?

Description: Returns a value indicating whether the object was already destroyed

Use of this method is deprecated. Use _destroyed? instead

This method returns true, if the object was destroyed, either explicitly or by the C++ side. The latter may happen, if the object is owned by a C++ object which got destroyed itself.

disp

Signature: [const] DVector disp

Description: Gets to the displacement vector

Staring with version 0.25 the displacement type is a vector.

Python specific notes:
The object exposes a readable attribute 'disp'. This is the getter.

disp=

Signature: void disp= (const DVector u)

Description: Sets the displacement

u:The new displacement

This method was introduced in version 0.20. Staring with version 0.25 the displacement type is a vector.

Python specific notes:
The object exposes a writable attribute 'disp'. This is the setter.

dup

Signature: [const] new DTrans ptr dup

Description: Creates a copy of self

Python specific notes:
This method also implements '__copy__' and '__deepcopy__'.

from_itrans

Signature: [static] new DTrans ptr from_itrans (const Trans trans)

Description: Creates a floating-point coordinate transformation from an integer coordinate transformation

Use of this method is deprecated. Use new instead

This constructor has been introduced in version 0.25 and replaces the previous static method 'from_itrans'.

Python specific notes:
This method is the default initializer of the object.

from_s

Signature: [static] new DTrans ptr from_s (string s)

Description: Creates a transformation from a string

Creates the object from a string representation (as returned by to_s)

This method has been added in version 0.23.

hash

Signature: [const] unsigned long hash

Description: Computes a hash value

Returns a hash value for the given transformation. This method enables transformations as hash keys.

This method has been introduced in version 0.25.

Python specific notes:
This method is also available as 'hash(object)'.

invert

Signature: DTrans invert

Description: Inverts the transformation (in place)

Returns:The inverted transformation

Inverts the transformation and replaces this object by the inverted one.

inverted

Signature: [const] DTrans inverted

Description: Returns the inverted transformation

Returns:The inverted transformation

Returns the inverted transformation

is_const_object?

Signature: [const] bool is_const_object?

Description: Returns a value indicating whether the reference is a const reference

Use of this method is deprecated. Use _is_const_object? instead

This method returns true, if self is a const reference. In that case, only const methods may be called on self.

is_mirror?

Signature: [const] bool is_mirror?

Description: Gets the mirror flag

If this property is true, the transformation is composed of a mirroring at the x-axis followed by a rotation by the angle given by the angle property.

Python specific notes:
The object exposes a readable attribute 'mirror'. This is the getter.

mirror=

Signature: void mirror= (bool m)

Description: Sets the mirror flag

m:The new mirror flag

"mirroring" describes a reflection at the x-axis which is included in the transformation prior to rotation.

This method was introduced in version 0.20.

Python specific notes:
The object exposes a writable attribute 'mirror'. This is the setter.

new

(1) Signature: [static] new DTrans ptr new (const Trans trans)

Description: Creates a floating-point coordinate transformation from an integer coordinate transformation

This constructor has been introduced in version 0.25 and replaces the previous static method 'from_itrans'.

Python specific notes:
This method is the default initializer of the object.

(2) Signature: [static] new DTrans ptr new

Description: Creates a unit transformation

Python specific notes:
This method is the default initializer of the object.

(3) Signature: [static] new DTrans ptr new (const DTrans c, const DVector u = 0,0)

Description: Creates a transformation from another transformation plus a displacement

c:The original transformation
u:The Additional displacement

Creates a new transformation from a existing transformation. This constructor is provided for creating duplicates and backward compatibility since the constants are transformations now. It will copy the original transformation and add the given displacement.

This variant has been introduced in version 0.25.

Python specific notes:
This method is the default initializer of the object.

(4) Signature: [static] new DTrans ptr new (const DTrans c, double x, double y)

Description: Creates a transformation from another transformation plus a displacement

c:The original transformation
x:The Additional displacement (x)
y:The Additional displacement (y)

Creates a new transformation from a existing transformation. This constructor is provided for creating duplicates and backward compatibility since the constants are transformations now. It will copy the original transformation and add the given displacement.

This variant has been introduced in version 0.25.

Python specific notes:
This method is the default initializer of the object.

(5) Signature: [static] new DTrans ptr new (int rot, bool mirr = false, const DVector u = 0,0)

Description: Creates a transformation using angle and mirror flag

rot:The rotation in units of 90 degree
mirrx:True, if mirrored at x axis
u:The displacement

The sequence of operations is: mirroring at x axis, rotation, application of displacement.

Python specific notes:
This method is the default initializer of the object.

(6) Signature: [static] new DTrans ptr new (int rot, bool mirr, double x, double y)

Description: Creates a transformation using angle and mirror flag and two coordinate values for displacement

rot:The rotation in units of 90 degree
mirrx:True, if mirrored at x axis
x:The horizontal displacement
y:The vertical displacement

The sequence of operations is: mirroring at x axis, rotation, application of displacement.

Python specific notes:
This method is the default initializer of the object.

(7) Signature: [static] new DTrans ptr new (const DVector u)

Description: Creates a transformation using a displacement only

u:The displacement

Python specific notes:
This method is the default initializer of the object.

(8) Signature: [static] new DTrans ptr new (double x, double y)

Description: Creates a transformation using a displacement given as two coordinates

x:The horizontal displacement
y:The vertical displacement

Python specific notes:
This method is the default initializer of the object.

rot

Signature: [const] int rot

Description: Gets the angle/mirror code

The angle/mirror code is one of the constants R0, R90, R180, R270, M0, M45, M90 and M135. rx is the rotation by an angle of x counter clockwise. mx is the mirroring at the axis given by the angle x (to the x-axis).

Python specific notes:
The object exposes a readable attribute 'rot'. This is the getter.

rot=

Signature: void rot= (int r)

Description: Sets the angle/mirror code

r:The new angle/rotation code (see rot property)

This method was introduced in version 0.20.

Python specific notes:
The object exposes a writable attribute 'rot'. This is the setter.

to_itype

Signature: [const] Trans to_itype (double dbu = 1)

Description: Converts the transformation to an integer coordinate transformation

The database unit can be specified to translate the floating-point coordinate transformation in micron units to an integer-coordinate transformation in database units. The transformation's' coordinates will be divided by the database unit.

This method has been introduced in version 0.25.

to_s

Signature: [const] string to_s (double dbu = 0)

Description: String conversion

If a DBU is given, the output units will be micrometers.

The DBU argument has been added in version 0.27.6.

Python specific notes:
This method is also available as 'str(object)'.

trans

(1) Signature: [const] DPoint trans (const DPoint p)

Description: Transforms a point

p:The point to transform
Returns:The transformed point

The "trans" method or the * operator transforms the given point. q = t(p)

The * operator has been introduced in version 0.25.

Python specific notes:
This method also implements '__rmul__'.

(2) Signature: [const] DVector trans (const DVector v)

Description: Transforms a vector

v:The vector to transform
Returns:The transformed vector

The "trans" method or the * operator transforms the given vector. w = t(v)

Vector transformation has been introduced in version 0.25.

Python specific notes:
This method also implements '__rmul__'.

(3) Signature: [const] DBox trans (const DBox box)

Description: Transforms a box

box:The box to transform
Returns:The transformed box

't*box' or 't.trans(box)' is equivalent to box.transformed(t).

This convenience method has been introduced in version 0.25.

Python specific notes:
This method also implements '__rmul__'.

(4) Signature: [const] DEdge trans (const DEdge edge)

Description: Transforms an edge

edge:The edge to transform
Returns:The transformed edge

't*edge' or 't.trans(edge)' is equivalent to edge.transformed(t).

This convenience method has been introduced in version 0.25.

Python specific notes:
This method also implements '__rmul__'.

(5) Signature: [const] DPolygon trans (const DPolygon polygon)

Description: Transforms a polygon

polygon:The polygon to transform
Returns:The transformed polygon

't*polygon' or 't.trans(polygon)' is equivalent to polygon.transformed(t).

This convenience method has been introduced in version 0.25.

Python specific notes:
This method also implements '__rmul__'.

(6) Signature: [const] DPath trans (const DPath path)

Description: Transforms a path

path:The path to transform
Returns:The transformed path

't*path' or 't.trans(path)' is equivalent to path.transformed(t).

This convenience method has been introduced in version 0.25.

Python specific notes:
This method also implements '__rmul__'.

(7) Signature: [const] DText trans (const DText text)

Description: Transforms a text

text:The text to transform
Returns:The transformed text

't*text' or 't.trans(text)' is equivalent to text.transformed(t).

This convenience method has been introduced in version 0.25.

Python specific notes:
This method also implements '__rmul__'.