addons

Create additional objects like axes, legends, lights, etc..

Axes

vedo.addons.Axes(obj=None, xtitle=None, ytitle=None, ztitle=None, xrange=None, yrange=None, zrange=None, c=None, numberOfDivisions=None, digits=None, limitRatio=0.04, axesLineWidth=1, gridLineWidth=1, htitle='', hTitleSize=0.03, hTitleFont=None, hTitleItalic=True, hTitleColor=None, hTitleJustify='bottom-center', hTitleRotation=0, hTitleOffset=0, 0.01, 0, titleDepth=0, titleFont='', textScale=1.0, xTitlePosition=0.95, yTitlePosition=0.95, zTitlePosition=0.95, xTitleOffset=0.025, yTitleOffset=0.0275, zTitleOffset=0.02, xTitleJustify=None, yTitleJustify=None, zTitleJustify=None, xTitleRotation=0, yTitleRotation=0, zTitleRotation=0, xTitleBox=False, yTitleBox=False, xTitleSize=0.025, yTitleSize=0.025, zTitleSize=0.025, xTitleColor=None, yTitleColor=None, zTitleColor=None, xTitleBackfaceColor=None, yTitleBackfaceColor=None, zTitleBackfaceColor=None, xTitleItalic=0, yTitleItalic=0, zTitleItalic=0, xyGrid=True, yzGrid=True, zxGrid=False, xyGrid2=False, yzGrid2=False, zxGrid2=False, xyShift=0, yzShift=0, zxShift=0, xyGridTransparent=False, yzGridTransparent=False, zxGridTransparent=False, xyGrid2Transparent=False, yzGrid2Transparent=False, zxGrid2Transparent=False, xyPlaneColor=None, yzPlaneColor=None, zxPlaneColor=None, xyGridColor=None, yzGridColor=None, zxGridColor=None, xyAlpha=0.05, yzAlpha=0.05, zxAlpha=0.05, xyFrameLine=None, yzFrameLine=None, zxFrameLine=None, xyFrameColor=None, yzFrameColor=None, zxFrameColor=None, xLineColor=None, yLineColor=None, zLineColor=None, xHighlightZero=False, yHighlightZero=False, zHighlightZero=False, xHighlightZeroColor='r', yHighlightZeroColor='g', zHighlightZeroColor='b', showTicks=True, xTickLength=0.015, yTickLength=0.015, zTickLength=0.015, xTickThickness=0.0025, yTickThickness=0.0025, zTickThickness=0.0025, xMinorTicks=1, yMinorTicks=1, zMinorTicks=1, tipSize=None, labelFont='', xLabelColor=None, yLabelColor=None, zLabelColor=None, xLabelSize=0.016, yLabelSize=0.016, zLabelSize=0.016, xLabelOffset=0.015, yLabelOffset=0.015, zLabelOffset=0.01, xLabelRotation=0, yLabelRotation=0, zLabelRotation=0, xValuesAndLabels=None, yValuesAndLabels=None, zValuesAndLabels=None, xUseBounds=True, yUseBounds=False, zUseBounds=False, useGlobal=False, xInverted=False, yInverted=False, zInverted=False, tol=0.0001)[source]

Draw axes for the input object. Returns an Assembly object.

  • xtitle, [‘x’], x-axis title text

  • xrange, [None], x-axis range in format (xmin, ymin), default is automatic.

  • numberOfDivisions, [None], approximate number of divisions on the longest axis

  • axesLineWidth, [1], width of the axes lines

  • gridLineWidth, [1], width of the grid lines

  • titleDepth, [0], extrusion fractional depth of title text

  • xyGrid, [True], show a gridded wall on plane xy

  • yzGrid, [True], show a gridded wall on plane yz

  • zxGrid, [True], show a gridded wall on plane zx

  • zxGrid2, [False], show zx plane on opposite side of the bounding box

  • xyGridTransparent [False], make grid plane completely transparent

  • xyGrid2Transparent [False], make grid plane completely transparent on opposite side box

  • xyPlaneColor, [‘gray’], color of the plane

  • xyGridColor, [‘gray’], grid line color

  • xyAlpha, [0.15], grid plane opacity

  • xyFrameLine, [0], add a frame for the plane, use value as the thickness

  • xyFrameColor, [None], color for the frame of the plane

  • showTicks, [True], show major ticks

  • digits, [None], use this number of significant digits in scientific notation

  • titleFont, [‘’], font for axes titles

  • labelFont, [‘’], font for numeric labels

  • textScale, [1.0], global scaling factor for all text elements (titles, labels)

  • htitle, [‘’], header title

  • hTitleSize, [0.03], header title size

  • hTitleFont, [None], header font (defaults to titleFont)

  • hTitleItalic, [True], header font is italic

  • hTitleColor, [None], header title color (defaults to xTitleColor)

  • hTitleJustify, [‘bottom-center’], origin of the title justification

  • hTitleOffset, [(0,0.01,0)], control offsets of header title in x, y and z

  • xTitlePosition, [0.32], title fractional positions along axis

  • xTitleOffset, [0.05], title fractional offset distance from axis line

  • xTitleJustify, [None], title justification

  • xTitleRotation, [0], add a rotation of the axis title

  • xTitleBox, [False], add a box around title text

  • xLineColor, [automatic], color of the x-axis

  • xTitleColor, [automatic], color of the axis title

  • xTitleBackfaceColor, [None], color of axis title on its backface

  • xTitleSize, [0.025], size of the axis title

  • ‘xTitleItalic’, [0], a bool or float to make the font italic

  • xHighlightZero, [True], draw a line highlighting zero position if in range

  • xHighlightZeroColor, [autom], color of the line highlighting the zero position

  • xTickLength, [0.005], radius of the major ticks

  • xTickThickness, [0.0025], thickness of the major ticks along their axis

  • xMinorTicks, [1], number of minor ticks between two major ticks

  • xValuesAndLabels [], assign custom tick positions and labels [(pos1, label1), …]

  • xLabelColor, [automatic], color of numeric labels and ticks

  • xLabelPrecision, [2], nr. of significative digits to be shown

  • xLabelSize, [0.015], size of the numeric labels along axis

  • ‘xLabelRotation’, [0], numeric labels rotation (can be a list of 3 rotations)

  • xLabelOffset, [0.025], offset of the numeric labels

  • tipSize, [0.01], size of the arrow tip

  • limitRatio, [0.04], below this ratio don’t plot smaller axis

  • xUseBounds, [True], keep into account space occupied by labels when setting camera

  • xInverted [False], invert labels order and direction (only visually!)

