QRendererGui

class QRendererGui(gui, design: QDesign, initiate=True, fig=None, ax=None)[source]

Abstract base class for the GUI rendering.

Extends QRenderer. An interface class.

Parameters:
  • gui (MetalGUI) – the GUI.

  • design (QDesign) – The design.

  • initiate (bool) – True to initiate the renderer. Defaults to True.

  • fig (figure) – current figure. Defaults to None.

  • ax (ax) – current ax. Defaults to None.

Attributes

design

Return a reference to the parent design object.

element_extensions = {}

Element extensions dictionary

element_table_data = {}

Element table data.

logger

Returns the logger.

name = 'guibase'

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.

clear_axis()[source]

Clear the axis.

Raises:

NotImplementedError – Function not written yet

clear_figure()[source]

Clear the figure.

Raises:

NotImplementedError – Function not written yet

static get_renderer(name: str)

Returns an already loaded and instantiated renderer.

Parameters:

name (str) – rendering name

Returns:

Renderer with the given name

Return type:

QRenderer

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.

Parameters:

highlight_qcomponents (Union[list, None], optional) – Components to render. Defaults to None.

Returns:

Tuple: Empty or partial list of components in QDesign.
int: 0 subset selected

1 every component selected 2 invalid

Return type:

Tuple[list, int]

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:

bool

parse_value(value: Any | List | Dict | Iterable) Any

Same as design.parse_value. See design for help.

Returns:

Parsed value of input.

Return type:

object

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.

render_component(component)[source]

Render the given component.

Parameters:

component (QComponent) – the component

Raises:

NotImplementedError – Function not written yet

render_connectors()[source]

Render connectors.

Raises:

NotImplementedError – Function not written yet

render_design(selection=None)[source]

Render the design.

Parameters:

selection (selection) – Not used

render_shapely()[source]

Render shapely.

Raises:

NotImplementedError – Function not written yet

set_ax(ax)[source]

Set the given ax.

Parameters:

ax (ax) – ax to set

set_fig(fig)[source]

Set the given figure.

Parameters:

fig (figure) – Figure to set

setup_fig(fig)[source]

Setup the given figure.

Parameters:

fig (figure) – figure to setup

Raises:

NotImplementedError – Function not written yet

start(force=False)

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.

Parameters:

force (bool) – If True, need to scrap the existing initialization and re-do If False, will start a new one only if none exists. Defaults to False.

Returns:

is the renderer initialized successfully (thus usable?)

Return type:

bool

stop()

Any calls that one may want to make after a rendering is complete.

style_axis(ax)[source]

Style the axis.

Parameters:

ax (ax) – ax to style

Raises:

NotImplementedError – Function not written yet

update_options(render_options: Dict | None = None, render_template: Dict | None = 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.