Admin Production ni-theme
Current Publication

SetNumericColorRamp

LabWindows/CVI

SetNumericColorRamp

int SetNumericColorRamp (int panelHandle, int controlID, ColorMapEntry colorMapArray[], int hiColor, int numberOfColors, int interpolateColors);

Purpose

Adds a color ramp to a numeric slide control.

The color ramp consists of colors that correspond to the data values along the scale. If you set interpolateColors to 1, LabWindows/CVI adds smooth color transitions between the data values specified.

Supported Controls

You can use SetNumericColorRamp with numeric slide controls.

Parameters

Input
Name Type Description
panelHandle int Specifier for a particular panel that is currently in memory. You can obtain this handle from functions such as LoadPanel and NewPanel.
controlID int The defined constant, located in the .uir header file, that you assigned to the control in the User Interface Editor, or the ID returned by functions such as NewCtrl and DuplicateCtrl.
colorMapArray ColorMapEntry[] Array of ColorMapEntry structures.

colorMapArray defines how to translate values on the numeric slide into color values. If a data value exactly matches a data value in one of the ColorMapEntry structures, the function converts it to the corresponding color.

Otherwise, the following rules apply:

  • If interpolateColors is zero, SetNumericColorRamp uses the color associated with the next higher data value. If there is no higher data value, the function uses the color specified in hiColor.
  • If interpolateColors is nonzero, SetNumericColorRamp calculates the color using a weighted mean of the colors associated with the color map data values immediately above and below the scale value. If there is no higher data value, the function uses the color specified in hiColor.

colorMapArray can contain up to 255 ColorMapEntry structures that LabWindows/CVI defines as follows:

typedef struct
{

union
{

char valChar;
int valInt;
__int64 valInt64;
short valShort;
float valFloat;
double valDouble;
unsigned char valUChar;
unsigned long valULong;
unsigned __int64 valUInt64;
unsigned short valUShort;

} dataValue;
int color;

} ColorMapEntry;



You do not need to sort the order of the colorMapArray.
hiColor int RGB value that corresponds to the color for numeric scale values that are higher than the highest data value in colorMapArray.
numberOfColors int Number of entries in colorMapArray.

numberOfColors must be less than or equal to 255.

If interpolateColors is nonzero, numberOfColors must be greater than or equal to two.
interpolateColors int Indicates how to assign colors to the numeric scale values that do not exactly match the data values in the colorMapArray.

If you set interpolateColors to zero, the colors shift abruptly along the scale.

If you set interpolateColors to nonzero, the colors blend together smoothly between specified data values.

In all cases, the following rules apply to extreme values:

  • For data values below the lowest color map data value, LabWindows/CVI assigns the color of the lowest color map data value.
  • For data values above the highest color map data value, LabWindows/CVI assigns the color corresponding to the value of hiColor.

Return Value

Name Type Description
status int Return value indicating whether the function was successful. A negative number indicates that an error occurred.

Additional Information

Library: User Interface Library

Include file: userint.h

LabWindows/CVI compatibility: LabWindows/CVI 8.5 and later

Example

Refer to userint\ColorRamps.cws for an example of using the SetNumericColorRamp function.