Skip to content

Tree Form¤

compas_model.viewer.treeform ¤

Classes¤

ModelTreeForm ¤

ModelTreeForm(
    controller: ModelViewer,
    selection_changed: Callable[[list[Element]], None] | None = None,
    projection: Literal["hierarchy", "types", "collections"] = "hierarchy",
)

Tree widget synchronized with a model viewer controller.

Parameters:

  • controller (ModelViewer) –

    Controller providing model hierarchy and concrete scene objects.

  • selection_changed (Callable[[list[Element]], None] | None, default: None ) –

    Optional callback receiving the selected model elements.

Notes

Tree items retain only element GUIDs. Model.tree remains the source of hierarchy, and selection and visibility remain properties of the concrete ElementObject instances managed by the controller.

Methods:¤
item_for_element ¤
item_for_element(element: Element) -> QTreeWidgetItem

Return the tree item representing an element.

item_for_guid ¤
item_for_guid(guid: str) -> QTreeWidgetItem

Return the tree item registered for an element GUID.

update ¤
update(refresh: bool = False) -> None

Synchronize tree selection and visibility from scene objects.

Parameters:

  • refresh (bool, default: False ) –

    If True, rebuild items from the current model tree.

Functions:¤

install_model_tree ¤

install_model_tree(
    controller: ModelViewer,
    selection_changed: Callable[[list[Element]], None] | None = None,
) -> ModelTreeForm

Replace COMPAS Viewer's generic scene tree with a model tree.

Parameters:

  • controller (ModelViewer) –

    Model viewer controller whose viewer UI should be updated.

Returns: