CPlot: a simple plotter for arrays and CGNS/python trees

Version: 2.5 (20/09/2017)

Author: Onera

Download pdf version.


Preamble

CPlot is a simple plotter for arrays (as defined in Converter documentation) or for CGNS/python trees (pyTrees).

This module is part of Cassiopee, a free open-source pre- and post-processor for CFD simulations.

For use with the Converter array interface, you must import the CPlot module:
import CPlot
Then, in the following, a is an array, and A a list of arrays.
For use with the pyTree interface, you must import the CPlot.PyTree module:
import CPlot.PyTree as CPlot
Then, in the following, a is a zone node and A is a list of zone nodes or a complete pyTree.

Actions

CPlot.display: display arrays/pyTrees:
CPlot.display(A)
Display function has a lot of options that can be specified as arguments: Example of use: array display (array), array display offscreen (array), pyTree display (pyTree).

CPlot.render: force rendering:
CPlot.render()

CPlot.delete: delete zones from plotter. This function does not render. Argument is either a list of zone numbers (struct zones then unstructured zones order) or a list of zone names if zoneNames arg has been provided before to display function:
CPlot.delete([12,13,...]) .or. CPlot.delete(['zone1', 'zone2',...])
Example of use: delete zone from plotter (array), delete zone (pyTree).

CPlot.add: add/insert one array in plotter. This function does not render. For array interface, no is the position of insertion of a in A:
CPlot.add(A, no, a, zoneName=[], renderTag=[])
For the pyTree interface, insert or append a to the base nob, at position noz in the zone list. If noz=-1, append to end of list:
CPlot.add(t, nob, noz, a)

CPlot.replace: performs A[no]=a, keeping plotter coherent. This function does not render. For array interface:
CPlot.replace(A, no, a, zoneName=None, renderTag=None)
For the pyTree interface, performs t[2][nob][2][noz]=a, keeping plotter coherent:
CPlot.replace(t, nob, noz, a)

CPlot.display1D: display 1D curves overlayed to CPlot display. On one screen, you can display many plots using different slots. gridPos specified the position on the screen (see the State.gridSize). bgBlend indicates the blending of the background, var1 and var2 are the name of the variables to be plotted:
CPlot.display1D(A, slot=0, gridPos=(0,0), gridSize=(-1,-1), bgBlend=1., var1='', var2='')
Example of use: display curves (array), display curves (pyTree).

CPlot.pressKey: wait for a key to be pressed:
CPlot.pressKey()

CPlot.finalizeExport: finalize an export. It acts as a barrier if no arg is specified. Must be called after dumping all images of a movie with arg 1:
CPlot.finalizeExport()
Example of use: display in a mpeg file (array)

Set / get functions

CPlot.getState: return the specified state value in plotter:
v = CPlot.getState(stateName)
Example of use: get the state of plotter (array).

CPlot.getSelectedZone: return the currently selected zone. If none is selected, return -1. If multiple zones are selected, return the last selected zone:
n = CPlot.getSelectedZone()
Example of use: get the selected zone (array).

CPlot.getSelectedZones: return the list of selected zones. If none is selected, return []:
N = CPlot.getSelectedZones()
Example of use: get the selected zones (array).

CPlot.getSelectedStatus: return the selected status (1: selected, 0: not selected) of zone nz:
status = CPlot.getSelectedStatus(nz)
Example of use: get the selected status of a zone (array).

CPlot.getActiveZones: return the list of active (displayed) zones:
N = CPlot.getActiveZones()
Example of use: get the active zones (array).

CPlot.getActiveStatus: return the active status (1: active, 0: inactive) of zone nz:
status = CPlot.getActiveStatus(nz)
Example of use: get the active status of a zone (array).

CPlot.getActivePoint: return the last clicked point position (coordinates in 3D world) as a list of three coordinates:
point = CPlot.getActivePoint()
Example of use: get the active point coords (array).

