API reference - Class PCellDeclarationHelperNotation used in Ruby API documentation Description: A helper class to simplify the declaration of a PCell (Ruby version) Class hierarchy: PCellDeclarationHelper » PCellDeclaration This class provides adds some convenience to the PCell declaration based on PCellDeclaration. PCellDeclaration is a C++ object which is less convenient to use than a Ruby-based approach. In particular this class simplifies the declaration and use of parameters through accessor methods that are created automatically from the declaration of the parameters. The basic usage of this class is the following: # Derive your PCell from PCellDeclarationHelper class MyPCell < RBA::PCellDeclarationHelper # initalize def initialize super # your initialization: add parameters with name, type, description and # optional other values param :p, TypeInt, "The parameter", :default => 1 param :l, TypeLayer, "The layer", :default => RBA::LayerInfo::new(1, 0) # add other parameters .. end # reimplement display_text_impl def display_text_impl # implement the method here end # reimplement produce_impl def produce_impl # implement the method here end # optionally reimplement coerce_parameters_impl def coerce_parameters_impl # implement the method here end end An implementation of display_text_impl could look like this: def display_text_impl "We have p=#{p}" end Because in the sample declaration above we have declared parameter "p" we can access the value of p inside the implementation simply by using the "p" method. Similarily the produce_impl implementation could use code like the following. Please note that layout and cell are available to get the layout and cell. Also because we have declared a layer parameter "l", we can access the layer index with the "l_layer" method: def produce_impl cell.shapes(l_layer).insert(RBA::Box.new(0, 0, p*100, p*200)) end Again in this sample, we used "p" to access the parameter "p". The implementation of coerce_parameter_impl can make use of the parameter setters. In the case of the "p" parameter, the setter is "set_p": def coerce_parameter_impl p < 10 || set_p(10) end Public methods
Detailed descriptioncan_create_from_shape_implDescription: Returns true if the PCell can be created from the given shape This method can be reimplemented in a PCell class. If the PCell can be created from the shape available through the shape accessor (a Shape object), this method is supposed to return true. The layout the shape lives in can be accessed with layout and the layer with layer. The default implementation returns false. cellDescription: Gets the reference to the current cell within produce_impl coerce_parameters_implDescription: Coerces the parameters This method can be reimplemented in a PCell class. It is supposed to adjust parameters to render a consistent parameter set and to fix parameter range errors. This method is called for example inside the PCell user interface to compute the actual parameters when "Apply" is pressed. display_text_implDescription: Delivers the display text This method must be reimplemented in a PCell class to identify the PCell in human-readable form. This text is shown in the cell tree for the PCell for example. initializeDescription: Initializes this instance layerDescription: Gets the reference to the current layer index within can_create_from_shape_impl, parameters_from_shape_impl and transformation_from_shape_impl The object returned is the layer index within the Layout object of the shape which will be converted. layoutDescription: Gets the reference to the current layout within produce_impl, can_create_from_shape_impl, parameters_from_shape_impl and transformation_from_shape_impl The object returned is the Layout object of the shape which will be converted. param(name,type,description,...)Description: Declares a parameter with the given name, type and description and optional attributes.
Optional, named parameters are
":choices" must be an array of two-element arrays (description text, value) which specify one choice each for parameters with a choice of values. Such parameters are represented by a drop-down box. This declaration will create accessor methods "x" and "set_x", where "x" is the name of the parameter. If the type is TypeLayer, an accessor "x_layer" delivering the layer index inside produce_impl is created as well. parameters_from_shape_implDescription: Sets the parameters from a shape This method can be reimplemented in a PCell class. If can_create_from_shape_impl returns true, this method is called to set the parameters from the given shape (see shape, layout and layer). Note, that for setting a layer parameter you need to create the LayerInfo object, i.e. like this: set_l layout.get_info(layer) The default implementation does nothing. All parameters not set in this method will receive their default value. produce_implDescription: Produces the layout This method must be reimplemented in a PCell class. Using the parameter values provided by the parameter accessor methods and the layout and cell through layout and cell, this method is supposed to produce the final layout inside the given cell. shapeDescription: Gets the reference to the current shape within can_create_from_shape_impl, parameters_from_shape_impl and transformation_from_shape_impl The object returned is the Shape object of the shape which will be converted. transformation_from_shape_implDescription: Gets the initial PCell instance transformation when creating from a shape This method can be reimplemented in a PCell class. If can_create_from_shape_impl returns true, this method is called to get the initial transformation from the given shape (see shape, layout and layer). This method must return a Trans object. The default implementation returns a unit transformation (no displacement, no rotation). |