
Home |
|
PegDial
|

Examples |

Index |
|
 |
|
|
 |
|
Overview |
Derived from class
PegThing
|
 |
|
The PegDial class, although itself a derived class,
is the base class used to implement a measurement object called
a dial. The dial consists of a dial face over which a needle moves
in an arc to indicate the current value of some measured variable.
The center of rotation of the needle is called the needle anchor.
KwikPeg includes several dial classes derived from the
PegDial class.
The finite dial classes restrict the
needle travel to some minimum and maximum limit.
The needle may travel from 0 degrees through the entire 360 degrees
of a circle. However, the needle cannot travel beyond 360 degrees.
The circular dial classes allow the
needle to travel beyond 360 degrees in either direction.
The needle may travel from its 0 degree position through
the entire 360 degrees of a circle and beyond.
 |
To use the PegDial class or its derivatives,
your KwikPeg configuration must have the following option enabled: |
| |
Drawing: HMI graphics |
|
|
 |
 |
|
PegFiniteDial
PegFiniteBitmapDial
PegCircularDial
PegCircularBitmapDial
It is important to understand the geometry which governs the operation
of a KwikPeg dial.
Consider the x-y coordinate system shown in Figures 1 and 2 below.
A point P in the x-y plane has coordinates (x,y).
Coordinate x is considered positive along OX and negative along
OX'. Coordinate y is positive along OY and negative along
OY'.
Line X'OXis the x; line Y'OY is the y axis.
The angle A (shown red) described counterclockwise
from OX is considered positive. If the angle is described
clockwise from OX, it is considered negative.
The quadrants denoted by I, II, III and IV are the
first, second, third and fourth quadrants, respectively.
In Figure 1, the angle shown in red is in the second quadrant.
In Figure 2, the angle shown in red is in the third quadrant.

Angles used by the PegDial class are defined as follows.
0 degrees is always along line OX.
Angle values increase in the counterclockwise direction.
Therefore, line OY is at 90 degrees, line OX' is at 180 degrees
and line OY' is at 270 degrees.
The PegDial class supports
the following style flags:
FF_NONE | No frame. |
FF_THIN | Thin frame. |
FF_THICK | Thick 3D frame. |
FF_RAISED | Raised 3D frame. |
FF_RECESSED | Recessed 3D frame. |
DS_CLOCKWISE |
If this style flag is set, the dial needle will rotate in a
clockwise direction as the measured value increases.
If this style flag is not set, the dial needle will rotate in a
counter clockwise direction as the measured value increases. |
DS_RECTCOR |
If this style flag is set, the center of rotation
of the dial needle will be at the center of the dial's bounding rectangle
(its mReal rectangle). |
DS_USERCOR |
If this style flag is set, the center of rotation
of the dial needle will be at the screen coordinates specified by your
application. This style flag permits the center of the needle rotation
to be outside the rectangle in which a finite dial is drawn. |
DS_TICMARKS |
If this style flag is set, the dial will be drawn
with tick marks at the defined intervals. |
DS_THINNEEDLE |
If this style flag is set, the dial needle will be drawn
as a thin single line, 1 pixel wide. |
DS_THICKNEEDLE |
If this style flag is set, the dial needle will be drawn
as a thick single line, 3 pixels wide. |
DS_POLYNEEDLE |
If this style flag is set, the dial needle will be drawn
as a filled polygon. |
DS_STANDARDSTYLE |
This style flag mask selects the following styles which are commonly
used for dials:
DS_THINNEEDLE | DS_CLOCKWISE |
DS_TICMARKS | DS_RECTCOR.
Note that derived classes may only support a subset of these style flags.
For example, the finite dials simply ignore the DS_CLOCKWISE
style flag since the direction of needle travel is determined by
the dial's needle limits. The circular dials also ignore the
DS_CLOCKWISE style flag since the direction of needle
rotation is determined by the limits of the measured variable. |
AF_TRANSPARENT |
If this style flag is set, the background color will be that
of the dial's parent object. |
Constructors:
 |
 |
PegDial(const PegRect &Rect,
|
| |

WORD wStyle)
|
 |
PegDial(SIGNED iLeft, SIGNED iTop,
|
| |

WORD wStyle)
|
The first constructor creates a derived dial
in the rectangle specified by parameter Rect.
The second constructor creates a derived dial
with its top left corner located at (iLeft,iTop).
By default, an object created in this fashion will have a
width and height of 100 pixels.
For both constructors,
the frame style and dial characteristics will be governed by the style flags
provided by parameter wStyle.
Public Functions:
 |
 |
