61. gui.viewport — Multiple OpenGL viewports in a Qt widget.

This module provides the MultiCanvas class which allows for multiple OpenGL viewports in a single Qt OpenGL widget.

class gui.viewport.MultiCanvas(parent=None)[source]

An OpenGL canvas with multiple viewports.

The MultiCanvas implements a central QT widget containing one or more QtCanvas widgets.

changeLayout(nvps=None, ncols=None, nrows=None, pos=None, rstretch=None, cstretch=None, reset=False)[source]

Change the lay-out of the viewports on the OpenGL widget.

nvps: number of viewports ncols: number of columns nrows: number of rows pos: list holding the position and span of each viewport [[row,col,rowspan,colspan],…] rstretch: list holding the stretch factor for each row cstretch: list holding the stretch factor for each column (rows/columns with a higher stretch factor take more of the available space) Each of this parameters is optional.

If a number of viewports is given, viewports will be added or removed to match the requested number. By default they are laid out rowwise over two columns.

If ncols is an int, viewports are laid out rowwise over ncols columns and nrows is ignored. If ncols is None and nrows is an int, viewports are laid out columnwise over nrows rows. Alternatively, the pos argument can be used to specify the layout of the viewports.

newView(shared=True, settings=None)[source]

Create a new viewport.

If shared is True, and the MultiCanvas already has one or more viewports, the new viewport will share display lists and textures with the first viewport. Since pyFormex is not using display lists (anymore) and textures are needed to display text, the value defaults to True, and all viewports will share the same textures, unless a viewport is created with a specified value for shared: it can either be another viewport to share textures with, or a value False or None to not share textures with any viewport. In the latter case you will not be able to use text display, unless you initialize the textures yourself.

settings: can be a legal CanvasSettings to initialize the viewport. Default is to copy settings of the current viewport.

Returns the created viewport, which is an instance of QtCanvas.

addView()[source]

Add a new viewport to the widget

setCurrent(canv)[source]

Make the specified viewport the current one.

canv can be either a viewport or viewport number.

viewIndex(view)[source]

Return the index of the specified view

currentView()[source]

Return the index of the current view

showWidget(w)[source]

Show the view w.

removeView()[source]

Remove the last view

Link viewport vp to to

settings()[source]

Return the full configuration needed to restore the MultiCanvas

loadConfig(config)[source]

Reset the viewports size, layout and cameras from a dict

save(filename)[source]

Save the canvas settings to file

load(filename)[source]

Load the canvas settings from file