gdshelpers.layout package

Submodules

gdshelpers.layout.grid module

class gdshelpers.layout.grid.GridLayout(title=None, tight=False, region_layer_type='layout', region_layer_on_labels=False, vertical_spacing=10, vertical_alignment=100, horizontal_spacing=10, horizontal_alignment=100, text_size=40, row_text_size=30, line_width=1, align_title_line=True, frame_layer=6, text_layer=7, region_layer=5)

Bases: object

A grid layout class.

This class arranges cells in an ordered matter. It is useful if you want to place several independent devices next to each other.

Parameters:
  • title (str) – Title to be put on the top of the grid layout.
  • tight (bool) – Pack all devices as close as possible along the x-axis.
  • region_layer_type (None, str) – One of None, 'layout' or cell.
  • region_layer_on_labels (bool) – Put a region layer around the labels as well when in cell mode.
  • vertical_spacing (float) – Minimum vertical spacing between devices. The true spacing will be bigger in most cases, since it will align to the next write field.
  • vertical_alignment (float) – Vertical alignment, typically the write field size.
  • horizontal_spacing (float) – Minimum horizontal spacing between devices. The true spacing will be bigger in most cases, since it will align to the next write field.
  • horizontal_alignment (float) – Horizontal alignment, typically the write field size.
  • text_size (float) – Size of the title text.
  • row_text_size (float) – Size of text placed in the rows.
  • line_width (float) – Width of the frame.
  • frame_layer (int) – Layer of the frame. If set to zero, the frame will not be drawn.
  • text_layer (int) – Layer of text
  • region_layer (int) – Layer of the region layer boxes.
add_column_label_row(labels, row_label=None, size=None, alignment='center-top')

Start a new row, containing only labels.

Parameters:
  • labels (tuple, list) – List of labels for each column.
  • row_label – Row label of the new row.
  • size (float) – Size of the text.
  • alignment – Alignment of the labels.
Type:

str, None

add_label_to_row(text, size=None, origin=None, alignment='left-center')

Add a label to the current row.

Parameters:
  • text (str) – Text of the label.
  • size (float) – Size of the label. Defaults to row_text_size.
  • origin – Origin of the text.
  • alignment – Alignment.
add_to_row(cell=None, bbox=None, alignment='left-bottom', realign=True, unique_id=None, allow_region_layer=True)

Add a new cell to the row.

The dimensions of the cell will either be determined directly or can be given via bbox. They determined bounding box always assumes a start at (0, 0) to preserve write field alignment.

If realign is activated, the cell will be shifted, so that the it starts in the first write field quadrant. So if your cell contains structures as (-70, 10) and the write field size is 100, the cell will be shifted to (30, 10).

The alignment of the cell can also be changed, but note that only ‘left-bottom’ guarantees write field alignment. When the region layers are used, these will force an alignment again, though.

The position of each added cell inside the grid can be traced when passing a unique_id while adding the cell.

Parameters:
  • cell – Cell to add.
  • bbox – Bounding box. If None, it will be determined based on cell.
  • alignment – Alignment of the cell inside the grid.
  • realign – Realign the cell, so that it starts in the first positive write field.
  • unique_id – ID to trace where the cell was placed in the final layout.
  • allow_region_layer (bool) – Allow a region layer around the cell.
Type:

gdsCAD.core.Cell

begin_new_row(row_label=None)

Begin a new row.

Parameters:row_label (str) – Label of the row.
generate_layout(cell_name='GRID_LAYOUT')

Generate a layout cell.

Parameters:cell_name – Name of the generated layout cell
Returns:Tuple of a cell, containing the layout and a dictionary mapping each unique id to the position inside the cell.
region_layer_type

gdshelpers.layout.write_field module

gdshelpers.layout.write_field.annotate_write_fields(cell, origin='left-top', end='right-bottom', size=100, layer=4)

Add write field marker lines to a cell.

Write fields are rectangular and typically start at the upper left part of a structure. This function adds write field lines to a given cell. The bounds are either found automatically or can be given as (x, y) tuple.

Alignment options are given as - separated tuple, allowing for combinations of left, right with bottom, top.

Parameters:
  • cell – The cell in which the lines will be added.
  • origin – Origin of the write field markers.
  • end – End of the write field markes. Must not be aligned to the write field, however.
  • size – Size of the write field squares.
  • layer – Layer on which the write field lines are added.

