4.3.2. undulate.renderers.renderer module
renderer.py declare the logic to render waveforms into different format
- undulate.renderers.renderer.incr_wavelane(f)
incr_wavelane is a decorator that increment _WAVE_COUNT in auto. This generates a unique id for each wavelane
- undulate.renderers.renderer.incr_wavegroup(f)
incr_wavegroup is a decorator that increment _WAVEGROUP_COUNT in auto. This generates a unique id for each group of wavelanes
- undulate.renderers.renderer.svg_curve_convert(vertices: list) list
convert svg path definition to simpler s/c/m/l only mode to support eps renderer and other output format
- Parameters
vertices (list) –
list of (type,x,y) tuples where x,y are coordinates and type is the svg operator
Warning
it does not support T curves
- Returns
list of (type,x,y) tuples where type is only cubic bezier curve
- class undulate.renderers.renderer.Renderer
Bases:
object
Abstract class of all renderer and define the parsing logic
- group(callback, identifier: str, **kwargs) str
Group some drawable together
- Parameters
callback (callable) – function which populate what inside the group
identifier (str) – unique id for the group
- path(vertices: List[undulate.bricks.generic.Point], **kwargs) str
Draw line segments to connect consecutive points of ‘vertices’ to represent common signals
- Parameters
vertices (List[Point]) – list of points to be connected
style_repr (optional str) – css rule, by default ‘path’
- arrow(arrow_description: undulate.bricks.generic.ArrowDescription, **kwargs) str
Draw an arrow to represent edge trigger on clock signals or to point something in an annotation.
- Parameters
arrow_description (ArrowDescription) – position and oriantation
style_repr (optional str) – css rule, by default ‘arrow’
- polygon(vertices: List[undulate.bricks.generic.Point], **kwargs) str
Draw a closed shape for shaded/colored area
- Parameters
vertices (List[Point]) – Ordered list of point delimiting the polygon
style_repr (optional str) – css rule, by default None
- spline(vertices: List[undulate.bricks.generic.SplineSegment], **kwargs) str
Draw a path to represent smooth signals
- Parameters
vertices (List[SplineSegment]) – list of SVG path operators and arguments
style_repr (optional str) – css rule, by default ‘path’
- text(x: float, y: float, text: str = '', **kwargs) str
Draw a text at a specific position
- Parameters
x (float) – x coordinate of the text
y (float) – y coordinate of the text
text (str) – text to display
style_repr (optional str) – css rule, by default ‘text’
- translate(x: float, y: float, **kwargs) str
translation function that is inherited for svg and eps
- brick(symbol: str, b: undulate.bricks.generic.Brick, **kwargs) str
Draw the symbol of a given Brick element
- static adjust_y(index, brick_height: float = 1.0) float
Convert an integer expression the index of the waveform as a y-coordinate in the drawing context
- Parameters
y (int) – index of the waveform
brick_height (float) – height of a brick
- Returns
equivalent y-coordinate
- static from_to_parser(s: object, width: float, height: float, brick_width: float = 40.0, brick_height: float = 20.0) undulate.bricks.generic.Point
Parse the from and to options of annotations into positions for drawing the specified shape or text
Supported format are: - float - Tuple[float, float] - String “float” - String “float unit” where unit is either “” or “%” - String “(float unit, float unit)” where unit is either “” or “%” - String “node_name” - String “node_name + (± float, ± float)”
- Parameters
s (str) – value of from or to option
width (float) – width of the image
height (float) – height of the image
brick_width (float, default=40) – brick width
brick_height (float, default=40) – brick height
- Returns
Point of x-y coordinate
- annotate(wavelanes: dict, viewport: tuple, **kwargs) str
Draw edges, vertical lines, horizontal lines, global time compression, … or any other shape defined in the annotations section of the input file
Example
{"annotations": [ {"shape": "||", "x": 3.5}, {"shape": "-~>", "from": "trigger", "to": "event", "text": "ready"} ]}
- Parameters
wavelanes (Dict) – global signals representations
viewport (Tuple[float, float, float, float]) – the drawable zone (excluding signal names) x, y, width, height
edges (Dict) – edge section of the input file
annotations (List[Dict]) – annotations section of the input file
brick_width (float) – default width of a brick
brick_height (float) – default height of a brick
- wavelane_title(name: str, **kwargs) str
Draw the title in front of a waveform
- Parameters
name (str) – name of the waveform print alongside
order (int) –
position from 0-4 of the title position along the y-axis. This property is important when overlaying signals
0 : middle of the wavelane height, is the default
1-4 : quarter from top to bottom of the wavelane
brick_height (float) – height a brick
- ticks(width: int, height: int, step: float, **kwargs) str
Generates the dotted vertical lines to ease reading of waveforms and their respective alignment
- Parameters
width (int) – width of the image
height (int) – height of the image
step (float) – distance between two ticks
offsetx (optional) – shift all ticks along the x-axis
offsety (optional) – shift to the bottom ticks with exceeding the height
phase (optional) – phase of the first signal on the top level this parameter is used to align tick with the rising edges of the first signal
- size(wavelanes, depth: int = 1, **kwargs)
Pre-estimate the size of the image (duplicate of wavegroup without drawing)
- Parameters
name (str) – name of the waveform group
wavelanes (Dict[str, dict]) – named waveforms composing the group
depth (int) – depth of nested groups to represent hierarchy
config (Dict[str, Any]) – config section of the input file
brick_width (float) – width of a brick, default is 20.0
brick_height (float) – height of a brick, default is 20.0
width (float) – image width
height (float) – image height
Warning
Might be good to implement a parameter no_drawing in wavegroup and performs 2 passes to prevent possible discrepency
- draw(wavelanes, **kwargs) str
Business function calling all others
- Parameters
wavelanes (dict) – parsed dictionary from the input file
filename (str, optional) – file name of the output generated file
brick_width (int) – by default 40
brick_height (int) – by default 20
is_reg (bool) – if True wavelanes given represents a register otherwise it represents a bunch of signals