KwikPeg Manuals
Home
PegScale
Examples
Examples
Index
Index


Members
Styles
Signals
(none)
Overview Derived from class PegThing

The PegScale class, although itself a derived class, is the base class used to implement a linear scale. The linear scale provides a graphical representation of the value of some measured variable. The variable's value is indicated by a needle which moves along a straight line called the line of travel. Values are mapped linearly from a minimum value at one end of the line of travel to a maximum value at the other end.

Linear scales can be mounted horizontally or vertically. The direction of travel is completely adjustable since the minimum value can be pegged to either end of the line of travel.

KwikPeg includes two linear scale classes derived from the PegScale class. The PegLinearScale class draws the scale within a rectangle with a background color determined by the scale itself or by its parent. The PegLinearBitmapScale class uses a bitmap image for the scale background, providing a custom look to the scale face.

To use the PegScale class or its derivatives, your KwikPeg configuration must have the following option enabled:
  Drawing: HMI graphics



 See Also

PegLinearScale

PegLinearBitmapScale



 Styles

The PegScale 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.
SS_TICMARKS  If this style flag is set, the scale will be drawn with tick marks at the defined intervals. The tick marks will be drawn along the side of the scale opposite to the needle's line of travel.
SS_FACELEFT  This style flag only applies if the scale is mounted vertically.
If this style flag is set, the needle will travel along the right side of the scale and face (point) to the left. If this style flag is reset, the needle will travel along the left side of the scale and face to the right.
SS_FACETOP  This style flag only applies if the scale is mounted horizontally.
If this style flag is set, the needle will travel along the bottom edge of the scale and face (point) upwards. If this style flag is reset, the needle will travel along the top edge of the scale and face downwards.
SS_BOTTOMTOTOP  This style flag only applies if the scale is mounted vertically.
If this style flag is set, the minimum value will be pegged to the bottom extreme of the scale's line of travel. If this style flag is reset, the minimum value will be pegged to the top extreme of the scale's line of travel.
SS_LEFTTORIGHT  This style flag only applies if the scale is mounted horizontally.
If this style flag is set, the minimum value will be pegged to the left extreme of the scale's line of travel. If this style flag is reset, the minimum value will be pegged to the right extreme of the scale's line of travel.
SS_ORIENTVERT  If this style flag is set, the scale will be mounted vertically so that the scale needle moves up and down. If this style flag is reset, the scale will be mounted horizontally so that the scale needle moves left and right.
SS_THINNEEDLE  If this style flag is set, the scale needle will be drawn as a thin single line, 1 pixel wide.
SS_THICKNEEDLE  If this style flag is set, the scale needle will be drawn as a thick single line, 3 pixels wide.
SS_POLYNEEDLE  If this style flag is set, the scale needle will be drawn as a filled polygon.
SS_STANDARDSTYLE  This style flag mask selects the following styles which are commonly used for scales:
SS_FACELEFT | SS_BOTTOMTOTOP | SS_ORIENTVERT | SS_TICMARKS | SS_POLYNEEDLE.
Note that derived classes may only support a subset of these style flags. For example, the linear bitmap scale simply ignores the SS_TICMARKS style flag since tick marks, if needed, can be provided by the bitmap image used for the scale face.
SS_USERTRAVEL  If this style flag is set, the scale's line of travel can be constrained to lie within a particular region of the scale's bounding rectangle. If this style flag is reset, the line of travel will extend to within a few pixels of the scale's bounding rectangle. Derived classes which support this style flag provide member functions to set the limits for the extremities of the line of travel.
AF_TRANSPARENT  If this style flag is set, the background color will be that of the scale's parent object.

Top of page


 Members

Constructors:

PegScale(const PegRect &Rect,
  LONG lMinValue, LONG lMaxValue,
  WORD wStyle)
PegScale(SIGNED iLeft, SIGNED iTop,
  LONG lMinValue, LONG lMaxValue,
  WORD wStyle)

The first constructor creates a derived linear scale in the rectangle specified by parameter Rect.

The second constructor creates a derived linear scale with its top left corner located at (iLeft,iTop). By default, an object created in this fashion will have a width of 100 pixels and a height of 150 pixels.

For both constructors, the following parameters are provided.

Values for the measured variable which the scale represents are restricted to the range lMinValue to lMaxValue.

The minimum measured value is always pegged directly to one end of the scale's line of travel as specified by the scale's style flags. The maximum measured value maps directly to the other end of the line of travel. The needle then travels linearly from its minimum end to its maximum end as the measured value goes from its minimum value to its maximum value.

The frame style and scale characteristics will be governed by the style flags provided by parameter wStyle.

 

Public Functions:

LONG GetCurrentValue(void) const

This inline function returns the current value of the measured variable.

LONG GetMaxValue(void) const

This inline function returns the maximum allowed value of the measured variable.

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 scale needle. For systems with 16 or more colors, the default needle color is red. For all others, the default needle color is white.

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 parameter bRedraw is TRUE, the scale will be redrawn so that the needle reflects the updated value of the variable which the scale represents.

void SetMaxValue(LONG lVal,
  BOOL bRedraw = TRUE)

This function sets the maximum allowed value of the measured variable.

If parameter bRedraw is TRUE, the scale will be redrawn so that the needle position properly reflects the current value of the measured variable with respect to its revised limits.

void SetMinValue(LONG lVal,
  BOOL bRedraw = TRUE)

This function sets the minimum allowed value of the measured variable.

If parameter bRedraw is TRUE, the scale will be redrawn so that the needle position properly reflects the current value of the measured variable with respect to its revised limits.

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 parameter bRedraw is TRUE, the scale will be redrawn so that the needle reflects the updated value of the variable which the scale represents.


Top of page


 Examples

The PegLinearScale class and the PegLinearBitmapScale class provide examples of linear scales derived from the PegScale class.




Top of page
KwikPeg Manuals
Home
Index
Index

 
Copyright © 2000-2003