CPlot: a simple plotter for arrays and CGNS/python trees
Version: 2.5 (20/09/2017)
Author: Onera

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:
- dim: 1: 1D, 2: 2D, 3: 3D (default: 3)
- mode: 0 or 'Mesh': mesh, 1 or 'Solid': solid, 2 or 'Render': render, 3 or 'Scalar': scalar field, 4 or 'Vector': vector field (default: 0)
- scalarField: scalar field number or scalarField name
- displayBB: 0: bounding box display (default: 1)
- displayInfo: 0 means no info display (default: 1)
- displayIsoLegend: 0 means no iso legend display (default: 0)
- meshStyle: 0: white solid and red wireframe, 1: colored wireframe, 2: colored solid and wireframe, 3: cyan solid and black wireframe (default: 2)
- solidStyle: 0: blue, 1: colored by zone, 3: cyan (default: 1)
- scalarStyle: 0: banded, 1: banded+mesh, 2: lines, 3: lines+mesh (default: 0)
- colormap: 0: Blue2Red, 2: Green2Red, 4: Black2White, 6: White2Black, 8: Diverging (default: 0)
- niso: number of isos (default: 25)
- isoEdges: width of iso edges for scalar display (default: -1)
- isoScales: list of min and max of a variable [novar, niso, min, max] (default: [])
- win: (sizeWinX, sizeWinY) window size (default: 700,700)
- posCam: (x,y,z) camera position
- posEye: (x,y,z) eye position
- dirCam: (x,y,z) camera direction (default: 0,0,1)
- viewAngle: camera angle in degrees (default: 50)
- bgColor: 0-10 (default: 0)
- shadow: 0-1 (default: 0)
- dof: 0-1 (default: 0)
- stereo: 1 or 2 means red/cyan anaglyph (default: 0)
- stereoDist: distance between eyes for stereo.
- export: file name for export
- exportResolution: resolution for export ("1200x900")
- zoneNames: optional list of zone names (same size as arrays,
struct zones, then unstruct zones)
- renderTags: optional list of render tags (same size as arrays,
struct zones, then unstruct zones)
- offscreen: 1 means offscreen rendering (mesa), 2 means
offscreen rendering (openGL) (default: 0)
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:
- ghostifyDeactivatedZones: 1 means deactivated zones will appear blended.
- edgifyActivatedZones: 1 means activated zones will appear as edges.
- edgifyDeactivatedZones: 1 means deactivated zones will appear as edges.
- message: "A string" or "Clear"
- viewAngle: the camera angle (default: 50 degrees).
- cursor: mouse cursor type (0: normal, 1: cross, 2: wait).
- lightOffset: offset to default light position (default: (0,0)).
- dofPower: power of depth of field effect (default: 6.).
- selectionStyle: style for selection (default: 0).
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
- f: fit view.
- Ctrl+f: full screen.
- Arrows or left mouse: move around.
- Shift + Arrows or right mouse: strafe.
- Ctrl + Arrows or Ctrl + left mouse: move your head.
- Ctrl + right mouse: tilt your head.
- Shift + left mouse: select zone (mouse plugin).
- Shift + Ctrl + left mouse: multiple select (mouse plugin).
- Ctrl + left mouse: Accurate select (mouse plugin).
- Shift + right mouse: deactivate zone (mouse plugin).
- Shift + double left mouse: center view.
- o or left mouse: move up.
- p or left mouse: move down.
- 1-Shift+1 : display fields (primary variable).
- 2-Shift+2 : change secondary variable.
- Space bar : mesh display.
- Shift+Space bar : solid display.
- m-M: toggle between 1D, 2D, 3D mode.
- z or Z: change selected zone.
- a or A: activate/deactivate a zone.
- l: look for active zone.
- c: change render appearance (colormaps,...)
- i or I or Ctrl+i: change displayed i plane.
- j or J or Ctrl+j: change displayed j plane.
- k or K or Ctrl+k: change displayed k plane.
- r: reload files.
- q: quit.
- Esc: display CPlot menu.
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