Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
It is useful to show the representation of colors assigned to the data plot on the GUI. For this the Map Color control is created to act as a legend for the colors showing the data range. The CreateColorScale function is called from the PlotOGLData function above for this purpose. The source listing for CreateColorScale is shown in Figure 9-9.
|
Code View:
Scroll
/
Show All //Display color map on the Color Map scale
int CreateColorScale (void)
{
double ColorMapArray[5][2];
int NumberOfXpoints, NumberOfYpoints, NumberOfColors,
InterpolateColors,InterpolatePixels ;
ColorMapArray[0][0] = -10.0;
ColorMapArray[0][1] = -10.0;
ColorMapArray[1][0] = -5.0;
ColorMapArray[1][1] = -5.0;
ColorMapArray[2][0] = 0.0;
ColorMapArray[2][1] = 0.0;
ColorMapArray[3][0] = 5.0;
ColorMapArray[3][1] = 5.0;
ColorMapArray[4][0] = 10.0;
ColorMapArray[4][1] = 10.0;
// Plot this array on the color scale graph control
NumberOfXpoints = 2;
NumberOfYpoints = 5;
NumberOfColors = 5;
InterpolateColors = 0;
InterpolatePixels = 0;
if (PlotIntensity (OGLPanelHandle, OGLPANEL_COLORMAP, ColorMapArray,
NumberOfXpoints, NumberOfYpoints, VAL_DOUBLE, MapColor, VAL_YELLOW,
NumberOfColors, InterpolateColors, InterpolatePixels) <= 0)
return -1;
return 0;
}//CreateColorScale
|