pygimli.viewer.pv

Pyvista based drawing functions used by pygimli.viewer.

Overview

Functions

drawMesh(ax, mesh[, notebook])

param ax

The plotter to draw everything. If none is given, one will be created.

drawModel([ax, mesh, data])

Draw the mesh with given data.

drawSensors(ax, sensors[, diam, color])

Draw the sensor positions to given mesh or the the one in given plotter.

drawSlice(ax, mesh[, normal])

param ax

The Plotter to draw on.

drawStreamLines(ax, mesh, data[, label, radius])

Draw streamlines of given data.

pgMesh2pvMesh(mesh[, data, label])

pyGIMLi’s mesh format is different from pyvista’s needs, some preparation is necessary.

Classes

Show3D(application, **kwargs)

Functions

drawMesh

pygimli.viewer.pv.drawMesh(ax, mesh, notebook=False, **kwargs)[source]
Parameters
  • ax (pyvista.Plotter [optional]) – The plotter to draw everything. If none is given, one will be created.

  • mesh (pg.Mesh) – The mesh to show.

  • notebook (bool [False]) – Sets the plotter up for jupyter notebook/lab.

  • cmap (str ['viridis']) – The colormap string.

Returns

ax – The plotter

Return type

pyvista.Plotter [optional]

drawModel

pygimli.viewer.pv.drawModel(ax=None, mesh=None, data=None, **kwargs)[source]

Draw the mesh with given data.

Parameters
  • ax (pyvista.Plotter [None]) – Pyvista’s basic Plotter to add the mesh to.

  • mesh (pg.Mesh) – The Mesh to plot.

  • data (iterable) – Data that should be displayed with the mesh.

Returns

ax – The plotter

Return type

pyvista.Plotter [optional]

drawSensors

pygimli.viewer.pv.drawSensors(ax, sensors, diam=0.01, color='grey', **kwargs)[source]

Draw the sensor positions to given mesh or the the one in given plotter.

Parameters
  • ax (pyvista.Plotter) – The plotter to draw everything. If none is given, one will be created.

  • sensors (iterable) – Array-like object containing tuple-like (x, y, z) positions.

  • diam (float [0.01]) – Radius of sphere markers.

  • color (str ['grey']) – Color of sphere markers.

Returns

ax – The plotter containing the mesh and drawn electrode positions.

Return type

pyvista.Plotter

Examples using pygimli.viewer.pv.drawSensors

drawSlice

pygimli.viewer.pv.drawSlice(ax, mesh, normal=[1, 0, 0], **kwargs)[source]
Parameters
  • ax (pyvista.Plotter) – The Plotter to draw on.

  • mesh (pg.Mesh) – The mesh to take the slice out of.

  • normal (list [[1, 0, 0]]) – Coordinates to orientate the slice.

Returns

ax – The plotter containing the mesh and drawn electrode positions.

Return type

pyvista.Plotter

Note

Possible kwargs are: normal: tuple(float), str origin: tuple(float) generate_triangles: bool, optional contour: bool, optional

They can be found at https://docs.pyvista.org/core/filters.html#pyvista.CompositeFilters.slice

Examples using pygimli.viewer.pv.drawSlice

drawStreamLines

pygimli.viewer.pv.drawStreamLines(ax, mesh, data, label=None, radius=0.01, **kwargs)[source]

Draw streamlines of given data.

PyVista streamline needs a vector field of gradient data per cell.

Parameters
  • ax (pyvista.Plotter [None]) – The plotter that should be used for visualization.

  • mesh (pyvista.UnstructuredGrid|pg.Mesh [None]) – Structure to plot the streamlines in to. If its a pv grid a check is performed if the data set is already contained.

  • data (iterable [None]) – Values used for streamlining.

  • label (str) – Label for the data set. Will be searched for within the data.

  • radius (float [0.01]) – Radius for the streamline tubes.

Note

All kwargs will be forwarded to pyvistas streamline filter: https://docs.pyvista.org/core/filters.html?highlight=streamlines#pyvista.DataSetFilters.streamlines

Examples using pygimli.viewer.pv.drawStreamLines

pgMesh2pvMesh

pygimli.viewer.pv.pgMesh2pvMesh(mesh, data=None, label=None)[source]

pyGIMLi’s mesh format is different from pyvista’s needs, some preparation is necessary.

Parameters
  • mesh (pg.Mesh) – Structure generated by pyGIMLi to display.

  • data (iterable) – Parameter to distribute to cells/nodes.

Classes

Show3D

class pygimli.viewer.pv.Show3D(application, **kwargs)[source]

Bases: PyQt5.QtWidgets.QMainWindow

__init__(application, **kwargs)[source]

pyGIMLi’s GUI for pyvista’s QtInteractor class. All kwargs are being forwarded to that.

Note

Everything pyvista.Plotter would accept: https://docs.pyvista.org/plotting/plotting.html#plotter

addMesh(mesh, data=None, **kwargs)[source]

Add a mesh to the pyqt frame.

Parameters
  • mesh (pg.Mesh) – pyGIMLi created mesh.

  • data (iterable) – Data belonging to the mesh.

Note

**kwargs
label: str

A label for the given data.

cmap: str

The MPL colormap that should be used to display parameters.

allowMeshParameters()[source]

Make data from the given mesh accessible via GUI.

Note

This apparently needs to happen when using the gui since on call the cell_arrays will be emptied…

exportMesh()[source]

Save the displayed data as VTK.

resetExtrema(_btn=False, fromGlobal=False)[source]

Reset user chosen values to the original ones.

Parameters
  • _btn (bool [False]) – Catch the default that comes with the button signal.

  • fromGlobal (bool [False]) – Flag for condition.. is set when resetting user/global limits.

setGlobalLimits()[source]

Manipulate the user limits of the dictionary storing all data.

setupMenu()[source]

Create the menubar on top of frame and provide actions.

setupWidget(**kwargs)[source]
showHotKeys()[source]
takeScreenShot()[source]

Save the scene as image.

toggleBbox()[source]

Toggle the visibility of the axis grid surrounding the model.

updateParameterView(param=None)[source]

Change the view to given Parameter values.

Parameters

param (Current text of the just triggered QComboBox) –

Note

May be overloaded.

updateScalarBar()[source]

When user set limits are made and finished/accepted the color bar needs to change.

wait()[source]

overload