Example
from vedo import Box, show
b = Box(pos=(1,2,3), length=8, width=9, height=7).alpha(0)
ax = Axes(b, c='k')  # returns Assembly object
show(b, ax)

customAxes1.py customAxes1.py customAxes2.py customAxes3.py

customIndividualAxes.py customIndividualAxes.py

Goniometer

vedo.addons.Goniometer(p1, p2, p3, font='', arcSize=0.4, fill=0.1, s=1, italic=0, rotation=0, prefix='', c=0.2, 0, 0, alpha=1, lw=1, precision=3)[source]

Build a graphical goniometer to measure the angle formed by 3 points in space.

Parameters
  • p1 (list) – first point.

  • p2 (list) – the vertex point.

  • p3 (list) – the last point defining the angle.

  • font (str, optional) – Font name to be used. The default is “”.

  • arcSize (float, optional) – dimension of the arc wrt the smallest axis. The default is 0.4.

  • fill (bool, optional) – fill the arc area. The default is 0.1.

  • s (float, optional) – size of the text. The default is 1.

  • italic (float, bool, optional) – italic text. The default is 0.

  • rotation (float, optional) – rotation of text in degrees. The default is 0.

  • prefix (str, optional) – append this string to the numeric value of the angle. The default is “”.

  • c (list, optional) – color of the goniometer. The default is (0.2, 0, 0).

  • alpha (float, optional) – transparency level. The default is 1.

  • lw (float, optional) – line width. The default is 1.

  • precision (int, optional) – number of significant digits. The default is 3.

goniometer.py goniometer.py

Light

vedo.addons.Light(pos, focalPoint=0, 0, 0, angle=180, c='white', intensity=1, removeOthers=False)[source]

Generate a source of light placed at pos, directed to focal point. Returns a vtkLight object.

Parameters
  • focalPoint – focal point, if this is a vedo object use its position.

  • angle – aperture angle of the light source

  • c – set the light color

  • intensity (float) – intensity value between 0 and 1.

  • removeOthers (bool) – remove all other lights in the scene (in this case a Plotter object must already exist)

Hint

lights.py

Ruler

vedo.addons.Ruler(p1, p2, unitScale=1, label='', s=None, font='', italic=0, prefix='', units='', c=0.2, 0.1, 0.1, alpha=1, lw=1, precision=3, labelRotation=0, axisRotation=0, tickAngle=90)[source]

Build a 3D ruler to indicate the distance of two points p1 and p2.

Parameters
  • label (str) – alternative fixed label to be shown

  • unitScale (float) – factor to scale units (e.g. μm to mm)

  • s (float) – size of the label

  • font (str) – font name

  • italic (float) – italicness of the font [0,1]

  • units (str) – string to be appended to the numeric value

  • lw (float) – line width in pixel units

  • precision (int) – nr of significant digits to be shown

  • labelRotation (float) – initial rotation of the label around the z-axis

  • axisRotation (float) – initial rotation of the line around the main axis

  • tickAngle (float) – initial rotation of the line around the main axis

goniometer.py goniometer.py

addButton

vedo.addons.addButton(fnc, states='On', 'Off', c='w', 'w', bc='dg', 'dr', pos=20, 40, size=24, font='Normografo', bold=False, italic=False, alpha=1, angle=0)[source]

Add a button to the renderer window.

Parameters
  • states (list) – a list of possible states [‘On’, ‘Off’]

  • c – a list of colors for each state

  • bc – a list of background colors for each state

  • pos – 2D position in pixels from left-bottom corner

  • size – size of button font

  • font (str) – font type (arial, courier, times)

  • bold (bool) – bold face (False)

  • italic (bool) – italic face (False)

  • alpha (float) – opacity level

  • angle (float) – anticlockwise rotation in degrees

