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_class
compas_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
- window
PySide2.QtWidgets.QMainWindow
The main window of the application. This window contains the view and any other UI components such as the menu, toolbar, statusbar, …
- view
compas_view2.View
Instance of OpenGL view. This view is the central widget of the main window.
- controller
compas_view2.app.Controller
The action controller of the app.
- window
Methods
Display the about message as defined in the config file.
Add a COMPAS object.
Add an object as a reference to another object.
Decorator for button actions.
Decorator for checkbox actions.
Confirm the execution of an action.
Display a critical warning.
Update fps info in the status bar.
Display info.
Initialize the components of the user interface. Parameters ---------- config: dict The overall configuration dictionary.
Decorator for callbacks of a dynamic drawing process.
Create a matplotlib canvas as dock widget.
Create a side dock widget.
Create a side object tree form widget.
Ask a question.
Decorator for radio actions.
Remove an object from the view.
Resize the main window programmatically.
Show the viewer window.
Create a side object tree form widget.
Decorator for combo boxes.
Show the viewer window.
Create a side dock widget.
Decorator for slider actions.
Display a message in the status bar.
Create a tabs form widget.
Execute a multi-threaded function.
Create a side object tree form widget.
Display a warning.