Editor Mode Quickstart Manual

This user manual is brief description of how to use KLayout in editor mode. KLayout can be put into editing mode by simply supplying the "-e" option on the command line:

klayout -e [<input file>] [-l <layer properties file>]

Accordingly, with the command line option "-ne", non-editable mode can be enforced.

Klayout can be configured to use editing mode as default when started. To enable editing by default, check the "Edit mode" check box on the "Application" tab in the setup dialog ("File/Setup").

In editing mode, some optimizations are disabled. This results in somewhat longer loading times and a somewhat higher memory consumption. The actual increase strongly depends on the nature of the input file: for example, OASIS shape arrays are not kept as such in editing mode and resolved into individual shapes.

This document covers the functionality in a basic section and brief receipe-type descriptions of the main editing functions:

Basic principles of editor mode

Basic editing operations

Advanced editing operations

Basic principles of editor mode

Pick and drop principle

Most drawing programs employ the click-and-drag paradigm: left-click on an element and drag it to the destination keeping the mouse button pressed. Although being pretty intuitive, this principle has one disadvantage: it is hard to do something other than dragging, while you keep the mouse button pressed. In particular this means: no zooming (or would you like to press the right mouse button as well, draw the zoom box and then release just the right mouse button ...?). In order to allow zoom and potentially other operations, KLayout employs the pick-and-drop-principle.

In pick-and-drop, you pick an element by clicking at it with the left mouse button, move it (without any mouse button pressed) and drop it (by left-clicking at the target position). Since the mouse button is not pressed, the mouse is free for other operations: just the dragged item is "sticking" to the mouse cursor.

In addition, while dragging the object, Shift and Ctrl keys can be used to force certain direction constraints or override the ones specified in the options (i.e. "move" or "edit" options): The Shift key forces KLayout into orthogonal mode: movements are restricted to horizontal or vertical unless not applicable. The Ctrl key forces KLayout into diagonal mode: movements are restricted to horizontal, vertical or the diagonal axes. Ctrl plus Shift will release all directional constraints - movements will be allowed in any direction.

Basic editor mode options

Most tools being using in editing mode have certain options, i.e. when drawing a path, the width and extension mode has to be specified. There exists a general setup dialog for editing options. It can be opened using "Editor Options" from the "Edit" menu or using the F3 shortcut (unless overridden).

In the dialog there is always a generic settings tab and - depending on the tool chosen - a tool specific tab. On the generic tab, these settings can be changed:

Whenever you change something in the settings dialog, use "Apply" or "Ok" to apply your changes.

Selection

The basic entity that some operations work with is the "selection". This is basically a set of shapes of instances on which an operation should be applied. A selection can be established by either clicking on a element in "Select" mode or by dragging a selection rectangle. When the mouse is released, all elements inside the selection rectangle are selected.

The selection set can be modified by adding elements (press the Shift button in addition to selecting elements), by removing elements (press Ctrl in addition) or by toggling the selecting (press Shift and Ctrl in addition: remove already selected ones and add new ones).

Partial editing vs. full element editing

"Partial editing" is a powerful feature that allows to modify shapes. It allows to move edges or segments of polygons resp. paths, to delete vertices, edges or segments from polygons or paths and to insert new points into polygons and paths. "Partial editing" can be applied to a complex partial selection: Multiple edges or vertices can be selected and deleted or moved.

The normal selection works "full element". In this mode, the whole shape is being moved or deleted. Only in full element mode, shapes or instances can be sent to the clipboard.

Basic editing operations

Creating a layout from scratch

