App

class App[source]

Bases: object

Viewer app.

Parameters
titlestr, optional

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

version{‘120’, ‘330’}, optional

The version of the GLSL used by the shaders. It will override the value in the config file. Default is '120' with a compatibility profile. The option '330' is not yet available.

widthint, optional

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

heightint, optional

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

viewmode{‘shaded’, ‘ghosted’, ‘wireframe’, ‘lighted’}, optional

The display 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.

viewport{‘front’, ‘right’, ‘top’, ‘perspective’}, optional

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

show_gridbool, optional

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

configdict | filepath, optional

A configuration dict for the App, or a path to a JSON file containing such a dict. Default is None, in which case the default configuration (a Rhino-like preference) is used. More configuration options can be found in the example-control of the page.

controller_classcompas_view2.app.Controller, optional

A custom controller corresponding to a custom config file. Default is None, in which case the default controller is used, matching the default config file.

Notes

The app has a (main) window with a central OpenGL widget (i.e. the ‘view’), 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 app supports rotate/pan/zoom, and object selection via picking or box selections.

Currently the app uses OpenGL 2.2 and GLSL 120 with a ‘compatibility’ profile. Support for OpenGL 3.3 and GLSL 330 with a ‘core’ profile is under development.

The app can currently only be used ‘as-is’. This means that there is no formal mechanism for adding actions to the controller or to add functionality to the shader, other than by extending the core classes. In the future, such mechanism will be provided by allowing the user to overwrite the configuration file and add actions to the controller, without having to modify the package source code.

Currently the app has no scene graph. All added COMPAS objects are wrapped in a viewer object and stored in a dictionary, mapping the object’s ID (id(object)) to the instance.

Examples

>>> from compas_view2 import app
>>> viewer = app.App()
>>> viewer.show()
Attributes
windowPySide2.QtWidgets.QMainWindow

The main window of the application. This window contains the view and any other UI components such as the menu, toolbar, statusbar, …

viewcompas_view2.View

Instance of OpenGL view. This view is the central widget of the main window.

controllercompas_view2.app.Controller

The action controller of the app.

Methods

about

Display the about message as defined in the config file.

add

Add a COMPAS object.

add_reference

Add an object as a reference to another object.

button

Decorator for button actions.

checkbox

Decorator for checkbox actions.

confirm

Confirm the execution of an action.

critical

Display a critical warning.

fps

Update fps info in the status bar.

info

Display info.

init

Initialize the components of the user interface. Parameters ---------- config: dict The overall configuration dictionary.

on

Decorator for callbacks of a dynamic drawing process.

plot

Create a matplotlib canvas as dock widget.

popup

Create a side dock widget.

propertyform

Create a side object tree form widget.

question

Ask a question.

radio

Decorator for radio actions.

remove

Remove an object from the view.

resize

Resize the main window programmatically.

run

Show the viewer window.

sceneform

Create a side object tree form widget.

select

Decorator for combo boxes.

show

Show the viewer window.

sidedock

Create a side dock widget.

slider

Decorator for slider actions.

status

Display a message in the status bar.

tabsform

Create a tabs form widget.

threading

Execute a multi-threaded function.

treeform

Create a side object tree form widget.

warning

Display a warning.