Admin Production ni-theme
Current Publication

PlotScaledIntensity

LabWindows/CVI

PlotScaledIntensity

int PlotScaledIntensity (int panelHandle, int controlID, void *zArray, size_t numberOfXPoints, size_t numberOfYPoints, int zDataType, double yGain, double yOffset, double xGain, double xOffset, ColorMapEntry colorMapArray[], int hiColor, size_t numberOfColors, int interpColors, int interpPixels);

Purpose

Draws a solid rectangular plot in a graph control. You can apply scaling factors and offsets to the data values.

The plot consists of pixels whose colors correspond to the magnitude of data values in a two-dimensional array and whose coordinates correspond to the locations of the same data values in the array, scaled by xGain and yGain and offset by xOffset and yOffset. For instance, the pixel associated with zArray[2][3] is located at the following coordinates:

{ (x = 3 × xGain + xOffset), (y = 2 × yGain + yOffset) }

The lower left corner of the plot area is located at

{xOffset, yOffset}

The upper right corner of the plot area is located at

{ (numXpts — 1) × xGain + xOffset, (numYpts — 1) × yGain + yOffset }

where numXpts is the number of x points and numYpts is the number of y points.

Refer to the PlotIntensity function reference for an example of how to plot to an intensity graph. PlotScaledIntensity is similar to PlotIntensity except that it includes additional gain and offset parameters.

Supported Controls

You can use PlotScaledIntensity with graph 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.
zArray void * Array that contains the data values to convert to colors.

The data type must be of the type you specify in zDataType.

The locations at which the colors appear on the graph depend on that location of the data values in zArray. zArray must be a two-dimensional array of the following form:

zArray[numberOfYPoints][numberOfXPoints]

Each element of the array is associated with a pixel on the graph. The pixel associated with element zArray[y][x] is located at the following location on the graph:

{x × xGain + xOffset, y × yGain + yOffset}

numberOfXPoints size_t Number of points to display along the x-axis in each row.

This value must be less than or equal to INT_MAX.
numberOfYPoints size_t Number of points to display along the y-axis in each column.

This value must be less than or equal to INT_MAX.
zDataType int The data type of the elements in zArray and the data type of the color map values.

The following table lists the valid data types.

VAL_CHAR A single byte character.
VAL_SHORT_INTEGER A 2 byte integer.
VAL_INTEGER A 4 byte integer.
VAL_FLOAT A 4 byte floating point value.
VAL_DOUBLE An 8 byte floating point value.
VAL_64BIT_INTEGER An 8 byte integer.
VAL_UNSIGNED_SHORT_INTEGER An unsigned 2 byte integer.
VAL_UNSIGNED_INTEGER An unsigned 4 byte integer.
VAL_UNSIGNED_CHAR An unsigned single byte character.
VAL_UNSIGNED_64BIT_INTEGER An unsigned 8 byte integer.
VAL_SIZE_T An unsigned 4 byte integer (32-bit applications).
An unsigned 8 byte integer (64-bit applications).
VAL_SSIZE_T A 4 byte integer (32-bit applications).
An 8 byte integer (64-bit applications).
VAL_PTRDIFF_T A 4 byte integer (32-bit applications).
An 8 byte integer (64-bit applications).
VAL_UINTPTR_T An unsigned 4 byte integer (32-bit applications).
An unsigned 8 byte integer (64-bit applications).
VAL_INTPTR_T A 4 byte integer (32-bit applications).
An 8 byte integer (64-bit applications).
yGain double The gain to apply to the waveform (yArray) data.

The default value is 1.0.
yOffset double A constant offset to add to the waveform (yArray) data.

The default value is 0.0.
xGain double The scaling factor to apply to the horizontal coordinates that the zArray indices represent.

The pixel associated with element zArray[y][x] is located at the following location on the graph.

{x × xGain + xOffset, y × yGain + yOffset}

The default value is 1.0.
xOffset double Specifies the offset to add to the horizontal coordinates that the zArray indices represent.

The pixel associated with element zArray[y][x] is located at the following location on the graph.

{x × xGain + xOffset, y × yGain + yOffset}

The default value is 0.0.
colorMapArray ColorMapEntry[] Array of ColorMapEntry structures. colorMapArray contains up to 255 ColorMapEntry structures that are defined 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;



colorMapArray defines how to translate data values in zArray into color values. If a data value matches exactly to a data value in one of the ColorMapEntry structures, the function converts it to the corresponding color. Otherwise, the following rules apply:

  • If interpColors is zero, the color associated with the next higher data value is used.
  • If interpColors is nonzero, the color is calculated using a weighted mean of the colors associated with the color map data values immediately above and below the zArray value.

If there is no higher value, the function uses the color specified in hiColor.

The colorMapArray entries do not need to be in sorted order.
hiColor int RGB value to which to translate all zArray values that are higher than the highest data value in colorMapArray.
numberOfColors size_t Number of entries in colorMapArray. numberOfColors must be less than or equal to 255. If interpColors is nonzero, the numberOfColors must be greater than or equal to two.
interpColors int Indicates how to assign colors to zArray data values that do not exactly match the data values in the colorMapArray.

If interpColors is zero, the data value is assigned the color associated with the next higher color map data value.

If interpColors is nonzero, the color is calculated using a weighted mean of the colors associated with the color map data values immediately above and below the zArray value.

Regardless of the value of interpColors, the following rules apply:

  • Data below the lowest color map data value are assigned the color of the lowest color map data value.
  • Data values above the highest color map data value are assigned the value of the hiColor parameter.
interpPixels int Indicates how to color the pixels between the pixels assigned to the zArray values.

If interpPixels is zero, an unassigned pixel is given the same color as the closest assigned pixel.

If interpPixels is nonzero, an unassigned pixel is first given a data value using a weighted mean of the data values associated with the four closest assigned pixels. Then the color is calculated using the color map array.

Performance Considerations If interpPixels is zero, the performance degrades as the number of data points in zArray increases.

If interpPixels is nonzero, the performance degrades as total number of pixels in the plot area increases.

Return Value

Name Type Description
plotHandle int The handle of the new plot that you can use in subsequent function calls to reference the plot.

If the handle is positive, the new plot was successfully added to the graph. Negative values indicate that an error occurred.

Note  If ATTR_DATA_MODE is set to VAL_DISCARD, the function returns 0.

Additional Information

Library: User Interface Library

Include file: userint.h

LabWindows/CVI compatibility: LabWindows/CVI 4.0 and later

Examples

Refer to the following examples that use the PlotScaledIntensity function:

  • userint\graphlegend.cws

    Open example
  • userint\GraphZooming.cws

    Open example
  • userint\intgraph.cws

    Open example