Admin Production ni-theme
Current Publication

OGLSetPlotColorScheme

LabWindows/CVI

OGLSetPlotColorScheme

int OGLSetPlotColorScheme (int panelHandle, int OGLControlId, int plotHandle, int colorScheme, const ColorMapEntry *colorMapEntries, int numberOfColors, int highColor, int interpolateColors, const int *colorArrayEntries, int xSize, int ySize);

Purpose

Sets the color scheme to be used when the plot is drawn and also sets the data that may be required for each of those color schemes.

You also can use OGLSetPlotAttribute to set the color scheme and the data required.

Parameters

Input
Name Type Description
panelHandle int The specifier for a particular panel that is currently in memory.

This handle will have been returned by the LoadPanel, NewPanel, or DuplicatePanel function.
OGLControlId int The ID of the control on which the plot is drawn. This is the ID returned by OGLNewCtrl or OGLConvertCtrl.
plotHandle int The handle of the plot to be deleted. This is the handle returned by OGLPlot3DScatter or OGLPlot3DUniform.
colorScheme int The color scheme for the plots overrides the surface color if the value of OGLATTR_SURFACE_STYLE is not OGLVAL_NONE. Otherwise, it overrides the wire color if OGLATTR_WIRE_STYLE is not OGLVAL_NONE. If both the above attibutes are OGLVAL_NONE, then the color scheme overrides the point color.

In the following explanation of the color schemes, default color denotes the color that is overridden.

Color Scheme Meaning


None The plot will have a solid color specified by the default color.
Shaded The color of a data point is determined using its z value as follows. If the z value is less than (zmax+zmin)/2 then the color is interpolated between black and the default color. Otherwise it is interpolated between the default color and white.
Gray Scale The color is determined by interpolating from black to white over the range of z values.
Color Spectrum The color is determined using a color map, which has a predetermined set of seven color values distributed evenly over the range of z values.
Color Map The color values are determined using the given color map.
Color Array The color values are determined using the given color array.
colorMapEntries const ColorMapEntry * An array of ColorMapEntry structures. Each ColorMapEntry structure contains:

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;



The Color Map array defines how data values in the Z Array are translated into color values. If a data value matches exactly to a data value in one of the ColorMapEntry structures, then it is converted to the corresponding color. Otherwise:

  • If the interpolateColors? parameter is zero, the color associated with the next higher data value is used.
  • If the interpolateColors? parameter is nonzero, the color is computed using a weighted mean of the colors associated with the Color Map data values immediately above and below the Z Array value.

If there is no higher value, then the color specified in the highColor parameter is used.

The Color Map entries do not need to be in sorted order.
numberOfColors int Specifies the number of entries in the Color Map array.
highColor int The RGB value to which all Z Array values that are higher than the highest data value in the Color Map array are translated.
interpolateColors int Indicates how to assign colors to Z Array data values that do not exactly match the data values in the Color Map array.

If you specify a nonzero value or select Yes in the function panel, then the data value is assigned a color computed using a weighted mean of the colors associated with the Color Map data values above and below the Z Array data value.

Specify 0 or select No in the function panel, then the data value is assigned the color associated with the next higher Color Map data value.

The following rules apply regardless of the value of interpolateColors?:
  • Data values 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 passed in the highColor parameter.
colorArrayEntries const int * Specifies an array of colors for each data point in the plot. The array is interpreted as a two dimensional array of size YSize x XSize. The color value of the point at position {x, y} in the data array is the value of the color array entry at {x mod XSize, y mod YSize}.
xSize int The X Size of the color array.
ySize int The Y Size of the color array.

Return Value

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

Error Codes

–1 to –999 A User Interface Library error code. (constants are available in userint.h)
–1001 The panel is a child panel.
–1002 No window system handle for panel.
–1003 Only a canvas or picture can be converted into an OGL control.
–1004 Error registering window.
–1005 Error creating window.
–1006 The OGL control could not be found.
–1007 Too many controls.
–1008 The OGL plot could not be found.
–1009 Too many plots.
–1010 The label attribute could not be obtained.
–1011 Could not hide the control.
–1012 Could not unhide the control.
–1013 Could not move the control.
–1014 Could not resize the control.
–1015 Invalid parameters passed to the function.
–1016 The attribute is an invalid OGL control attribute.
–1017 The attribute is an invalid OGL plot attribute.
–1018 The last operation caused an OpenGL error. Use OGLGetLastOpenGLError to get the error code.
–1019 The last operation caused a Windows error. Use GetLastError to get the error code.
–1020 The font name is too long.
–1021 The attribute value cannot be set.
–1022 Not enough memory.
–1023 Could not set the context.
–1024 Could not restore the context.
–1025 The control was created by another thread.
–1026 The data type passed to this function was invalid.
–1027 Trying to get an uninitialized or zero length array attribute.
–1028 The function has to be called from the main thread.
–1029 The control is already being refreshed.
–1030 The pixel depth cannot be less than 8 bits (256 colors).

Additional Information

Library: OpenGL 3D Plotting Control

Include file: custctrl\cviogl.h

LabWindows/CVI compatibility: LabWindows/CVI 5.0 and later

Examples

Refer to the following examples that use the OGLSetPlotColorScheme function:

  • apps\oglscxi\oglscxi.cws

    Open example
  • userint\custctrl\cviogl\oglsim.cws

    Open example