Home |
HMI (Human-Machine Interface) Classes Class PegDial |
Class PegDialPegDial is an abstract base class from which PegFiniteDial and PegFiniteBitmapDial are derived. PegDial provides the base functionality common to all the derived dial objects in the PEG library. It is important to understand how the angle value works on the dial. Consider an xy coordinate system (Figures 1 and 2, below). A point P in the xy plane has coordinates (x,y) where x is considered positive along OX and negative along OX' while y is positive along OY and negative along OY'. The angle A described counterclockwise from OX is considered positive. If it is described clockwise from OX it is considered negative. We call X'OX and Y'OY the x and y axis respectively. The various quadrants are denoted by I,II,III and IV called the first, second, third and fourth quadrants, respectively. In Figure 1, for example, angle A is in the second quadrant while in Figure 2, angle A is in the third quadrant. When working with angles with any PegDial derived class, 0 degrees is always on line OX with greater angle values going counterclockwise. Therefore, line OY is at 90 degrees, line OX' is at 180 degrees and line OY' is at 270 degrees. Style FlagsPegDial supports the standard frame styles FF_NONE, FF_THIN, FF_THICK, FF_RAISED, and FF_RECESSED. PegDial also supports the following additional styles: DS_CLOCKWISESets the direction that the data will move the needle. Having this flag set causes the needle to move in a clockwise direction as the current value gets larger. Clearing this flag will cause the needle to move in a counter clockwise direction. DS_TICMARKSIf this flag is set, the dial will draw tick marks at the defined intervals. DS_THINNEEDLEWill draw the needle as a thin single line. DS_THICKNEEDLEWill draw the needle as a thick single line. DS_POLYNEEDLEWill draw the needle using a filled polygon. DS_RECTCORRectangle Center of Rotation. Will use the center of the bounding rectangle (mReal) as the center for the anchor of the needle. DS_USERCORUser Center of Rotation. Allows the user to specify where the center anchor will be for the needle. This allows for off center bitmaps to be used for backgrounds on the dial. DS_STANDARDSTYLEA combination of DS_THINNEEDLE | DS_CLOCKWISE | DS_TICMARKS | DS_RECTCOR. AF_TRANSPARENTEnables the background to be drawn using the background color of the parent. SignalsPegDial does not send any signals. class PegDial : public PegThing { public: PegDial(const PegRect& Rect, PEGUINT wStyle); PegDial(PEGINT iLeft, PEGINT iTop, PEGUINT wStyle); virtual void SetValue(LONG lValue, BOOL bRedraw = TRUE); virtual LONG IncrementValue(LONG lValue, BOOL bRedraw = TRUE); // Accessors and mutators LONG GetCurrentValue() const; PEGINT GetCurAngle() const; PEGUINT GetNeedleLength() const; void SetNeedleLength(PEGUINT wLen); COLORVAL GetNeedleColor() const; void SetNeedleColor(COLORVAL tColor); COLORVAL GetDialColor() const; void SetDialColor(COLORVAL tColor); COLORVAL GetAnchorColor() const; void SetAnchorColor(COLORVAL tColor); PEGUINT GetAnchorWidth() const; void SetAnchorWidth(PEGUINT wWidth); LONG GetTicFreq(void) const; void SetTicFreq(LONG lFreq); PEGUINT GetTicLen(void) const; void SetTicLen(PEGUINT wLen); PEGINT GetMinAngle(void) const; PEGINT GetMaxAngle(void) const; LONG GetMinValue(void) const; LONG GetMaxValue(void) const; protected: virtual PEGINT ValToAngle(LONG lVal) = 0; virtual void CalcNeedlePos(void) = 0; virtual void DrawTicMarks(void) = 0; virtual void DrawNeedle(void); virtual void DrawAnchor(void); virtual void EraseNeedle(void); virtual void CalcClipAndDraw(void); virtual void DrawDial(void); virtual void CalcTicPos(LONG lVal, PegPoint& tPt1, PegPoint& tPt2); LONG mlCurValue; PEGINT miCurAngle; PegRect mtNeedlePos; PEGUINT mwNeedleLen; LONG mlTicFreq; PEGUINT mwTicLen; PEGUINT mwAnchorWidth; COLORVAL mtNeedleColor; COLORVAL mtDialColor; COLORVAL mtAnchorColor; PEGINT miMinAngle; PEGINT miMaxAngle; LONG mlMinValue; LONG mlMaxValue; BOOL mbValueSet; }; ConstructorsThe first constructor simply takes a reference to a PegRect and a PEGUINT for the style flags. The second constructor simply takes PEGINT values to describe the left and top position of the dial. By default, an object created in this fashion will have a width and height of 100 pixels. Methods GetAnchorColor and SetAnchorColorThese inline functions provide retrieval and setting of the color used to draw the needle anchor. Methods GetAnchorWidth and SetAnchorWidthThese inline functions provide retrieval and setting of the anchor width. Method GetCurAngleThis inline function returns the current angle of the needle. Method GetCurrentValueThis inline function returns the current value. Methods GetDialColor and SetDialColorThese inline functions provide retrieval and setting of the color used to draw the dial face. Method GetMinValueThis inline method returns the minimum value supported by the dial. Method GetMaxValueThis inline method returns the maximum value supported by the dial. Methods GetNeedleColor and SetNeedleColorThese inline functions allow for the setting and retrieving of the current color of the needle. Methods GetNeedleLength and SetNeedleLengthThese inline functions allow for the setting and retrieving of the current length of the needle. The value can be between 0 and 100 (inclusive). This value is used to calculate the length of the needle based on the lesser of the width or height of the dial. For example, if this value is set to 80, then the length of the needle is 80% of the width or height of the dial, whichever is smaller. Methods GetTicFreq and SetTicFreqThese inline functions provide retrieval and setting of the tick mark frequency. This determines the interval at which tick marks will be drawn on the dial face. Methods GetTicLen and SetTicLenThese inline functions provide retrieval and setting of the tick mark length. This value works the same way as the needle length. The value is a percentage of the width or height of the dial, whichever is smaller. Therefore, if this value was set to 10, then the tick length would be 10% of the width or height of the dial, whichever is smaller. Method IncrementValueThis virtual method increments the current value of the dial. By default, if the object is visible, it will redraw itself. To suppress this behavior, set bRedraw to FALSE. Method SetValueThis virtual method allows the current value to be set. By default, if the object is visible, it will redraw itself. To circumvent this behavior, set bRedraw to FALSE. ExamplesSee PegFiniteDial or PegFiniteBitmapDial for examples of PegDial derived objects.
|