Gadget Library - High Level Widgets
Gauges:
OtkWidget Otk_MakeGauge2( OtkWidget container, float left, float top, float horiz_size, float vert_size, char *title );
This function places a circular analog gauge display at the specified position and size.
By default, the initial meter position is set to zero. Call this function once for each
gauge. Use Otk_SetGauge2 to move the indicator.
void Otk_SetGauge2( OtkWidget gauge, float value, OtkColor tmpcolor );
This function moves the specified gauge's indicator to the position indicated by the value parameter.
Allowable values span from 0.0 to 100.0. Larger or smaller values will be saturated at the max or min value
respectively.
LED Meters:
OtkWidget Otk_MakeLEDmeter( OtkWidget container, float left, float top, float horiz_size, float vert_size,
int nbars, char orientation, OtkColor tmpcolor );
This function places an LED meter display at the specified position and size.
The LED bar-graph display can be oriented either vertically or horizontally, by
specifying 'v' or 'h', respectively in the orientation parameter.
By default, the initial meter state is off/dark, so a dark color is recommended
for the initial color. Use Otk_SetLEDmeter to change the display state.
void Otk_SetLEDmeter( OtkWidget ledmeter, float value, OtkColor offcolor, OtkColor oncolor );
This function moves the specified led-meter's indication to the position indicated by the
value parameter, by turning on the appropriate LED bars. Allowable values span from
0.0 to 100.0. Larger or smaller values will be saturated at the max or min value
respectively.
void Otk_SetLEDmeter_Range( OtkWidget ledmeter, float minvalue, float maxvalue, OtkColor oncolor );
This function is similar to Otk_SetLEDmeter above, but it sets only a specified range
to the given color. It is handy for adding, for example, a peak-hold indicator to an LED meter.
Or it could be used, for example, to make the 0 to 80% range of the meter display in green, and the
80% to 100% range to display in red, as often seen in common VU meters. The minvalue and
maxvalue paramaters should span between 0.0 and 100.0.
Bar-Graphs:
OtkWidget Otk_MakeBarMeter( OtkWidget container, float left, float top, float horiz_size, float vert_size,
char orientation, OtkColor tmpcolor );
This function places a Bar-Graph display at the specified position and size.
The bar-graph can be oriented either vertically or horizontally, by specifying 'v' or
'h', respectively in the orientation parameter. By default, the initial meter
state is off/low. Use Otk_SetBarMeter to change the display state.
void Otk_SetBarMeter( OtkWidget barmeter, float value );
This function moves the specified bar-graph's indication to the position indicated by the
value parameter. Allowable values span from 0.0 to 100.0. Larger or smaller values
will be saturated at the max or min value respectively.
void Otk_SetBarmeter_Range( OtkWidget barmeter, int segment, float minval, float maxval, OtkColor color );
This function is similar to Otk_SetBarmeter above, but it sets only a specified range
to the given color. It is handy for adding, for example, a peak-hold indicator to a VU meter.
Or it could be used, for example, to make the 0 to 80% range of the meter display in green, and the
80% to 100% range to display in red, as often seen in common VU meters. The minval and
maxval paramaters should span between 0.0 and 100.0. The segment parameter enables adjusting
previously designated segments. The initial segment created by Otk_MakeBarMeter and manipulated
by Otk_SetBarMeter, is segment = 0. If you wish to add a second segment, without disturbing the
first, then specify segment = 1. The position or color of that segment can be changed by specifying
that segment number. Any number of segments may be added and managed on a given bar-meter.
XY-Graphs, Plotters, Strip-Charts:
OtkWidget Otk_Plot_Init( OtkWidget container, char *xlabel, char *ylabel, float xpos, float ypos,
float width, float height, OtkColor fgcolor, OtkColor bgcolor );
This is the first function to call when making a graph. It is usually called once per graph.
This function places an XY graph display panel at the position within the container
specified by xpos and ypos. The graph size is set by width and height parameters - all in
percent of the container panel. The xlabel and ylabels are placed on the respective
graph axes. Specify the graph border and label color as fgcolor, and the background
color with bgcolor. The following functions place number-scales and data on the graph.
For example usage, see plot_example1.c.
void Otk_Plot_Set_Axes( OtkWidget plotbox, float xmin, float xmax, int xgrids,
float ymin, float ymax, int ygrids,
OtkColor tcolor, OtkColor gcolor );
This function places numbers on the X (horizontal) and Y (vertical) axes of the graph
referenced by plotbox. It also sets the axes ranges spanned by the graph,
and places grids on the graph. You must specify the X and Y ranges by min and max values,
as well as the number of divisions or grids to place on each axis. Typically, a good
number of grids is 4 or 5. This also controls how many numbers will be placed each on
axis. For very small graphs (or for large values on the X-axis) where there is little
room, setting ngrids to 2 or 3 may suffice. For large graphs, where you want finer divisions,
you might set ngrids to 10 or 15. Specify the color axis numbers/text with tcolor, and
the grid color by gcolor. It is usually best to use a high contrast color relative to the
graph's background for the text, and a lower contrast color for the grids. This subdues
the grid relative to your data lines.
This function is often the second function called when making a graph. However, it
is not needed when using Otk_Plot_Data_AutoScaled nor Otk_StripChart_Init.
Otherwise, the axes ranges must be set before calling Otk_Plot_Data.
Otk_Plot_Set_Axes can also be called after data has been drawn to a graph.
It clears any previously written data lines or curves. It can be used as a
method to clear or refresh a graph.
For example usage, see plot_example1.c.
void Otk_Plot_Data( OtkWidget plotbox, int npoints, float *xarray, float *yarray, OtkColor dcolor );
This function plots data to the XY graph specified by plotbox. It accepts the number of
points as npoints, and two arrays cointaining X and Y values. Each of the arrays must
have at least npoints floating-point elements. The color of the data-curve drawn is set
by the dcolor parameter. You can add multiple curves on a given graph by calling
Otk_Plot_Data for each curve. The functions Otk_Plot_Init and Otk_Plot_Set_Axes must
be called to establish the graph before Otk_Plot_Data can be called.
For example usage, see plot_example1.c.
void Otk_Plot_Data_AutoScaled( OtkWidget plotbox,
int npoints, float *xarray, float *yarray, OtkColor dcolor,
OtkColor tcolor, OtkColor gcolor, int xgrids, int ygrids );
This function is a convenience function. It can be used in place of the
combination of Otk_Plot_Set_Axes and Otk_Plot_Data, when making a graph from a
single curve only. It is useful because it automatically determines and sets the
best axes ranges for the data you supply. The XY data arrays, npoints, and data-curve
color are specified as in Otk_Plot_Data above. The grid and axis-number granularities
and colors are set by xgrids, ygrids, gcolor and tcolor as in Otk_Plot_Set_Axes above.
void Otk_StripChart_Init( OtkWidget plotbox, int xrange, float ymin, float ymax,
OtkColor text_color, OtkColor grid_color, OtkColor data_color );
This function establishes a strip-chart. A strip-chart is an XY graph that
scrolls continuously as new data is added. The Otk_Plot_Init function must be
called first to obtain a plotbox. Next Otk_StripChart_Init is called instead of
Otk_Plot_Set_Axes, to establish the special strip-chart parameters and axes ranges.
The Y axis is specified as normal with ymin and ymax.
There are two styles of strip-charts. If xrange is a positive non-zero integer,
such as 10, then xrange (10) points will always be displayed, and xmin and xmax will
move as new data is added. The axis range stays constant. If xrange is -1, then
xmin will always stay at zero, and xmax will increase as new points are added.
This produces the effect of seeing the graph's x-axis range compress as new
data is added.
The text and data colors are set as in the other functions above.
The Otk_StripChart_Init is intended to be used before Otk_StripChart_AddPoint.
For example usage, see plot_example1.c.
void Otk_StripChart_AddPoint( OtkWidget plotbox, float value );
The function adds a data point to a strip-chart. The Otk_Plot_Init and
Otk_StripChart_Init functions must be called before using this function to
set plotbox. The value parameter specifies the Y-coordinate of the new point.
The X-axis value is the count of the point received. The count is automatically
incremented. See Otk_StripChart_Init above.
For example usage, see plot_example1.c.
Back to main page