KwikPeg Manuals
Home
PegFiniteBitmapDial
Examples
Examples
Index
Index


Members
Styles
Signals
(none)
Overview Derived from class PegFiniteDial

The PegFiniteBitmapDial class implements a finite dial, a dial for which the needle travel is restricted 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 PegFiniteBitmapDial class maps each measurement value to the face of the dial so that minimum and maximum measurement values correspond to the limits of the dial's needle travel.

The finite bitmap dial is drawn within a bounding rectangle but has no frame or tick marks. Instead, the face of the dial is drawn using a background bitmap image which, if necessary, can provide the frame and tick marks. The bitmap image can include transparent regions, allowing it to float over the background of the dial's parent. The colors of the dial needle and needle anchor are adjustable to provide the proper contrast with the dial's bitmap image. If desired, a separate bitmap image can be provided for the dial anchor.

Unlike the PegFiniteDial class, the PegFiniteBitmapDial class allows the center of rotation of the dial needle to be located anywhere within the dial's client area. Using this feature, a dial can be constructed with a dial face that occupies a single quadrant of a circle. Such a dial then fits within a much smaller bounding rectangle than would otherwise be required. See the examples for an illustration of such a dial.

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



 See Also

PegDial

PegFiniteDial

PegCircularDial

PegCircularBitmapDial



 Styles

The PegFiniteBitmapDial class supports the following style flags:

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.

The PegFiniteBitmapDial class does not support tick marks or any of the frame styles because a bitmap image is used for the background of the dial's client area. A frame and tick marks, if required, can be added to the background bitmap image.


Top of page


 Members

Constructors:

PegFiniteBitmapDial(const PegRect &Rect,
  SIGNED iMinAngle, SIGNED iMaxAngle,
  LONG lMinValue, LONG lMaxValue,
  PegBitmap *pBkgBitmap,
  PegBitmap *pAnchorBitmap = NULL,
  WORD wStyle = DS_STANDARDSTYLE)
PegFiniteBitmapDial(SIGNED iLeft, SIGNED iTop,
  SIGNED iMinAngle, SIGNED iMaxAngle,
  LONG lMinValue, LONG lMaxValue,
  PegBitmap *pBkgBitmap,
  PegBitmap *pAnchorBitmap = NULL,
  WORD wStyle = DS_STANDARDSTYLE)

The first constructor creates a finite bitmap dial in the rectangle specified by parameter Rect.

The second constructor creates a finite bitmap 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. If a background bitmap is specified, the dial is sized to the height and width of the bitmap image.

For both constructors, the following parameters are provided.

The dial's needle motion will be restricted to the angular range iMinAngle to iMaxAngle degrees. If necessary, review the definition of angles as they apply to dial geometry.

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

The minimum measured value maps directly to the minimum needle angle. The maximum measured value maps directly to the maximum needle angle. Hence, needle travel will go from the minimum angle to the maximum angle as the measured value goes from its minimum value to its maximum value.

Parameter pBkgBitmap is a pointer to the bitmap image which will be used as the dial background, forming the dial face. If the bitmap image includes transparent regions, be sure to use the AF_TRANSPARENT style flag so that the image will float over the parent's background or over the dial's background if the dial has no parent.

Parameter pAnchorBitmap is a pointer to the anchor point bitmap image to be drawn centered over the dial's center of rotation. If this parameter is NULL, the anchor point will be drawn as a small circle.

The dial characteristics will be governed by the style flags provided by parameter wStyle. Note that frame styles are not supported by finite bitmap dials.

 

Public Functions:

virtual void Draw(void)

The PegFiniteBitmapDial class overrides the Draw() function to draw the bitmap image background, the needle anchor and the dial needle to reflect the current value of the variable which the dial represents.

PegBitmap *GetAnchorBitmap(void) const

This function returns a pointer to the PegBitmap bitmap image which is used as the dial anchor point. The function returns NULL if the object does not have an anchor bitmap installed.

PegBitmap *GetBkgBitmap(void) const

This function returns a pointer to the PegBitmap bitmap image which is used as the dial background to form the dial face.

SIGNED GetCORX(void) const
SIGNED GetCORY(void) const

These inline functions return the relative x and y cordinates, in pixels, of the center of rotation of the dial needle. The x,y location of the center of rotation is measured relative to the top left corner of the dial's client area.

void SetAnchorBitmap(PegBitmap *pBmp)

This function sets the bitmap for the anchor point to the bitmap image referenced by parameter pBmp. The dial is not redrawn.

void SetBkgBitmap(PegBitmap *pBmp)

This function sets the background bitmap for the dial face to the bitmap image referenced by parameter pBmp. The dial is not redrawn.

void SetCOR(SIGNED CORX, SIGNED CORY,
  BOOL bRedraw = FALSE)

This function sets the relative x,y cordinates, in pixels, of the center of rotation of the dial needle to CORX,CORY. The x,y location of the center of rotation is measured relative to the top left corner of the dial's client area. The center of rotation must be within the client area of the dial.

If parameter bRedraw is TRUE, the dial will be redrawn so that the needle reflects the updated location of the needle's center of rotation.

void UseTrueCOR(BOOL bUse)

This function establishes the style to be used for needle center of rotation calculations.

If bUse is TRUE, style flag DS_RECTCOR is set and style flag DS_USERCOR is reset.

If bUse is FALSE, style flag DS_USERCOR is set and style flag DS_RECTCOR is reset.


Top of page


 Examples

The following example illustrates three finite bitmap dials derived from the PegFiniteBitmapDial class and drawn within a decorated window. Notice that the rightmost dial has the center of rotation for its needle located near the bottom right corner of the dial's bounding rectangle.

 
The PegFiniteBitmapDial objects illustrated above (excluding the text boxes below each dial) were created by the following code fragment:

    extern PegBitmap gbdialbkg1Bitmap;
    extern PegBitmap gbdialbkg2Bitmap;
    extern PegBitmap gbdialbkg3Bitmap;
    PegFiniteBitmapDial *mpDial1, *mpDial2, *mpDial3;
    :
    :
    PegRect WinRect;

    WinRect.Set(50, 50, 200, 200);
    mpDial1 = new PegFiniteBitmapDial(WinRect,
        180, 0, 0, 100, &gbdialbkg1Bitmap);

    WinRect.Shift(160, 0);
    mpDial2 = new PegFiniteBitmapDial(WinRect,
        225, 315, -25, 125, &gbdialbkg2Bitmap);
    mpDial2->Style((mpDial2->Style() | DS_THICKNEEDLE)
                    & ~DS_THINNEEDLE); 
    mpDial2->SetNeedleColor(BLUE);

    WinRect.Shift(160, 0);
    mpDial3 = new PegFiniteBitmapDial(WinRect,
        180, 90, 0, 100, &gbdialbkg3Bitmap, NULL,
        DS_THICKNEEDLE | DS_USERCOR);
    mpDial3->SetCOR(123, 123);
    mpDial3->SetNeedleLength(65);

    mpDial1->SetValue(62, FALSE);
    Add(mpDial1);
    mpDial2->SetValue(38, FALSE);
    Add(mpDial2);
    mpDial3->SetValue(62, FALSE);
    Add(mpDial3);



Top of page
KwikPeg Manuals
Home
Index
Index

 
Copyright © 2000-2003