Home |
HMI (Human-Machine Interface) Classes Class PegFiniteDial |
Class PegFiniteDialPegFiniteDial is an HMI output gadget that provides an analog equivalent to a digital readout. It can be fed any integral data from any source. The dial is categorized as finite because it takes a specific start angle and a specific end angle that map to a minimum and maximum value, respectively. So, in action, the needle on the dial moves between the start and end angles based on the current value that is between the minimum and maximum values assigned to the dial. The travel of the needle may be the entire 360 degrees of a circle, say from 0 to 359 in a counter clockwise direction, but may not wrap. Style FlagsPegFiniteDial supports the styles described in PegDial. SignalsPegFiniteDial does not send any signals. class PegFiniteDial : public PegDial { public: PegFiniteDial(const PegRect &Size, PEGINT iMinAngle, PEGINT iMaxAngle, LONG lMinValue, LONG lMaxValue, PEGUINT wStyle = DS_STANDARDSTYLE); PegFiniteDial(PEGINT iLeft, PEGINT iTop, PEGINT iMinAngle, PEGINT iMaxAngle, LONG lMinValue, LONG lMaxValue, PEGUINT wStyle = DS_STANDARDSTYLE); virtual void Draw(); virtual void SetLimits(PEGINT iMinAngle, PEGINT iMaxAngle, LONG lMinValue, LONG lMaxValue); protected: virtual void CalcNeedlePos(); virtual PEGINT ValToAngle(LONG lVal); virtual void DrawTicMarks(); }; ConstructorsThe first constructor takes a reference to a PegRect to determine its size, a style PEGUINT, a minimum and maximum angle and a minimum and maximum value. The second constructor takes PEGINT values to determine the left and top positions of the dial. By default, an object created using this constructor will have a width and height of 100 pixels. The remaining arguments are the same as above. The dial will map the minimum angle to the minimum value, and the maximum angle to the maximum value. So, the dial will behave as expected. If you set the minimum angle to be 0 and the maximum angle to be 180, and the minimum value to 0 and the maximum value to 100, then setting the value on the dial to 50 will set the needle to 90 degrees, straight up. Method DrawPegFiniteDial overrides the Draw() function. ExamplesThe following is an example of three PegFiniteDials on a PegDecoratedWindow. The above PegFiniteDials were created by the following code snippet: PegFiniteDial * mpDial1, * mpDial2, * mpDial3; . . PegRect WinRect; WinRect.Set(50, 50, 200, 200); mpDial1 = new PegFiniteDial(WinRect, 180, 0, -50, 100, AF_TRANSPARENT | DS_STANDARDSTYLE); mpDial1->SetTicFreq(10); mpDial1->SetTicLen(10); mpDial1->SetDialColor(CYAN); WinRect.Shift(160, 0); mpDial2 = new PegFiniteDial(WinRect, 225, 315, 0, 300, FF_RAISED | DS_THICKNEEDLE | DS_TICMARKS | DS_RECTCOR); mpDial2->SetColor(PCI_NORMAL, DARKGRAY); mpDial2->SetNeedleColor(BLUE); mpDial2->SetTicFreq(50); mpDial2->SetTicLen(20); WinRect.Shift(160, 0); mpDial3 = new PegFiniteDial(WinRect, 225, 315, 0, 300, FF_RECESSED | DS_POLYNEEDLE | DS_TICMARKS | DS_RECTCOR); mpDial3->SetColor(PCI_NORMAL, LIGHTGRAY); mpDial3->SetDialColor(GREEN); mpDial3->SetNeedleColor(YELLOW); mpDial3->SetTicFreq(50); mpDial3->SetTicLen(20); Add(mpDial1); PegPrompt * pPrompt = new PegPrompt(105, 160, 40, "0", 101, FF_RECESSED | TJ_CENTER | TT_COPY); pPrompt->SetColor(PCI_NTEXT, RED); mpDial1->Add(pPrompt); Add(mpDial2); pPrompt = new PegPrompt(265, 160, 40, "0", 102, FF_RECESSED | TJ_CENTER | TT_COPY); pPrompt->SetColor(PCI_NTEXT, BLUE); mpDial2->Add(pPrompt); Add(mpDial3);
|