Module contents

class gdshelpers.layout.GridLayout(title=None, tight=False, region_layer_type='layout', region_layer_on_labels=False, vertical_spacing=10, vertical_alignment=100, horizontal_spacing=10, horizontal_alignment=100, text_size=40, row_text_size=30, line_width=1, align_title_line=True, frame_layer=6, text_layer=7, region_layer=5)

Bases: object

A grid layout class.

This class arranges cells in an ordered matter. It is useful if you want to place several independent devices next to each other.

Parameters:
  • title (str) – Title to be put on the top of the grid layout.
  • tight (bool) – Pack all devices as close as possible along the x-axis.
  • region_layer_type (None, str) – One of None, 'layout' or cell.
  • region_layer_on_labels (bool) – Put a region layer around the labels as well when in cell mode.
  • vertical_spacing (float) – Minimum vertical spacing between devices. The true spacing will be bigger in most cases, since it will align to the next write field.
  • vertical_alignment (float) – Vertical alignment, typically the write field size.
  • horizontal_spacing (float) – Minimum horizontal spacing between devices. The true spacing will be bigger in most cases, since it will align to the next write field.
  • horizontal_alignment (float) – Horizontal alignment, typically the write field size.
  • text_size (float) – Size of the title text.
  • row_text_size (float) – Size of text placed in the rows.
  • line_width (float) – Width of the frame.
  • frame_layer (int) – Layer of the frame. If set to zero, the frame will not be drawn.
  • text_layer (int) – Layer of text
  • region_layer (int) – Layer of the region layer boxes.
add_column_label_row(labels, row_label=None, size=None, alignment='center-top')

Start a new row, containing only labels.

Parameters:
  • labels (tuple, list) – List of labels for each column.
  • row_label – Row label of the new row.
  • size (float) – Size of the text.
  • alignment – Alignment of the labels.
Type:

str, None

add_label_to_row(text, size=None, origin=None, alignment='left-center')

Add a label to the current row.

Parameters:
  • text (str) – Text of the label.
  • size (float) – Size of the label. Defaults to row_text_size.
  • origin – Origin of the text.
  • alignment – Alignment.
add_to_row(cell=None, bbox=None, alignment='left-bottom', realign=True, unique_id=None, allow_region_layer=True)

Add a new cell to the row.

The dimensions of the cell will either be determined directly or can be given via bbox. They determined bounding box always assumes a start at (0, 0) to preserve write field alignment.

If realign is activated, the cell will be shifted, so that the it starts in the first write field quadrant. So if your cell contains structures as (-70, 10) and the write field size is 100, the cell will be shifted to (30, 10).

The alignment of the cell can also be changed, but note that only ‘left-bottom’ guarantees write field alignment. When the region layers are used, these will force an alignment again, though.

The position of each added cell inside the grid can be traced when passing a unique_id while adding the cell.

Parameters:
  • cell – Cell to add.
  • bbox – Bounding box. If None, it will be determined based on cell.
  • alignment – Alignment of the cell inside the grid.
  • realign – Realign the cell, so that it starts in the first positive write field.
  • unique_id – ID to trace where the cell was placed in the final layout.
  • allow_region_layer (bool) – Allow a region layer around the cell.
Type:

gdsCAD.core.Cell

begin_new_row(row_label=None)

Begin a new row.

Parameters:row_label (str) – Label of the row.
generate_layout(cell_name='GRID_LAYOUT')

Generate a layout cell.

Parameters:cell_name – Name of the generated layout cell
Returns:Tuple of a cell, containing the layout and a dictionary mapping each unique id to the position inside the cell.
region_layer_type
gdshelpers.layout.annotate_write_fields(cell, origin='left-top', end='right-bottom', size=100, layer=4)

Add write field marker lines to a cell.

Write fields are rectangular and typically start at the upper left part of a structure. This function adds write field lines to a given cell. The bounds are either found automatically or can be given as (x, y) tuple.

Alignment options are given as - separated tuple, allowing for combinations of left, right with bottom, top.

Parameters:
  • cell – The cell in which the lines will be added.
  • origin – Origin of the write field markers.
  • end – End of the write field markes. Must not be aligned to the write field, however.
  • size – Size of the write field squares.
  • layer – Layer on which the write field lines are added.