To start with a fresh, empty layout, choose "New" from the "File" menu. A form is opened that requires you to specify some basic parameters. These are:

  • Top cell: this is the name of the first (and only) cell that will be present in the layout.
  • Database unit: this is the database unit (the conversion factor between integer coordinates and micron units. This is basically the "resolution" of the layout.
  • Initial window size: this is the size of the initial window shown, when the top cell is opened the first time. Since the initial view is empty, there is no geometrical guidance. By specifying an initial size, at least the "canvas" dimensions are known.

If a default layer properties file is specified in the setup dialog ("Application" tab), this is loaded into the layer view list automatically. Without such a file, the layer list is empty at the beginning and layers must be created with "Layer/New" from the "Edit" menu, before any shapes can be drawn.

Creating a new layer

You can create new layers using the "Layers / New Layers" function from the "Edit" menu. You are prompted to enter GDS layer and datatype numbers and optionally an OASIS layer name. On "Ok", the layer will be created and will be inserted into the layer panel.

Creating a new cell

You can create new cells using the "New Cell" function from the hierarchy panel's context menu (right mouse click on the cell hierarchy panel). You are prompted to enter the new cell's name (a cell with that name must not exists yet) and a window size.

Creating a polygon

Select "Polygon" mode from the toolbar. Choose a layer from the layer panel in which to create a new polygon. Left-click at the first vertex of the polygon. Move the mouse to the next vertex and place a new one with a left mouse button click. Move to the next vertex. Depending on the connection mode, the edges created are confined to certain directions. See connection angle constraints description for a detailed description of the modes. Use the "editor options" dialog (F3 shortcut) to change the mode, even during editing.

Double-click at the final point to finish the polygon. Press the ESC key to cancel the operation.

A polygon will never be "open": there are always edges connecting the current vertex with the initial one. Depending on the mode, this final connection is either a straight line or a combination of edges. In "diagonal mode", there are manifold possibilities to create a final connection in a more or less smart way. The program uses some heuristics to determine one feasible combination. Although this heuristics is not infinite smart, it should be easy to lead the algorithm to the desired solution, by pointing the mouse into the desired direction.

Creating a box

Select "Box" mode from the toolbar. Choose a layer from the layer panel in which to create a new box. Left click at the first point, move the mouse to the second point and finish the box by left-clicking at the second point. Press the ESC key to cancel the operation.

Hint: A box, once created, will remain a box. For example, it is not possible to delete one vertex of it, thus forming a triangle. This is only possible for polygons.

Creating a path

Select "Path" mode from the toolbar. The editor options dialog will open that additionally prompts for basic path parameters, such as width and extension scheme. When a path is being drawn, it will receive the settings entered into this dialog. The path properties can even be changed, while the path is being drawn. Don't forget to click "Apply" to take over the current entries. If the dialog has been closed unintentionally, it can be reopened with the F3 shortcut.

To actually draw a path, choose a layer from the layer panel in which to create a new box. Left click at the first vertex, move the mouse to the second vertex, click to place this one and continue to the last vertex. Double-click at the last vertex to finish the path. Press the ESC key to cancel the operation.

For paths, as for polygons, the segments created are subject to certain direction restrictions as imposed by the connection angle constraints. See connection angle constraints description for a detailed description of the modes. Use the "editor options" dialog (F3 shortcut) to change the mode, even during editing.

Creating a text object

Select "Text" mode from the toolbar. The editor options dialog will open that additionally prompts for the text string. Don't forget to click "Apply" to take over the current string. If the dialog has been closed unintentionally, it can be reopened with the F3 shortcut.

To actually draw the text, move the mouse to the desired location and left-click to place it.

A text can be given a size which is stored in a GDS2 file (OASIS files do not provide this feature). The size of the text is only shown in the layout if a scalable text font is selected (the "Default" font is not scalable) and text scaling is enabled. In order to do so, choose a scalable font from the "Text font" selection box in the "Display" tab of the setup dialog and check the "Apply text scaling and rotation" box in the same tab.

The text can also be rotated, which is shown as well only if text scaling and rotation is enabled. To rotate a text while placing it, click the right mouse button. This will rotate the text by 90 degree counterclockwise.

Placing an instance of a cell

Select "Instance" mode from the toolbar. The editor options dialog will open that additionally prompts for some instance parameters. The most important one of course is the cell that shall be placed. Geometrically, the rotation angle can be specified, the mirror option can be set and the instance may be specified as a regular array. As an array, the instance represents multiple placements of the cell, arranged in regular grid which is specified by the two axis vectors and instance counts in each direction. Don't forget to click "Apply" to take over the current settings. If the dialog has been closed unintentionally, it can be reopened with the F3 shortcut.

To place the instance, move the mouse to the desired location and left-click to place it. While moving, the right mouse button can be used to rotate the instance by 90 degree counterclockwise. Press the ESC key to cancel the operation.

Moving the selection

The whole selection can be moved in "Move" mode. If some elements are already selected, choose "Move" mode and select a reference point by left-clicking at the position. The reference point will be used as the "dragging handle" - each element is moved relative to this position. In no elements are selected when entering move mode, simply click at the element to move and place it somewhere else with a left mouse click.

While moving, the whole selection can be rotated by 90 degree counterclockwise with a right mouse button click. The ESC key will cancel the operation.

For movements, the movement direction constraint apply. See movement direction constraint description for details about the modes available. For example, in manhattan mode, only horizontal and vertical movements are allowed. The global movement constraint can be overridden by pressing Shift (orthogonal), Ctrl (diagonal) or both Shift and Ctrl (any angle) while moving the mouse.

Other transformations of the selection

The selection can be flipped at x- or y-axis, rotated as a whole or moved by a certain distance using the functions available in the "Selection" submenu of the "Edit" menu. For example, "Flip Vertically" flips the selection at the x-axis. A selection can be rotated by an arbitrary angle using the "Rotation By Angle" function from the "Selection" submenu.

Partial editing

When objects have to be modified after the have been created, partial editing comes into play. "Partial" refers to the fact that just parts of a polygon or path are edited. For example, just one vertex or an edge of a polygon can be moved. Partial editing mode also allows to delete single vertices or edges or to insert new ones. In partial editing mode, multiple edges or vertices can be selected, even a whole shape can be selected and can then be moved or deleted.

When moving the selected parts, the movement direction constraint applies. See movement direction constraint description for details about the modes available. For example, in manhattan mode, only horizontal and vertical movements of parts are allowed. Again, the global movement constraint can be overridden by pressing Shift (orthogonal), Ctrl (diagonal) or both Shift and Ctrl (any angle) while moving the mouse.

To enter partial mode, click on the "Partial" button in the toolbar. Parts (edges or vertices) can then be selected either by simply clicking at them or by dragging a selection rectangle. As in normal selection mode, the modifier buttons Shift and Ctrl can be used to add a selection to the existing one or to remove elements from the existing selection. Partial selection is subject to the "top level only" constraint (see description of top level selection mode).

Simply clicking at an item immediately enters "move" mode. In this mode, you can position the element at the desired target location and place it there by left-clicking at the position. Press "ESC" to cancel the operation. When a complex selection is made, move mode is entered by clicking at one of the selected items (the edges or vertices, not the shape to which they belong).

When moving parts, certain constraints apply, i.e. single edges can only be moved perpendicular to their current position. In addition, the movement is confined to the editing grid.

The selected items can be deleted by using the "Delete" function from the "Edit" menu or pressing the "Delete" key. If not enough vertices remain to form a valid object, the object is deleted (i.e. a polygon with less then 3 points).

By double-clicking at an edge or path segment, an additional point is created on this edge at the cursor's position. You can create a "bend" on a path by placing two new vertices on that segment and moving the connecting segment between these vertices away from the former center line. This basically requires two double-clicks on the path's centerline, a single click on the newly formed segment and a single click to drop it at the new position.

Moving the selection to a different layer

The selected shapes can be moved to a different layer as a whole. For this, choose "Change Layer" from the "Selection" submenu of the "Edit" menu. All selected shapes are moved to the layer that is the current one (marked with a rectangle) in the layer list. The shapes will not be moved across the hierarchy but just inside their cell.

All layers (source and target) must be located in the same layout. To move shapes to a different layout, use copy & paste.

Other layer operations

The layer specification can be edited using the "Edit Layer Specification" method from the "Layer" submenu inside the "Edit" menu. A dialog is shown in which the layer, datatype and (OASIS) name of the layer currently selected in the layer panel can be edited. On save, the shapes are then mapped to the new layer.

A layer can be cleared (either cellwise, on a cell's hierarchy or for all cells) using the "Clear Layer" method from the "Layer" submenu inside the "Edit" menu.

Copy and paste of the selection

Of course, copy and paste is supported as usual. Shapes can be copied between layouts: by opening two layouts, shapes can be moved from one layout to another. The shapes are mapped to the same layer than they have been on in the source layout. If a layer does not exist yet in the target layout, it is created.

Shapes in the selection are simply copied to the clipboard in the way they appear in the current cell. This means, if the shapes are pasted into a different layout they are put on the same position, but flat into the current cell. This provides a way to flatten a hierarchy: choose "hierarchical selection mode" in the editor options dialog (deselect "top level only"), select the shapes to flatten and copy everything to a different cell.

In non-hierarchical selection mode ("top level only" selection mode) or by clicking on a cell frame when the hierarchy levels are limited, instances can be selected as well. When copying instances to the clipboard, two possible methods exist:

  • Shallow copy: In this mode, just the instance is copied. When it is pasted into any target layout, the target cell of the instance is looked up and instantiated.
  • Deep copy: Not only the instance but the instantiated cell is copied as well. When pasting that into a different layout, the target cell will be created as well. If a cell with that name already exists, a variant is created and instantiated.

Delete a cell

To delete a whole cell, select the cell in the hierarchy browser and choose "Delete Cell" from the context menu (right mouse button). This time, three possible modes are offered:

  • Shallow delete: Just the cell (it's shapes and instances) are deleted, not any cells referenced by this cell. Since cells might no longer be referenced after that, they may appear as new top cells in the layout.
  • Deep delete: The cell and all it's subcells are deleted, unless the subcells are referenced otherwise (by cells that are not deleted). In this delete mode a complete hierarchy of cells can be removed without side effects.
  • Complete delete: The cell and all it's subcells are deleted, even if other cells would reference these subcells.

Rename a cell

To rename a cell, select the cell in the hierarchy browser and choose "Rename Cell" from the context menu (right mouse button). You are prompted for a new name which must not exist yet.

Copy and paste of cells

Whole cells can be copied to the clipboard as well. To copy a whole cell, select the cell in the hierarchy browser (make sure the focus is in that window) and choose "Copy" or "Cut" from the "Edit" menu. To paste such a cell into a target layout, choose "Paste" from the "Edit" menu.

Copying a cell from one layout to another provides a way to merge two layouts into one: simply copy the top cell of the first layout into the second one and instantiate both in a new top cell for example.

Advanced editing operations

Hierarchical operations: flatten instances, make cell from selection, move up in hierarchy

Klayout provides several operations that move shapes or instances up and down in hierarchy. All these operations are accessible through the "Edit" menu in the "Selection" sub-menu.

  • Flatten instances: Replace the selected instances by the contents of the instantiated cell. KLayout will ask, if all levels or just the first level of the cell should be expanded. If all levels are expanded, the cell will be resolved into a set of shapes in the current cell's hierarchy.
  • Move up in hierarchy: Applies only to selections inside child cells of the current cell (thus does not make sense if 'top level only' selection mode is active). The selected shapes and instances are brought up to the current cell's level and removed from the original cell.
    A non-destructive way of moving a shape up in the hierarchy is to copy and paste the shape. This does an explicit flattening of the shapes selected when inserting them.
    Hint: the current implementation removes the selected object from it's original cell. Since it only creates new copies for the selected instances, the object ist lost for all other instances of the cell. This may create undesired side effects and it is likely that this behaviour will change in future implementations.
  • Make cell from selection: Removes the currently selected objects and places them into a new cell whose name can be specified.

Creating clips

KLayout provides a utility to create rectangular clips from a given cell. One or more rectangles can be specified. The current cell is cut along the edges of these rectangles. For each rectangle, a new cell is created containing the clipped content for the rectangle. Finally, if more than one rectangle is specified, all the clips are combined into a master top cell which appears as a new top cell in the cell hierarchy.

The clips can be either specified by coordinates, taken from another layer (which must contain boxes which then are copied into the output as well) or taken from the rulers. In the latter case, the rulers' start and end points are taken as the corners of the clip rectangles. It is convenient therefore to create a new ruler type with a box appearance for this purpose.

Clips are done hierarchically: child cells are clipped as well, potentially creating variants (which may be shared by several clips). This way, large clips can be created from large layouts in an efficient way. Hint: Clipping will not work exactly if the layout contains cell instances with arbitrary rotation angles such as 45 degree.

Flatten cells

The "flatten cell" operation flattens a cell into all of it's parents. This basically removes a cell by promoting her shapes and instances up in the hierarchy.

The flatten operation offers some options, i.e. the number of hierarchy levels to flatten and how to deal with child cells which become obsolete through this operation. By enabling this "prune" option, all child cells are removed when they are no longer needed. Otherwise, new top level cells will appear - these are the cells which are not longer instantiated.

Layer boolean operations

KLayout now comes with a set of boolean operations. These operations are available in the "Layers" submenu of the "Edit" menu ("Boolean Operations" and "Merge" functions). A dialog will open that allows to specify mode, input layer(s), output layer and certain other options.

  • AND: intersection. The output layer will contain all areas where shapes from layer A and layer B overlap.
  • A NOT B: difference. The output layer will contain all areas where shapes from layer A are not overlapping with shapes from layer B.
  • B NOT A: difference. The output layer will contain all areas where shapes from layer B are not overlapping with shapes from layer A.
  • XOR: symmetric difference. The output layer will contain all areas where shapes from layer A are not overlapping with shapes from layer B and vice versa.

In addition, a MERGE operation is provided, which is a single-layer operation that joins (merges) all shapes on the layer. As a special feature, this operation allows to select a minimum overlap count: 0 means that output is produced when at least one shape is present. 1 means that two shapes have to overlap to produce an output and so on. This does not apply for single polygons: self-overlaps of polygons are not detected in this mode.

All operations can be performed in three hierarchical modes:

  • Flat: Both layers are flattened and the results are put into the current top cell.
  • Top cell: perform the operation on shapes in the top cell only.
  • Cellwise: perform the operation on shapes of all cells below the current top cell individually. This mode is allowed only if the layouts of both inputs and output are the same.

For the first two modes, the source and target layout can be different, provided that all layouts are loaded into the same view. This allows to combine layers of different layouts, i.e. compare them using a XOR function.

As a special feature, KLayout's boolean implementation allows to choose how "kissing corner" situations are resolved. KLayout allows two modes:

  • Maximum coherence: the output will contain as few, coherent polygons as possible. These polygons may contain points multiple times, since the contour may return to the same point without closing the contour.
  • Minimum coherence: the output will contain as much, potentially touching polygons as possible.

The following screenshots illustrate the maximum coherence (left) and minimum coherence (right) modes for a XOR operation between two rectangles.

The boolean operations are currently implemented flat and based on a full-level edge representation. This means, that the complete layer is flattened (if "flat" mode is requested) and converted into a set of edges which the processor runs on. This will lead to huge resource requirements for very large layouts and is not recommended for such applications currently.

The boolean processor is based on an iterative approach to cover grid snap effects which makes it highly accurate but somewhat slower than a single-pass scanline implementation. Performance penalty is about 2x (two times slower) compared to an efficiently implemented single-pass algorithm.

Layer sizing

A sizing operation allows to grow or shrink the shapes of a layer by a given offset, which is applied per edge. Positive values will enlarge the shapes while negative values will shrink the shapes. The offset can be given separately for horizontal and vertical direction. However, the sign of both values must be identical (i.e. "0.5,0" or "1.0,0.2", but not "0.2,-0.2").

The sizing function can be found in the "Layers" submenu of the "Edit" menu. A dialog will open that allows to specify input and output layers, sizing value in micron: a single value for same sizing in x and y direction or comma-separated list of two values (i.e. "0.2,0.1").

As for the boolean operations, hierarchical mode and kissing corner resolution can be specified (see Layer boolean operations for a description of these modes). In addition, the cutoff strategy for sharp edges can be chosen from strict to virtually unlimited. The following screenshot demonstrates the effect for "strict" (red) to "weak" (purple) cutoff modes.

Shapewise boolean operations

Boolean operations are also available on selected shape sets. These operations use the concept of "primary" and "secondary" selection. The primary selection contains all shapes that are selected in the first step. The secondary selection contains all shapes that are selected in additional steps using the "Shift" modifier key.

The following operations are available in the "Selection" submenu of the "Edit" menu:

  • Merge: merge all shapes in the primary and secondary selection and write the results to the layer of the primary selection.
  • Intersection: Compute the intersection (AND) of primary and secondary selection and write the results to the layer of the primary selection.
  • Subtraction: Compute the difference (A NOT B) of primary (A) and secondary (B) selection and write the results to the layer of the primary selection.

Shapewise sizing

The selected shapes can be sized with a given enlargement and shrink distance, similar to the layer operation but with less options. The sizing function can be found in the "Selection" submenu of the "Edit" menu. A dialog will open that prompts for the sizing value (one value for same sizing in x and y direction in micron or two comma-separated values for different sizing in x and y direction).

Object alignment

This operation use the concept of "primary" and "secondary" selection. The primary selection contains all shapes that are selected in the first step. The secondary selection contains all shapes that are selected in additional steps using the "Shift" modifier key.

The object alignment function allows to align all objects in the secondary selection to the objects in the primary selection (i.e. objects in the primary selection define the reference points but are not moved). An "object" can be a shape or an instance of a cell. Cell instances are referred to by their bounding box which can be either computed from the visible layers alone or from all layers.

Alignment can be specified differently in horizontal and vertical direction. Horizontal alignment can be "none" (no change), "left" (align left sides), "center" (align centers) or "right" (align right sides). Vertical alignment can be "none", "bottom", "center" or "top".

The alignment function can be found in the "Selection" submenu of the "Edit" menu. A dialog will open which allows to specify the alignment mode and bounding box computation mode for cell instances.

Corner rounding

In some applications, i.e. power devices, it is desirable to have round corners instead of sharp corners to limit the electrical field. Klayout now offers a convenient way to create such structures. The basic idea is to draw the structures with sharp, 90 degree corners and then "soften" the corners by rounding them to a given radius. The resulting polygons can then be written to GDS files, even though GDS does not have the concept of "soft" (or circular) geometries.

The interesting part is: the corner rounding function can be re-applied on such geometries on a polygon basic. That means, that even if such a modified polygons are saved to GDS or otherwise modified, the original geometry can be reconstructed and the corner radius can be changed. No special geometrical objects or special GDS annotation is required to achieve this. This requirement imposes some (probably weak) limitations:

  • The number of points per corner must not be too small (currently at least 32 on the full circle)
  • The original geometry must not exhibit sharp corners and the original segments must be at least twice the corner radius in length.
  • The corner segments must be perceivable as such, i.e the angle between adjacent edges must be "nearly" 180 degree. This imposes some restrictions on the minimum length of such a segment and on the accuracy by which they can be expressed in database units. This boils down to a certain length limit in terms of database units.

The following screenshot illustrates the round corners function. As can be seen in this example, it is necessary to allow a different radius specification for "inner" and "outer" corners.

The corner rounding function operates on selected shapes. It can be found in the "Selection" submenu of the "Edit" menu. A dialog will open which allows to specify the radius values and the desired resolution. If the selected polygon already has rounded corners, the corner rounding will be removed and the original polygon reconstructed before the new corner rounding is applied. By specifying "0" for the radius, the original sharp corners will be recovered.

Cell origin adjustment

The cell origin is important for a cell because this point is the instantiation anchor for cell instances. The cell origin adjustment function allows to shift the origin to a certain place relative to a cell's bounding box. This can be either the center, a corner or the middle of an edge of the bounding box. The bounding box can either be computed from all or just from the visible layers.

The cell origin adjustment function can be found in the "Cell" submenu of the "Edit" menu.

Layer operations: clear, delete, edit specification

Three full-layer operations are implemented which are available in the "Layers" submenu of the "Edit" menu:

  • Clear: clear but don't delete the currently active layer in the layer list.
  • Delete: clear and delete the currently active layer in the layer list.
  • Edit Layer Specification: edit the layer specification of the currently active layer in the layer list.

The "layer specification" describes how a layer is saved to GDS or OASIS streams. It consists of a layer and datatype number and optionally - for OASIS - a layer name.