ELEMENT_NEEDLE

Use ELEMENT_NEEDLE to draw an image that pivots around a specific point in another image. ELEMENT_NEEDLE supports transparency and nonlinear gauges. For ELEMENT_NEEDLE, POS (position) is the center of rotation in the background image; OFS (offset) is the center of rotation in the needle image.

typedef struct ELEMENT_NEEDLE

{

HEADER;

MODULE_VARsource_var;

PMODULE_VAR_CBsource_var_cb;

PFN_FLOAT64display_value_fn;

PFN_FLOAT64angle_fn;

PFN_FLOAT64lag_fn;

PIXPOINTreference;

PNONLINEARITYnonlinearity_table;

UINT32nonlinearity_table_size;

SINT32max_degrees_per_tick;

FLOAT64readout_goal;

FLOAT64theta_goal;

FLOAT64theta;

PIXPOINTreference_old;

PIXPOINTo0, o1, o2, o3;

IMAGE_SETneedle_data;

PIMAGEtexture_data;

UINT32texture_handle;

PIMAGEsave_buffer;

PIXPOINTsave_position;

} ELEMENT_NEEDLE, *PELEMENT_NEEDLE, **PPELEMENT_NEEDLE;

ELEMENT_NEEDLE uses the following members:

Member Description
HEADER Discussed in detail in the topic Using Drawing Elements.
source_var Use as MODULE_VAR to access simulation state values.
source_var_cb Use as a callback function for source_var.
display_value_fn Do not use.
angle_fn Do not use.
lag_fn Do not use.
reference Use as a reference point to determine if the needle needs to be rotated. This point is rotated the number of degrees the needle should be rotated. If, after rotation, the point’s X and Y values haven't changed since the previous frame, the needle will not be redrawn. The closer this point is to the pivot point, the less likely the point will change with a small angle of rotation. If the point is too far away, the more likely the point is going to change with a small rotation. Generally, a point near the tip of the needle is a good reference point.
nonlinearity_table Points to an array of NONLINEARITY structures.
nonlinearity_table_size Number of entries in nonlinearity_table array.
max_degrees_per_tick Maximum angle, in degrees, the needle can rotate in one timer tick. Use this to make your needle movement smoother. If the value is 0, it's ignored.
readout_goal Used internally by the Panel system; do not use. Must be set to 0.
theta_goal Used internally by the Panel system; do not use. Must be set to 0.
theta Used internally by the Panel system; do not use. Must be set to 0.
reference_old Used internally by the Panel system; do not use. Must be set to 0.
o0, o1, o2, o3 Used internally by the Panel system; do not use. Must be set to 0.
needle_data Used internally by the Panel system; do not use. Must be set to 0.
texture_data Used internally by the Panel system; do not use. Must be set to 0.
texture_handle Used internally by the Panel system; do not use. Must be set to 0.
save_buffer Used internally by the Panel system; do not use. Must be set to 0.
save_position Used internally by the Panel system; do not use. Must be set to 0.

Remarks

In some cases, you might want your needle to move in a nonlinear manner. For example, an airspeed gauge sometimes shows a greater angle between 0 and 50 knots than the angle between 100 and 150 knots. You can accomplish this by using a nonlinearity table.

A nonlinearity table is defined as an array of NONLINEARITY structures. Each element in the array represents a discrete point on your gauge where the value is known. For example, your gauge might show airspeed as values from 0 to 160 knots, with tick marks every 20 knots. You could create an entry for each tick, filling in the pt and value member variables of the NONLINEARITY structure.

A NONLINEARITY structure uses the following members:

Member Description
pt Specifies X, Y point in the background bitmap.
value Readout of the gauge at that point.
degrees Used internally by the Panel system: do not use. Must be set to 0.

At runtime, the value of the needle is examined and the angle to be drawn is interpolated from the nonlinearity table.

Values are listed as they appear clockwise around the face of the gauge. If gauge values increase when rotating clockwise, values in the nonlinearity table will start at the minimum and increase. If gauge values decrease when rotating clockwise, then values in the table will start with the maximum and decrease.

The following code example shows the nonlinearity table structure definition:

typedef struct NONLINEARITY

{

PIXPOINTpt;

FLOAT64value;

FLOAT64degrees;

} NONLINEARITY, *PNONLINEARITY, **PPNONLINEARITY;