Skip to content

ScalarBarActor ​

Introduction ​

vtkScalarBarActor creates a scalar bar with tick marks. A scalar bar is a legend that indicates to the viewer the correspondence between color value and data value. The legend consists of a rectangular bar made of rectangular pieces each colored a constant value. Since vtkScalarBarActor is a subclass of vtkActor2D, it is drawn in the image plane (i.e., in the renderer's viewport) on top of the 3D graphics window.

Methods ​

computeBarSize ​

Compute the bar position and size within the box, and return the size of a single bar segment in normalized bar coordinates.

ArgumentTypeRequiredDescription
textSizesITextSizesYes

createPolyDataForOneLabel ​

Append the quad for a single label to results, advancing its point and cell indices. Does nothing when the text is absent from the texture atlas.

ArgumentTypeRequiredDescription
textStringYes
posVector3Yesanchor point in normalized viewport coordinates
alignmentYeshorizontal and vertical anchoring of the text
orientationYestext orientation
offsetVector2Yespixel offset applied to the anchor point
resultsIResultYesaccumulator that is mutated in place

extend ​

Method use to decorate a given object (publicAPI+model) with vtkScalarBarActor characteristics.

ArgumentTypeRequiredDescription
publicAPIYesobject on which methods will be bounds (public)
modelYesobject on which data structure will be bounds (protected)
initialValuesIScalarBarActorInitialValuesNo(default: {})

getActors ​

getAutoLayout ​

getAutomated ​

getAxisLabel ​

getAxisTextStyle ​

getAxisTextStyle ​

getAxisTitlePixelOffset ​

Pixel offset between the bar and the axis title, as used for this view.

getAxisTitlePixelOffset ​

getBarActor ​

Get the actor drawing the colored bar segments.

getBarPosition ​

getBarPositionByReference ​

getBarSize ​

getBarSizeByReference ​

getBoxPosition ​

Position of the box the bar and its labels are laid out in, in normalized viewport coordinates.

getBoxPosition ​

getBoxPositionByReference ​

getBoxPositionByReference ​

getBoxSize ​

Size of the box the bar and its labels are laid out in, in normalized viewport coordinates.

getBoxSize ​

getBoxSizeByReference ​

getBoxSizeByReference ​

getDrawAboveRangeSwatch ​

getDrawBelowRangeSwatch ​

getDrawNanAnnotation ​

getGenerateTicks ​

getLastAspectRatio ​

The view aspect ratio recorded at the last updateAPISpecificData().

getLastSize ​

The view size in pixels recorded at the last updateAPISpecificData().

getLastTickBounds ​

The scalar range the bar was last built for.

getNestedProps ​

getOrientation ​

Get the current bar orientation setting

getRenderable ​

Get the actor this helper renders for.

getScalarsToColors ​

getTickLabelPixelOffset ​

Pixel offset between the bar and the tick labels, as used for this view.

getTickLabelPixelOffset ​

getTickPositions ​

Normalized position along the tick segment for each tick. When unset, the position is derived from the tick value and the mapping range.

getTickStrings ​

The label drawn for each entry of getTicks().

getTickTextStyle ​

getTickTextStyle ​

getTicks ​

The scalar values the ticks are drawn at.

getTmActor ​

Get the actor drawing the text label quads.

getTopTitle ​

Whether the axis title is drawn above the bar rather than beside it.

newInstance ​

Method use to create a new instance of vtkScalarBarActor

recomputeBarSegments ​

Rebuild the bar segments (NaN, Below, ticks, Above) from the current settings.

ArgumentTypeRequiredDescription
textSizesITextSizesYes

resetAutoLayoutToDefault ​

resetGenerateTicksToDefault ​

setAutoLayout ​

ArgumentTypeRequiredDescription
autoLayoutYes

setAutomated ​

ArgumentTypeRequiredDescription
automatedBooleanYes

setAxisLabel ​

ArgumentTypeRequiredDescription
axisLabelStringYes

setAxisTextStyle ​

ArgumentTypeRequiredDescription
axisTextStyleIStyleYes

setAxisTitlePixelOffset ​

Pixel offset between the bar and the axis title, as used for this view.

ArgumentTypeRequiredDescription
axisTitlePixelOffsetNumberYes

setAxisTitlePixelOffset ​

ArgumentTypeRequiredDescription
axisTitlePixelOffsetNumberYes

setBarPosition ​

ArgumentTypeRequiredDescription
barPositionVector2Yes

setBarPositionFrom ​

ArgumentTypeRequiredDescription
barPositionVector2Yes

setBarSize ​

ArgumentTypeRequiredDescription
barSizeSizeYes

setBarSizeFrom ​

ArgumentTypeRequiredDescription
barSizeSizeYes

setBoxPosition ​

ArgumentTypeRequiredDescription
boxPositionVector2Yes

setBoxPosition ​

ArgumentTypeRequiredDescription
boxPositionVector2Yes

setBoxPositionFrom ​

ArgumentTypeRequiredDescription
boxPositionVector2Yes

setBoxPositionFrom ​

ArgumentTypeRequiredDescription
boxPositionVector2Yes

setBoxSize ​

ArgumentTypeRequiredDescription
boxSizeSizeYes

setBoxSize ​

ArgumentTypeRequiredDescription
boxSizeSizeYes

setBoxSizeFrom ​

ArgumentTypeRequiredDescription
boxSizeSizeYes

setBoxSizeFrom ​

ArgumentTypeRequiredDescription
boxSizeSizeYes

setDrawAboveRangeSwatch ​

Set whether the Above range swatch should be rendered or not

ArgumentTypeRequiredDescription
drawAboveRangeSwatchBooleanYes

setDrawBelowRangeSwatch ​

Set whether the Below range swatch should be rendered or not

ArgumentTypeRequiredDescription
drawBelowRangeSwatchBooleanYes

setDrawNanAnnotation ​

Set whether the NaN annotation should be rendered or not.

ArgumentTypeRequiredDescription
drawNanAnnotationBooleanYes

setGenerateTicks ​

Sets the function used to generate legend ticks.

This function takes a vtkScalarBarActorHelper and returns true on success. To have the desired effect, the function must call: helper.setTicks(ticks: num[]) and helper.setTickStrings(tickStrings: string[]).

After setting the generateTicks function you must regenerate the vtkScalarBarActor for your changes to take effect. One way to do that is:

 const mapper = scalarBarActor.getMapper()
 if (mapper) {
   mapper.getLookupTable().resetAnnotations()
 }
ArgumentTypeRequiredDescription
generateTicksYes

setOrientation ​

Set the orientation of the scalar bar

ArgumentTypeRequiredDescription
orientationYes'horizontal' to force horizontal, 'vertical' to force vertical, or null/undefined for auto

setOrientationToHorizontal ​

Forces the scalar bar to use horizontal orientation regardless of aspect ratio

setOrientationToVertical ​

Forces the scalar bar to use vertical orientation regardless of aspect ratio

setRenderable ​

Bind this helper to an actor. Rebinds the internal actors' property, parent prop and coordinate system, and copies the actor's text styles.

ArgumentTypeRequiredDescription
renderablevtkScalarBarActorYes

setScalarsToColors ​

ArgumentTypeRequiredDescription
scalarsToColorsvtkScalarsToColorsYes

setTickLabelPixelOffset ​

Pixel offset between the bar and the tick labels, as used for this view.

ArgumentTypeRequiredDescription
tickLabelPixelOffsetNumberYes

setTickLabelPixelOffset ​

ArgumentTypeRequiredDescription
tickLabelPixelOffsetYes

setTickPositions ​

Normalized position along the tick segment for each tick.

ArgumentTypeRequiredDescription
tickPositionsArray[Number]Yes

setTickStrings ​

The label drawn for each entry of getTicks().

ArgumentTypeRequiredDescription
tickStringsArray[String]Yes

setTickTextStyle ​

ArgumentTypeRequiredDescription
tickStyleIStyleYes

setTicks ​

The scalar values the ticks are drawn at.

ArgumentTypeRequiredDescription
ticksArray[Number]Yes

setTopTitle ​

Whether the axis title is drawn above the bar rather than beside it.

ArgumentTypeRequiredDescription
topTitleBooleanYes

setVisibility ​

updateAPISpecificData ​

Record the view resolution, camera and render window, and rebuild the texture atlas, bar segments and polydata when anything they depend on has changed.

ArgumentTypeRequiredDescription
sizeVector2Yesthe view size in pixels
cameravtkCameraYes
renderWindowYes

updatePolyDataForBarSegments ​

Rebuild the polydata holding the colored bar segments.

updatePolyDataForLabels ​

Rebuild the polydata holding the label quads and their texture coordinates.

updateTextureAtlas ​

Render every label into the texture atlas and return the resulting text measurements. Only needs to be called when the strings change.