CPlot.getActivePointIndex: return the active point index. For structured grids, return [ind, indc, i,j,k], where ind is the global index of the nearest node to active point, indc is the global index of the nearest center to active point and i,j,k are the indices of nearest node. For unstructured grids, return [ind, indc, no, 0, 0], where ind is the global index of nearest node, indc is the nearest center to the clicked point and no is the number of ind in the center2node connectivity of indc:
ind = CPlot.getActivePointIndex()
Example of use: get the active point index (array).

CPlot.getMouseState: return the current button state of mouse (0: left pressed, 1: middle pressed, 2: righ pressed, 5: not pressed) and the current mouse position (if pressed). Use it when dragging:
(state, ind) = CPlot.getMouseState()
Example of use: return current mouse state (array).

CPlot.getKeyboard: return the pressed keys as a string:
string = CPlot.getKeyboard()
Example of use: get the pressed keys (array).

CPlot.resetKeyboard: reset the pressed key string:
CPlot.resetKeyboard()

CPlot.changeVariable: change displayed variable:
CPlot.changeVariable()
Example of use: change the displayed variable (array).

CPlot.changeStyle: change CPlot display style:
CPlot.changeStyle()
Example of use: change the display style (array).

CPlot.changeBlanking: change the blanking procedure:
CPlot.changeBlanking()
Example of use: change the blanking procedure (array).

CPlot.setState: set CPlot state. The same keywords as display can be used:
CPlot.setState(dim=2, mode=0, ...)
Additional keywords are: Example of use: set the display state (array), set the display state (pyTree).

CPlot.setMode: set CPlot display mode (0 or 'Mesh': means mesh, 1 or 'Solid': means solid, 2 or 'Render': means render, 3 or 'Scalar' means scalar field, 4 or 'Vector' means vector fields):
CPlot.setMode(0) .or. CPlot.setMode('Mesh')
Example of use: set the display mode (array), set the display mode (pyTree).

CPlot.setSelectedZones: set the selected zone status (1: selected, 0: not selected) by zone global number:
CPlot.setSelectedZones([(0,1), (1,0), (2,1),...])
Example of use: set the selected zones (array).

CPlot.unselectAllZones: unselect all zones:
CPlot.unselectAllZones()
Example of use: unselect all zones (array).

CPlot.setActiveZones: set the active (displayed) zones:
CPlot.setActiveZones([(0,1), (1,0), (2,1),...])
Example of use: set the active zones (array).

CPlot.setZoneNames: set the specified zone names:
CPlot.setZoneNames([(0,'Zone0'), (1,'Zone1'), (2,'Zone2'),...])
Example of use: set the specified zone names (array).

CPlot.lookFor: look for selected zone:
CPlot.lookFor()
Example of use: look for selected zone (array), look for selected zone (pyTree).

CPlot.moveCamera: move camera along check points:
CPlot.moveCamera([(0,0,0),(1,0,0),(1,1,0), moveEye=False, N=100, speed=50.)
Example of use: move camera (array), move camera (pyTree).

CPlot.travelLeft/Right/Up/Down/In/Out: travel camera left/Right/Up/Down/In/Out. Xr is the range (in 0.,1.). N is the number of check points:
CPlot.travelLeft(xr, N=100)
Example of use: travel camera (array), travel camera (pyTree).

Set rendering informations in pyTree

CPlot.addRender2Zone: add rendering info to a zone. Info are added in a .RenderInfo user defined node:
b = CPlot.addRender2Zone(a, material, color, blending, meshOverlay, shaderParameters)
Example of use: add render info to a zone (pyTree).

CPlot.addRender2PyTree: add rendering info to a tree. Info are added in a .RenderInfo user defined node. To load the settings to the view, call explicitely CPlot.loadView:
b = CPlot.addRender2PyTree(a, slot, posCam, posEye, dirCam, mode, scalarField, niso, isoScales, isoEdges, isoLight, colormap)
Example of use: add render info to a tree (pyTree).

CPlot.loadView: load a view defined in a slot to the plotter:
CPlot.loadView(a, slot=0)
Example of use: load a view (pyTree).

Commands in CPlot window

CPlot shell command

CPlot can be also used as a shell command:
cplot file
CPlot can read all formats readable with converter.

Return to main userguide