buttons.py buttons.py

addCutterTool

vedo.addons.addCutterTool(obj, mode='box')[source]

Create handles to cut away parts of a mesh or volume.

The cutting shape can be either a box, a plane or a sphere.

Parameters

mode (str) – the cutting shape.

cutter.py cutter.py

addIcon

vedo.addons.addIcon(mesh, pos=3, size=0.08)[source]

Add an inset icon mesh into the renderer.

Parameters
  • pos – icon position in the range [1-4] indicating one of the 4 corners, or it can be a tuple (x,y) as a fraction of the renderer size.

  • size (float) – size of the icon space.

icon icon.py

addLegend

vedo.addons.addLegend()[source]

addScalarBar

vedo.addons.addScalarBar(obj, pos=0.8, 0.05, title='', titleYOffset=15, titleFontSize=12, size=None, None, nlabels=None, c=None, horizontal=False, useAlpha=True)[source]

Add a 2D scalar bar for the specified obj.

param list pos

fractional x and y position in the 2D window

param list size

size of the scalarbar in pixel units (width, heigth)

param int nlabels

number of numeric labels to be shown

param bool useAlpha

retain trasparency in scalarbar

param bool horizontal

show in horizontal layout

addScalarBar3D

vedo.addons.addScalarBar3D(obj, pos=None, sx=None, sy=None, title='', titleFont='', titleXOffset=- 1.5, titleYOffset=0.0, titleSize=1.5, titleRotation=0.0, nlabels=9, labelFont='', labelOffset=0.375, italic=0, c=None, useAlpha=True, drawBox=True, aboveText=None, belowText=None, nanText='NaN')[source]

Draw a 3D scalar bar.

obj input can be:
  • a list of numbers,

  • a list of two numbers in the form (min, max),

  • a Mesh already containing a set of scalars associated to vertices or cells,

  • if None the last object in the list of actors will be used.

Parameters
  • sx (float) – thickness of scalarbar

  • sy (float) – length of scalarbar

  • title (str) – scalar bar title

  • titleXOffset (float) – horizontal space btw title and color scalarbar

  • titleYOffset (float) – vertical space offset

  • titleSize (float) – size of title wrt numeric labels

  • titleRotation (float) – title rotation in degrees

  • nlabels (int) – number of numeric labels

  • labelOffset (float) – space btw numeric labels and scale

  • useAlpha (bool) – render transparency of the color bar, otherwise ignore

  • drawBox (bool) – draw a box around the colorbar (useful with useAlpha=True)

addSlider2D

vedo.addons.addSlider2D(sliderfunc, xmin, xmax, value=None, pos=4, title='', font='', titleSize=1, c=None, showValue=True)[source]

Add a slider widget which can call an external custom function.

Parameters
  • sliderfunc – external function to be called by the widget

  • xmin (float) – lower value

  • xmax (float) – upper value

  • value (float) – current value

  • pos (list) – position corner number: horizontal [1-5] or vertical [11-15] it can also be specified by corners coordinates [(x1,y1), (x2,y2)]

  • title (str) – title text

  • font (str) – title font

  • titleSize (float) – title text scale [1.0]

  • showValue (bool) – if true current value is shown

sliders1.py sliders1.py sliders2.py

addSlider3D

vedo.addons.addSlider3D(sliderfunc, pos1, pos2, xmin, xmax, value=None, s=0.03, t=1, title='', rotation=0, c=None, showValue=True)[source]

Add a 3D slider widget which can call an external custom function.

Parameters
  • sliderfunc – external function to be called by the widget

  • pos1 (list) – first position coordinates

  • pos2 (list) – second position coordinates

  • xmin (float) – lower value

  • xmax (float) – upper value

  • value (float) – initial value

  • s (float) – label scaling factor

  • t (float) – tube scaling factor

  • title (str) – title text

  • c – slider color

  • rotation (float) – title rotation around slider axis

  • showValue (bool) – if True current value is shown

sliders3d.py sliders3d.py

buildRulerAxes

vedo.addons.buildRulerAxes(inputobj, xtitle='', ytitle='', ztitle='', xlabel='', ylabel='', zlabel='', xpad=0.05, ypad=0.04, zpad=0, font='Normografo', s=None, italic=0, units='', c=0.2, 0, 0, alpha=1, lw=1, precision=3, labelRotation=0, axisRotation=0, xycross=True)[source]

Build 3D rulers to indicate the sizes of the input scene or object.

Parameters
  • xtitle (str) – name of the axis or title

  • xlabel (str) – alternative fixed label to be shown instead of the distance

  • xpad (float) – gap distance from the x-axis

  • s (float) – size of the label

  • font (str) – font name

  • italic (float) – italicness of the font [0,1]

  • units (str) – string to be appended to the numeric value

  • lw (float) – line width in pixel units

  • precision (int) – nr of significant digits to be shown

  • labelRotation (float) – initial rotation of the label around the z-axis

  • axisRotation (float) – initial rotation of the line around the main axis

  • xycross (bool) – show two back crossing lines in the xy plane

goniometer.py goniometer.py