logo

Macro Programming

logo
the fair gds editor

Introduction
Screenshots
License
Download
Userinterface
Function Index
White Papers
Community
Contact

mouse left
no help

Introduction

The LayoutEditor offers a wide range of using macro or scripting. Starting with simple recording of macros until a complete adjustment of the user interface or integrating external software tools. Fundamental parts of the macro programing are:

Contents:

  • Macro Recording
  • Data Structure
  • C/C++ Macros
  • Python Macros
  • Python Program Extensions
  • List of Classes
  • Macro Function Index

    Macro Recording

    The simplest way to use macro is macro recording. Like many office programs the LayoutEditor can record the operations you have done with the graphical user interface. The operation are stored in a C/C++ style way an can be edited with any text editor. The recoring can be started via Start Macro Recording and stopped via Stop Recorded Macro. After stopping the recording you will be asked for a location to store the macro. Store macros can be executed via Execute Macro function. Alternative you can store the macro file in a specially named folder (setup). All macros in that folder and its sub folders will be included into the main menu of the LayoutEditor.

    Data Structure

    Structure Overview

    scripting The data stucture in the LayoutEditor is keep simple. A short overview is given here. More detailed information can be found for each class. The scripting is object orientated using a couple of classes and extensive use of pointers.

    Layout Window Structure

    scripting In any variant of scripting you will get a point with the name 'layout' on the class layout. The class layout is the main window in the LayoutEditor. With methods in this class you can adjust the graphical user interface. It also contains a pointer with the name 'drawing' to the class drawingField. This class stores the design data and gives a high level access to manipulate the data. Also methods for loading and saveing are avaiable. The class drawingField has a pointer 'currenctCell' to the current displayed cell and a pointer 'firstCell' to a list of all cell in the design.

    Cell Data Structure

    scripting The class cell stores data belonging to a single cell likes the cell name. It has a plenty of methods for a mid level modification of the cell elements. The cell class includes a list of all elements in the cell. Each single element or shape of the design like box, polygon or cellRef is store in the class element. Via method of the element class a low level access to any data is possible.


    C/C++ Macros

    All macros are text-files and stored somewhere below the "macros"-directory in the layout installation-directory. During program launch these directory-tree is scanned and add to the mainmenu. A modification of the macro-program is possible while the layout-program is running. Creating of macros had to be done in a text editor. Macro-examples are supplied with the LayoutEditor. If you program macros, which may be interesting for the general public, please contribute them to this project. They will be added to the next release. If you don't want this, feel free to keep it back.

    Structure of Macros

    All macros are in a pseudo C/C++ code. They had to start as follow:

    #!/path_to_the_layout/layout
    #name=your_macro_name
    #help=help_for_your_macro

    The main-function in the macro is executed. If a exitcode unequal 0 is returned, a warning is display. All called function had to be defined before the main function.

    int main(){
    ...
    }

    As standard types you can use int, double, bool, void. Additional there are further type like string, point, pointArray, etc. The usage of pointers is possible. Pointer on pointer are not allowed. while, do ... while, for and if structures can be used. switch, enum and struc structures are not allowed and will case a termination. Own functions can be created, own classed are not possible. Compiler commands unless '#include' are ignored. Comments are possible. Most of the drawing relevant classes can be accessed via the class layout.


    List of all layout specific classes: Macro Classes List
    Alphabetic list of all funtions: Macro Index

    Example Macros:
    Macro Programming Example 1
    Macro Programming Example 2
    Macro Programming Example 3
    Macro Programming Example 4
    Macro Programming Example 5
    Macro Programming Example 6
    Macro Programming Example 7

    Python Macros

    The use of python macros requires 'pylayout'. Pylayout is a python module with all the feature of the LayoutEditor. It is shipped with the LayoutEditor in some packages. It is not and will not be avaiable for some older plattform versions.

    Python macro can be used in the same way as C/C++ macros. The application interface has the same structure. There are only a few python specific differences. One difference is, that python macros must contain the word 'python' in the first line to be recongizes as a python macro. A simple python macro would look like this:

    #!use python
    #name=#1: Python Exsample 1
    #help=Helptext for Sample 1

    layout.drawing.point(0,0)
    layout.drawing.point(4000,2000)
    layout.drawing.box()
    layout.drawing.scaleFull()


    This simple example will add a box to the current cell on the active layer.

    Note:
    The LayoutEditor uses all avaiable processor cores in a system. So a python macro will be executed in a seperate thread. Mouse and keyboard events are send to the main thread. Depending on your system configuration this may result in 'problems'/'restrictions', if you create own user interfaces. Use Python Program Extensions to avoid it.

    Python Program Extensions

    The main LayoutEditor window as well as the juspertor library manager is written in python. These python sources are free and can be adjusted by anyone. You can add new features, integrate other tools or even embed the LayoutEditor into any other python program. The LayoutEditor uses the qt library for the graphical user interface and any of its feature is available for adaptions. Please see the python-qt bindings documentations for details.

    Multithreading
    The LayoutEditor uses multithreading. This mean that all avaiable processor core are used coincidental. So a design can be save during you review or print it. For data integrity and synconisation mutexes are used. For you python extension you had to use it as well to avoid data lost or program crashes. So for any access to a layout design you had to lock the mutex and release it afterwards. So a mutex read lock will wait until any write lock has finished, etc. Please see the Class drawingField for a more detailed documentation.