QGDSRenderer¶
- class QGDSRenderer(design: QDesign, initiate=True, render_template: Dict | None = None, render_options: Dict | None = None)[source]¶
Extends QRenderer to export GDS formatted files. The methods which a user will need for GDS export should be found within this class.
All chips within design should be exported to one gds file. For the “subtraction box”: 1. If user wants to export the entire design, AND if the base class of QDesign._chips[chip_name][‘size’] has dict following below example: {‘center_x’: 0.0, ‘center_y’: 0.0, ‘size_x’: 9, ‘size_y’: 6} then this box will be used for every layer within a chip.
2. If user wants to export entire design, BUT there is no information in QDesign._chips[chip_name][‘size’], then the renderer will calculate the size of all of the components and use that size for the “subtraction box” for every layer within a chip.
3. If user wants to export a list of explicit components, the bounding box will be calculated by size of QComponents in the QGeometry table. Then be scaled by bounding_box_scale_x and bounding_box_scale_y.
4. Note: When using the Junction table, the cell for Junction should be “x-axis” aligned and then GDS rotates based on LineString given in Junction table.
- datatype:
10 Polygon
11 Flexpath
- Default Options:
short_segments_to_not_fillet: ‘True’
check_short_segments_by_scaling_fillet: ‘2.0’
gds_unit: ‘1’
ground_plane: ‘True’
negative_mask: Dict(main=[])
corners: ‘natural’
tolerance: ‘0.00001’
precision: ‘0.000000001’
width_LineString: ‘10um’
path_filename: ‘../resources/Fake_Junctions.GDS’
junction_pad_overlap: ‘5um’
max_points: ‘199’
fabricate: ‘False’
- cheese: Dict
datatype: ‘100’
shape: ‘0’
cheese_0_x: ‘50um’
cheese_0_y: ‘50um’
cheese_1_radius: ‘100um’
delta_x=’100um’,
delta_y=’100um’,
edge_nocheese=’200um’,
view_in_file: Dict(main={1: True})
- no_cheese: Dict
datatype: ‘99’
buffer: ‘25um’
cap_style: ‘2’
join_style: ‘2’
view_in_file: Dict(main={1: True})
bounding_box_scale_x: ‘1.2’
bounding_box_scale_y: ‘1.2’
Create a QRenderer for GDS interface: export and import.
- Parameters:
design (QDesign) – Use QGeometry within QDesign to obtain elements for GDS file.
initiate (bool, optional) – True to initiate the renderer. Defaults to True.
render_template (Dict, optional) – Typically used by GUI for template options for GDS. Defaults to None.
render_options (Dict, optional) – Used to override all options. Defaults to None.
Attributes
- default_options = {'bounding_box_scale_x': '1.2', 'bounding_box_scale_y': '1.2', 'check_short_segments_by_scaling_fillet': '2.0', 'cheese': {'cheese_0_x': '25um', 'cheese_0_y': '25um', 'cheese_1_radius': '100um', 'datatype': '100', 'delta_x': '100um', 'delta_y': '100um', 'edge_nocheese': '200um', 'shape': '0', 'view_in_file': {'main': {1: True}}}, 'corners': 'natural', 'fabricate': 'False', 'gds_unit': '1', 'ground_plane': 'True', 'junction_pad_overlap': '5um', 'max_points': '199', 'negative_mask': {'main': []}, 'no_cheese': {'buffer': '25um', 'cap_style': '2', 'datatype': '99', 'join_style': '2', 'view_in_file': {'main': {1: True}}}, 'path_filename': '../resources/Fake_Junctions.GDS', 'precision': '0.000000001', 'short_segments_to_not_fillet': 'True', 'tolerance': '0.00001', 'width_LineString': '10um'}¶
Default options
- design¶
Return a reference to the parent design object.
- element_extensions = {}¶
Element extensions dictionary
- element_table_data = {'junction': {'cell_name': 'my_other_junction'}}¶
Element table data
- logger¶
Returns the logger.
- name = 'gds'¶
Name
- options¶
Options for the QRenderer.
Methods
- add_table_data_to_QDesign(class_name: str)¶
During init of renderer, this needs to happen. In particular, each renderer needs to update custom columns and values within QDesign.
- Parameters:
class_name (str) – Name from cls.name for each renderer.
- static debug_summarize_gds_library(lib: Library, show=False, scale: float = 100.0, width: int = 800) None[source]¶
Print a concise summary report for a gdstk.Library.
The summary includes:
Library metadata (name, unit, precision, number of cells).
Cell names and whether they have geometry.
- Per (layer, datatype) statistics:
number of polygons
number of paths
- Parameters:
lib – Loaded gdstk.Library instance.
show – If True, render and display the library as an SVG in Jupyter.
scale – SVG coordinate scaling factor. Increase for larger / more detailed chips. Default 100.0.
width – Display width in pixels when rendering in Jupyter. Default 800.
Example
import gdstk lib = gdstk.read_gds("awesome_design.gds") gds.debug_summarize_gds_library(lib, show=True, scale=200, width=1000)
- export_to_gds(file_name: str, highlight_qcomponents: list = None) int[source]¶
Use the design which was used to initialize this class. The QGeometry element types of both “path” and “poly”, will be used, to convert QGeometry to GDS formatted file.
- Parameters:
- Returns:
0=file_name can not be written, otherwise 1=file_name has been written
- Return type:
- classmethod get_template_options(design: QDesign, render_template: Dict = None, logger_: Logger = None, template_key: str = None) Dict¶
Creates template options for the Metal QRenderer class required for the class to function, based on the design template; i.e., be created, made, and rendered. Provides the blank option structure required.
The options can be extended by plugins, such as renderers.
- Parameters:
design (QDesign) – A design class.
render_template (Dict, optional) – Template options to overwrite the class ones. Defaults to None.
logger (logging.Logger, optional) – A logger for errors. Defaults to None.
template_key (str, optional) – The design.template_options key identifier. If None, then use _get_unique_class_name(). Defaults to None.
- Returns:
Dictionary of renderer’s default options based on design.template_options.
- Return type:
Dict
- get_unique_component_ids(highlight_qcomponents: list | None = None) Tuple[list, int]¶
Confirm the list doesn’t have names of components repeated. Confirm that the name of component exists in QDesign. If QDesign doesn’t contain any component, or if all components in QDesign are found in highlight_qcomponents, return an empty list; otherwise return a list of unique components to be sent to the renderer. The second returned item, an integer, specifies which of these 3 cases applies.
- import_junction_gds_file(lib: Library, directory_name: str | None = None) bool[source]¶
Import the file which contains all junctions for design.
If the file has already been imported, just return True.
When the design has junctions on multiple chips, we only need to import the file once to get all of the junction cells.
- Parameters:
lib – Main GDS library used by this renderer.
directory_name – Directory path where the junction GDS file is expected.
- Returns:
True if the file was imported (or was already imported), False otherwise.
- classmethod load()¶
Load the renderer and register all its extensions. Only performed once.
Once complete, the renderer is added to the class attribute ‘__loaded_renderers__’ of QRenderer
- Returns:
True if success, otherwise throws an error.
- Return type:
- new_gds_library() Library[source]¶
Creates a new GDS Library. Deletes the old. Create a new GDS library file. It can contains multiple cells.
- Returns:
GDS library which can contain multiple cells.
- Return type:
gdstk.Library
- parse_value(value: Any | List | Dict | Iterable) Any¶
Same as design.parse_value. See design for help.
- Returns:
Parsed value of input.
- Return type:
- static plot_gds_zoom(lib: Library, center_mm: Tuple[float, float], span_mm: float = 0.1, title: str | None = None, ax: object | None = None, figsize: Tuple[float, float] = (5.0, 5.0)) object[source]¶
Render a zoomed window of a GDS library using matplotlib.
Flattens the TOP cell hierarchy and draws every polygon whose bounding box overlaps the requested window, coloured by
(layer, datatype). Useful for inspecting junction placement and pad geometry without opening KLayout.- Parameters:
lib – Library returned by
gdstk.read_gds.center_mm – Centre of the zoom window in the same unit as
lib.unit(mm whenlib.unit = 0.001).span_mm – Half-width of the square zoom window. Default
0.10gives a 200 µm window.title – Optional axes title.
ax – Render into an existing
Axes. If None a new figure is created.figsize – Figure size in inches, used only when ax is None.
- Returns:
The
Figurecontaining the render. If ax was supplied this isax.figure; otherwise it is the newly created figure (deregistered from pyplot so it does not double-render in JupyterLab).
Example
import gdstk import matplotlib.pyplot as plt lib = gdstk.read_gds("my_chip.gds") # Single panel fig = gds.plot_gds_zoom(lib, center_mm=(0.70, 0.0), span_mm=0.10, title="Q1 junction") display(fig) # Side-by-side fig, axes = plt.subplots(1, 2, figsize=(13, 6)) gds.plot_gds_zoom(lib, center_mm=( 0.70, 0.0), ax=axes[0], title="Q1") gds.plot_gds_zoom(lib, center_mm=(-0.70, 0.0), ax=axes[1], title="Q2") plt.tight_layout() plt.close(fig) display(fig)
- classmethod populate_element_extensions()¶
Populate cls.element_extensions which will be used to create columns for tables in QGeometry tables.
The structure of cls.element_table_data should be same as cls.element_extensions.
- show_imported_junction_gds()[source]¶
If junction gds file has been imported, show the cells in it. To use, you may need to first set: >>> gds.options.path_filename = “../resources/Fake_Junctions.GDS” This function will read the file again, and print out the cells in it. It will also render the cells as an SVG inline if run in a Jupyter notebook.
- start(force: bool = False) bool¶
Call any initialization (single run) step required to setup the renderer for the first execution, such as connecting to some API or COM, or importing the correct material libraries, etc.
- update_options(render_options: Dict = None, render_template: Dict = None)¶
If template options has not been set for this renderer, then gather all the default options for children and add to design. The GUI would use this to store the template options.
Then give the template options to render to store in self.options. Then user can over-ride the render_options.
- Parameters:
render_options (Dict, optional) – If user wants to over-ride the template options. Defaults to None.
render_template (Dict, optional) – All the template options for each child. Defaults to None.