KLayout Manual: Main Index » Class Index » API reference - Class LayerMap

API reference - Class LayerMap

Notation used in Ruby API documentation

Description: An object representing an arbitrary mapping of physical layers to logical layers

"Physical" layers are stream layers or other separated layers in a CAD file. "Logical" layers are the layers present in a Layout object. Logical layers are represented by an integer index while physical layers are given by a layer and datatype number or name. A logical layer is created automatically in the layout on reading if it does not exist yet.

The mapping describes an association of a set of physical layers to a set of logical ones, where multiple physical layers can be mapped to a single logical one, which effectively merges the layers.

This class has been introduced in version 0.18.

Public constructors

LayerMapnewCreates a new object of this class

Public methods

[const]voidassign(const LayerMap other)Assign the contents of another object to self
voidclearClears the map.
voidcreateEnsures the C++ object is created
voiddestroyExplicitly destroy the object
[const]booldestroyed?Returns a value indicating whether the object was already destroyed
[const]LayerMapdupCreates a copy of self
[const]boolis_const_object?Returns a value indicating whether the reference is a const reference
[const]boolis_mapped?(const LayerInfo layer The physical layer specified with an \LayerInfo object.)Check, if a given physical layer is mapped.
[const]intlogical(const LayerInfo layer)Returns the logical layer (the layer index in the layout object) for a given physical layer.
voidmap(const LayerInfo phys_layer,
unsigned int log_layer)
Maps a physical layer to a logical one.
voidmap(const LayerInfo phys_layer,
unsigned int log_layer,
const LayerInfo target_layer)
Maps a physical layer to a logical one with a target layer.
voidmap(const LayerInfo pl_start,
const LayerInfo pl_stop,
unsigned int log_layer)
Maps a physical layer interval to a logical one.
voidmap(const LayerInfo pl_start,
const LayerInfo pl_stop,
unsigned int log_layer,
const LayerInfo arg4)
Maps a physical layer interval to a logical one with a target layer.
voidmap(string map_expr,
unsigned int log_layer)
Maps a physical layer given by a string to a logical one.
[const]LayerInfomapping(unsigned int log_layer)Returns the mapped physical (or target if one is specified) layer for a given logical layer.
[const]stringmapping_str(unsigned int log_layer)Returns the mapping string for a given logical layer.

Detailed description

[const] void assign(const LayerMap other)

Description: Assign the contents of another object to self

This method assigns the contents of another object to self. This is a deep copy that does not only copy the reference but the actual content.

void clear

Description: Clears the map.

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.

void destroy

Description: Explicitly destroy the object

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

[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.

[const] LayerMap dup

Description: Creates a copy of self

[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.

[const] bool is_mapped?(const LayerInfo layer The physical layer specified with an \LayerInfo object.)

Description: Check, if a given physical layer is mapped.

Returns:True, if the layer is mapped.

[const] int logical(const LayerInfo layer)

Description: Returns the logical layer (the layer index in the layout object) for a given physical layer.

layer:The physical layer specified with an LayerInfo object.
Returns:The logical layer index or -1 if the layer is not mapped.

void map(const LayerInfo phys_layer,unsigned int log_layer)

Description: Maps a physical layer to a logical one.

phys_layer:The physical layer (a LayerInfo object).
log_layer:The logical layer to which the physical layer is mapped.

In general, there may be more than one physical layer mapped to one logical layer. This method will add the given physical layer to the mapping for the logical layer.

void map(const LayerInfo phys_layer,unsigned int log_layer,const LayerInfo target_layer)

Description: Maps a physical layer to a logical one with a target layer.

phys_layer:The physical layer (a LayerInfo object).
log_layer:The logical layer to which the physical layer is mapped.
target_layer:The properties of the layer that will be created unless it already exists.

In general, there may be more than one physical layer mapped to one logical layer. This method will add the given physical layer to the mapping for the logical layer.

This method has been added in version 0.20.

void map(const LayerInfo pl_start,const LayerInfo pl_stop,unsigned int log_layer)

Description: Maps a physical layer interval to a logical one.

pl_start:The first physical layer (a LayerInfo object).
pl_stop:The last physical layer (a LayerInfo object).
log_layer:The logical layer to which the physical layers are mapped.

This method maps an interval of layers l1..l2 and datatypes d1..d2 to the mapping for the given logical layer. l1 and d1 are given by the pl_start argument, while l2 and d2 are given by the pl_stop argument.

void map(const LayerInfo pl_start,const LayerInfo pl_stop,unsigned int log_layer,const LayerInfo arg4)

Description: Maps a physical layer interval to a logical one with a target layer.

pl_start:The first physical layer (a LayerInfo object).
pl_stop:The last physical layer (a LayerInfo object).
log_layer:The logical layer to which the physical layers are mapped.
target_layer:The properties of the layer that will be created unless it already exists.

This method maps an interval of layers l1..l2 and datatypes d1..d2 to the mapping for the given logical layer. l1 and d1 are given by the pl_start argument, while l2 and d2 are given by the pl_stop argument. This method has been added in version 0.20.

void map(string map_expr,unsigned int log_layer)

Description: Maps a physical layer given by a string to a logical one.

map_expr:The string describing the physical layer to map.
log_layer:The logical layer to which the physical layers are mapped.

The string expression is constructed using the syntax: "list[/list][;..]" for layer/datatype pairs. "list" is a sequence of numbers, separated by comma values or a range separated by a hyphen. Examples are: "1/2", "1-5/0", "1,2,5/0", "1/5;5/6".

A target layer can be specified with the ":<target>" notation where the target is a valid layer specification string (i.e. "1/0").

Target mapping has been added in version 0.20.

[const] LayerInfo mapping(unsigned int log_layer)

Description: Returns the mapped physical (or target if one is specified) layer for a given logical layer.

log_layer:The logical layer for which the mapping is requested.
Returns:A LayerInfo object which is the physical layer mapped to the logical layer.

In general, there may be more than one physical layer mapped to one logical layer. This method will return a single one of them. It will return the one with the lowest layer and datatype.

[const] string mapping_str(unsigned int log_layer)

Description: Returns the mapping string for a given logical layer.

log_layer:The logical layer for which the mapping is requested.
Returns:A string describing the mapping.

The mapping string is compatible with the string that the "map" method accepts.

[static] LayerMap new

Description: Creates a new object of this class