COLORVAL GetAnchorColor(void) const
|
 |
void SetAnchorColor(COLORVAL tColor)
|
These inline functions get or set
the color of the needle anchor.
 |
 |
WORD GetAnchorWidth(void) const
|
 |
void SetAnchorWidth(WORD wWidth)
|
These inline functions get or set the width, in pixels,
of the needle anchor. Note that the needle anchor is drawn
as a circle with a diameter of wWidth pixels.
The default needle anchor diameter is 4 pixels.
 |
 |
SIGNED GetCurAngle(void) const
|
This inline function returns the current angle of the dial needle.
This function is used privately by the dial classes.
 |
 |
LONG GetCurrentValue(void) const
|
This inline function returns the current value of the measured variable.
 |
 |
COLORVAL GetDialColor(void) const
|
 |
void SetDialColor(COLORVAL tColor)
|
These inline functions get or set
the color of the dial face.
 |
 |
SIGNED GetMaxAngle(void) const
|
This inline function returns the dial's maximum needle angle.
 |
 |
LONG GetMaxValue(void) const
|
This inline function returns the maximum allowed value of the
measured variable.
 |
 |
SIGNED GetMinAngle(void) const
|
This inline function returns the dial's minimum needle angle.
 |
 |
LONG GetMinValue(void) const
|
This inline function returns the minimum allowed value of the
measured variable.
 |
 |
COLORVAL GetNeedleColor(void) const
|
 |
void SetNeedleColor(COLORVAL tColor)
|
These inline functions get or set
the color of the dial needle.
For systems with 16 or more colors, the default needle color is red.
For all others, the default needle color is white.
 |
 |
WORD GetNeedleLength(void) const
|
 |
void SetNeedleLength(WORD wLength)
|
These inline functions get or set the length of the dial needle.
The dial length is specified as a percentage 0 to 100, inclusive.
If the value is 0, the dial will not be visible.
The needle length will be wLength percent of the smaller of the
dial's width or height.
For example, if wLength is 80 and the dial is 120 pixels wide by
130 pixels high, the needle length will be 96 pixels (80% of 120).
 |
 |
LONG GetTicFreq(void) const
|
 |
void SetTicFreq(LONG lFreq)
|
These inline functions get or set
the measurement interval at which tick marks will be drawn.
The interval lFreq is specified in the same units as the measured variable
which the dial represents. The ticks will be drawn along the arc of the
needle's travel at needle angles which represent lFreq measurement
units. Of course, tick marks are only drawn if the object's
DS_TICMARKS style flag is set.
 |
 |
WORD GetTicLen(void) const
|
 |
void SetTicLen(WORD wLength)
|
These inline functions get or set the length of each tick mark.
The tick mark length is specified as a percentage 0 to 100, inclusive.
If the value is 0, the tick mark will not be visible.
The tick mark length will be wLength percent of the smaller of the
dial's width or height.
For example, if wLength is 10 and the dial is 120 pixels wide by
130 pixels high, the tick mark length will be 12 pixels (10% of 120).
 |
 |
virtual LONG IncrementValue(
|
| |

LONG lValue,
|
| |

BOOL bRedraw = TRUE)
|
This virtual function increments the current value of the measured
variable by lValue measurement units.
The increment value can be negative.
If the incremented value is less than the minimum
allowed value, the value is set to the minimum.
If the incremented value is greater than the maximum allowed value,
the current value is set to the maximum.
This function returns the final value of the measured value.
If the dial is visible and parameter bRedraw is
TRUE, the dial will be redrawn so that the needle
reflects the updated value of the variable which the dial represents.
If parameter bRedraw is FALSE, the dial
will not be redrawn.
 |
 |
virtual void SetValue(
|
| |

LONG lValue,
|
| |

BOOL bRedraw = TRUE)
|
This virtual function sets the current value of the measured
variable to lValue measurement units.
If the value lValue is less than the minimum
allowed value or greater than the maximum allowed value,
the current value is left unaltered.
If the new value differs from the current value and
the dial is visible and parameter bRedraw is
TRUE, the dial will be redrawn so that the needle
reflects the updated value of the variable which the dial represents.
If parameter bRedraw is FALSE, the dial
will not be redrawn.
The PegFiniteDial,
PegFiniteBitmapDial
and PegCircularDial
classes provide examples of dials derived from the PegDial
class.