Palettes: ENS_PALETTE
In EnSight each data set variable has four palettes (ENS_PALETTE). For scalar variables only the first palette is used. For vector variables the four palettes correspond to: magnitude, x component, y component, and z component. Other data set variables do not use palettes since parts cannot be directly colored by those variable types (e.g. tensor).
Given a Python handle to a variable (core.VARIABLES[0]), the palettes are accessed by the PALETTE member: core.VARIABLES[0].PALETTE[0].
At this time the ENS_PALETTE Python API exists mainly to support the EnSight Color Editor and Palette Editor dialogs. The API is not a full API to the underlying C API.
Methods:
- get_histogram(width, height) : Get a histogram image of dimension width x height. A byte array is returned that represents an image of the variable histogram. This image is used on the Advanced tab of the Palette Editor dialog.
- get_natural_texture_size() : Get the natural texture size. This returns the natural width of the palette. The natural width defined to be the (number of levels) + (nlevels-1)*(number of colors per level).
- make_texture(width) : Make a 1D color texture. This corresponds to the color palette as drawn at the top of the Palette Editor dialog. The method returns a unsigned byte array of length (width*4*2) consisting of (width) * (BGRA) * 2. The first (width * 4) values contain BGRA where A is always 0xff. The second set of values (width * 4) contain BGRA where A is the actual alpha value. Width should be the value returned by get_natural_texture_size() or perhaps a multiple of it. The color values vary fastest followed then by the texture size and then by 2 (varying alpha).
- clear_last_marker() : Clear the last added marker.
- clear_all_markers() : Clear all markers.
- add_marker_at_value(v) : Add a marker at a value. This adds a solid line of color MARKER_COLOR at the specified value v. v must be within the range of the scalar component.
- add_nuniform_markers(n) : Add n markers uniformly between min and max.
- add_markers_at_levels() : Add markers at node locked knot points.
- invert_colors() : Flip the colors from min to max.
- reverse_levels() : Flip the level values from min to max.
- set_minmax(min, max, doRecord) : Sets the min and max levels. If doRecord is true, an EnSight command is recorded.
- set_range_to_part_minmax() : Sets the palette min and max values to match those of the selected parts.
- set_range_to_viewport_minmax() : Sets the palette min and max values to match those of the visible parts in the current viewport.
- get_time_step_range() : returns a list containing the beginning and ending time steps.
- set_range_to_over_time_minmax(beginStep, endStep) : Sets the palette min and max values to match the values returned over the time range inclusive from beginStep to endStep.
- reset_range_on_time_change_all() : Applies the current value of the attribute RESET_RANGE_ON_TIME_CHANGE to all palettes.
- use_continuous_all() : Applies the current value of USE_CONTINUOUS to all palettes.
- set_point(componentName, whichKnot, position, value, doRecord) : Sets the specified knot point position and values for a single channel. The position and value are normalized. componentName must be one of "red", "green", "blue", "hue", "sat", "val", or "alpha". If doRecord is true, an EnSight command will be recorded.
- get_point(componentName, whichKnot) : Returns [position, value] which are normalized values for the knot point as specified by componentName and whichKnot.
- get_end_point_colors() : Returns a float list of 8 values corresponding to the RGBA (or HSVA) values at the minimum and maximum extents of the palette.
- add_knot(componentName, afterWhichKnot) : Add a knot of the specified component after the specified knot.
- delete_knot(componentName, whichKnot) : Deletes the specified knot for the specified component.
Attributes:
- DESCRIPTION : Gets or sets the 'Palette name'.
- INTERP : Gets or sets the 'Palette interpolation method'. Value is enums.PALETTE_CONTINUOUS, enums.PALETTE_BANDED, or enums.PALETTE_CONSTANT.
- COLORS_PER_LEVEL : Gets or sets the 'Colors per level'.
- COLOR_SPACE : Gets or sets the 'Palette color space'. Value is enums.PALETTE_HSV or enums.PALETTE_RGB.
- SCALE_METHOD : Gets or sets the 'Palette scaling method'. Value is enums.PALETTE_SCALE_LINEAR, enums.PALETTE_SCALE_LOG, or enums.PALETTE_SCALE_QUADRATIC.
- MINMAX : Gets or sets the 'Palette minimum / maximum values'. Value is a list: [minValue, maxValue].
- DEGREE : Gets or sets the 'Palette interpolation degree' used between knot points. Value is either enums.PALETTE_LINEAR or enums.PALETTE_SPLINE.
- HANDLE_UNDEFINED_VALUE : Gets or sets 'Palette handle undefined value' which indicates how to color undefined values. Value is either enums.PALETTE_UNDEFINED_BY_INVISIBLE, enums.PALETTE_UNDEFINED_AS_ZERO_VALUE, or enums.PALETTE_UNDEFINED_BY_PART_COLOR.
- LIMIT_FRINGES : Gets or sets the 'Palette limit fringes' value. Value is either enums.PALETTE_LIMIT_FRINGES_NO, enums.PALETTE_LIMIT_FRINGES_PART_COLOR, or enums.PALETTE_LIMIT_FRINGES_INVISIBLE.
- NODE_LOCK : Gets or sets 'Palette node lock' value used for knot editing of position values between components. Value is either enums.PALETTE_NODE_LOCK_NONE, enums.PALETTE_NODE_LOCK_COLOR, or enums.PALETTE_NODE_LOCK_ALL. enums.PALETTE_NODE_LOCK_COLOR locks the color components and not the alpha component.
- ALPHA_VOLUME_SCALE : Gets and sets the 'alpha volume extent' used by the volume renderer. The value is a floating point number.
- C1_POINTS : Gets or sets the 'component 1 nodes' for the knots. The values are a list of [coordinateList, valueList]. All numbers are normalized. The length of coordinateList and valueList must be the same. The values represent the x position (coordinate) and y position (value) of the knots for the first component (red or hue).
- C2_POINTS : Gets or sets the 'component 2 nodes'.
- C3_POINTS : Gets or sets the 'component 3 nodes'.
- C4_POINTS : Gets or sets the 'component 4 nodes'.
- MARKER_COLOR : Gets or sets the 'Palette marker color' which is always RGBA. Values are a list of [R, G, B, A] floats.
- MARKER_WIDTH : Gets or sets the 'Palette marker width'. Value is an integer.
- MAX_MARKERS : Gets or sets the maximum number of markers.
- NLEVELS : Gets or sets the 'number of levels'.
- LEVELS_AND_COLORS : Gets or sets the 'levels and colors'. Values are a list of N sub lists where N is the number of levels. Each sub list is [levelValue, C1, C2, C3, C4] where C1 through C4 are normalized component values (RGBA or HSVA) as indicated by COLOR_SPACE.
- LEVELS_LOCK : Gets or sets the 'Palette levels node lock'. Setting this will relock the level values to the knot values between the min and max palette values if and only if NODE_LOCK is not enums.PALETTE_NODE_LOCK_NONE. Returns the actual state used. Value is a boolean.
- HISTO_SCALE : Gets or sets the 'Histogram scale factor'. Value is between 0.0 and 2.0 inclusive.
- TIME_RANGE : Gets or sets the 'Palette time range'. Values are an integer list of [minStep, maxStep, useTransient].
- VARIABLE : Returns the associated ENS_VAR for this palette.
- RESET_RANGE_ON_TIME_CHANGE : Gets or sets the 'Palette reset range on time change'. If true, the palette will update its min and max values for the current time step.
- USE_CONTINUOUS : Gets or sets the 'Palette use continuous values for per element variables'. If true, the palette will continuously shade across per-element variables.