Viewer

class Viewer[source]

Bases: Scene

The Viewer class is the main entry of compas_viewer. It organizes the scene and create the GUI application.

Parameters:
titlestr, optional

The title of the viewer window. It will override the value in the config file.

fullscreenbool, optional

The fullscreen mode of the viewer window. It will override the value in the config file.

widthint, optional

The width of the viewer window at startup. It will override the value in the config file.

heightint, optional

The height of the viewer window at startup. It will override the value in the config file.

rendermodeLiteral[‘shaded’, ‘ghosted’, ‘wireframe’, ‘lighted’], optional

The display mode of the OpenGL view. It will override the value in the config file.

viewmodeLiteral[‘front’, ‘right’, ‘top’, ‘perspective’], optional

The view mode of the OpenGL view. It will override the value in the config file. In ‘ghosted’ mode, all objects have a default opacity of 0.7.

show_gridbool, optional

Show the XY plane. It will override the value in the config file.

configpathstr, optional

The path to the config folder.

Notes

The viewer has a (main) window with a central OpenGL widget, and a menubar, toolbar, and statusbar. The menubar provides access to all supported ‘actions’. The toolbar is meant to be a ‘quicknav’ to a selected set of actions. The viewer supports rotate/pan/zoom, and object selection via picking or box selections. Currently the viewer uses OpenGL 2.2 and GLSL 120 with a ‘compatibility’ profile.

Examples

from compas_viewer import Viewer
viewer = Viewer()
viewer.show()
Attributes:
rendercompas_viewer.components.render.Render

The render component of the viewer.

controllercompas_viewer.controller.Controller

The controller component of the viewer.

layoutcompas_viewer.layout.Layout

The layout component of the viewer.

Methods

add

Add an item to the scene.

add_action

Add a custom action to the viewer.

clear

Clear the scene.

on

Decorator for callbacks of a dynamic drawing process.

show

Show the viewer window.

Inherited Methods

ToString

Converts the instance to a string.

clear_objects

Clear all objects inside the scene.

copy

Make an independent copy of the data object.

draw

Draw the scene.

from_json

Construct an object of this type from a JSON file.

from_jsonstring

Construct an object of this type from a JSON string.

print_hierarchy

Print the hierarchy of the scene.

remove

Remove a scene object from the scene.

sha256

Compute a hash of the data for comparison during version control using the sha256 algorithm.

to_json

Convert an object to its native data representation and save it to a JSON file.

to_jsonstring

Convert an object to its native data representation and save it to a JSON string.

validate_data

Validate the data against the object's data schema.