Skip to content

API Reference

Plugins use three modules:

  • setuav_studio.api: StudioAPI, the contribution descriptors, and StudioPlugin.
  • setuav_studio.solver: AbstractSolver, SolverConfig, and SolverResult, with the table, plot and summary types in setuav_studio.solver.results.
  • setuav_studio.ui.style.icons: register_plugin_icons and unregister_plugin_icons.

Other application modules are implementation details and may change at any time.

StudioAPI

Every register_* method has a matching unregister_* method.

Area StudioAPI members Descriptor
Panels register_panel, show_panel PanelContribution
Toolbar register_toolbar_item, refresh_toolbar_states ToolbarContribution, ToolbarMenuItemContribution
Menus register_tool (Tools menu), register_action (any menu path) ToolContribution, ActionContribution
Settings register_settings_page SettingsPageContribution
Components register_component_type, register_component_editor, register_component_model, register_component_deriver ComponentTypeContribution, ComponentDeriver
Project tree register_project_tree_provider, register_component_tree_provider, register_component_menu_provider ProjectTreeNodeContribution, ComponentTreeNodeContribution, ComponentMenuItemContribution
Analyses register_solver, add_solver_config, run_solver, get_solver_results AbstractSolver, SolverConfig
Project data project, edit_component, edit_project, transaction, undo, redo —
Appearance component_color, set_component_color —
Events subscribe, publish, on_project_changed, on_selection_changed, set_selection StudioEvents
Feedback show_status, report_progress, tasks.submit —

Numeric editor fields are described with ParameterField and TableParameterField; a field can hold a number or a formula that uses the project constants. A field's decimals is the precision in its stored unit and follows the value into the display unit: one decimal in g shows four in kg. To show a stored value outside an editor field, use get_unit_manager().format_value(value, quantity, decimals), or format_number for the number alone, from setuav_studio.units. A field with component_type lists the project's components of that type by name and stores the chosen component's ID.

Keep the interface responsive

Run long work through api.tasks.submit so the Qt UI thread never blocks. A solver already runs in the background when Studio runs it.

Analyses

An analysis is a solver class plus a toolbar item that adds a configuration to the project. The solver declares its editable parameters in PARAMETER_FIELDS and returns a SolverResult with summary values, tables, and plots:

from typing import ClassVar

from setuav_studio.api import ParameterField
from setuav_studio.solver import AbstractSolver, SolverResult


class HoverSolver(AbstractSolver):
    PARAMETER_FIELDS: ClassVar[list[ParameterField]] = [
        ParameterField(key="altitude", label="Altitude", unit="m", quantity="altitude"),
    ]

    def run(self) -> SolverResult:
        return SolverResult(solver_id="com.example.hover", config=self.config, name="Hover")

See Writing a Plugin for a complete solver. Register it in activate with api.register_solver("com.example.hover", HoverSolver, icon="..."). The icon is shown next to the solver's analyses in the Project Explorer. Add a toolbar item in the "analysis" group whose callback calls api.add_solver_config with a SolverConfig for the solver.

Component colors

Each component's color is part of the project ("color": "#RRGGBB", gray when absent), and the 3D Viewer paints the surfaces of every scene object drawing a component in that color. A plugin therefore builds its scene objects with the right component_id and does not choose colors for component geometry. Rings, lines and overlays keep their own colors, for markers and other visual aids.

Icons

An icon field accepts an icon name, a file path, or a QIcon. Names resolve in this order: icons registered by plugins, the core icons in src/setuav_studio/assets/icons/, then QtAwesome specifiers such as fa6s.chart-line.

To ship icons, put one SVG per icon, named after the icon, in a folder of the plugin and register the folder:

from pathlib import Path

from setuav_studio.ui.style.icons import register_plugin_icons, unregister_plugin_icons

register_plugin_icons(self.id, Path(__file__).parent / "assets" / "icons")
...
unregister_plugin_icons(self.id)  # in deactivate

assets/icons/hover.svg then becomes the icon hover. The isometric style of the bundled icons is generated by src/setuav_studio/assets/icons/tools/iso.py.