TGSpeedo.h

Go to the documentation of this file.
00001 // @(#)root/gui:$Id: TGSpeedo.h
00002 // Author: Bertrand Bellenot   26/10/06
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TGSpeedo
00013 #define ROOT_TGSpeedo
00014 
00015 //////////////////////////////////////////////////////////////////////////
00016 //                                                                      //
00017 // TGSpeedo                                                             //
00018 //                                                                      //
00019 // TGSpeedo is a widget looking like a speedometer, with a needle,      //
00020 // a counter and a small odometer window.                               //
00021 //                                                                      //
00022 // Three thresholds are configurable, with their glowing color          //
00023 // A peak mark can be enabled, allowing to keep track of the highest    //
00024 // value displayed. The mark can be reset by right-clicking on the      //
00025 // widget.                                                              //
00026 // Two signals are available:                                           //
00027 //    OdoClicked(): when user click on the small odometer window        //
00028 //    LedClicked(): when user click on the small led near the counter   //
00029 //                                                                      //
00030 //////////////////////////////////////////////////////////////////////////
00031 
00032 #ifndef ROOT_TGFrame
00033 #include "TGFrame.h"
00034 #endif
00035 #ifndef ROOT_TGWidget
00036 #include "TGWidget.h"
00037 #endif
00038 #ifndef ROOT_TGPicture
00039 #include "TGPicture.h"
00040 #endif
00041 #ifndef ROOT_TImage
00042 #include "TImage.h"
00043 #endif
00044 
00045 
00046 class TGSpeedo : public TGFrame, public TGWidget {
00047 
00048 public:
00049    enum EGlowColor { kNoglow, kGreen, kOrange, kRed };
00050 
00051 protected:
00052    TImage          *fImage;               // image used as background
00053    TImage          *fImage2;              // intermediate image used as background
00054    const TGPicture *fBase;                // picture used as background
00055    FontStruct_t     fTextFS, fCounterFS;  // font structures for text rendering
00056    Int_t            fCounter;             // small odo meter (4 digits)
00057    TString          fPicName;             // name of picture used as background
00058    TString          fLabel1;              // main label (first line)
00059    TString          fLabel2;              // main label (second line)
00060    TString          fDisplay1;            // first line in the small display
00061    TString          fDisplay2;            // second line in the small display
00062    Float_t          fAngle, fValue;       // needle angle and corresponding value
00063    Float_t          fPeakVal;             // maximum peak mark
00064    Float_t          fMeanVal;             // mean value mark
00065    Float_t          fAngleMin, fAngleMax; // needle min and max angle
00066    Float_t          fScaleMin, fScaleMax; // needle min and max scale
00067    Float_t          fThreshold[3];        // glowing thresholds
00068    EGlowColor       fThresholdColor[3];   // glowing threshold colors
00069    Bool_t           fThresholdActive;     // kTRUE if glowing threhsholds are active
00070    Bool_t           fPeakMark;            // kTRUE if peak mark is active
00071    Bool_t           fMeanMark;            // kTRUE if mean mark is active
00072 
00073    virtual void     DoRedraw();
00074            void     DrawNeedle();
00075            void     DrawText();
00076            void     Translate(Float_t val, Float_t angle, Int_t *x, Int_t *y);
00077 
00078 public:
00079    TGSpeedo(const TGWindow *p = 0, int id = -1);
00080    TGSpeedo(const TGWindow *p, Float_t smin, Float_t smax,
00081             const char *lbl1 = "", const char *lbl2 = "",
00082             const char *dsp1 = "", const char *dsp2 = "", int id = -1);
00083    virtual ~TGSpeedo();
00084 
00085    virtual TGDimension  GetDefaultSize() const;
00086    virtual Bool_t       HandleButton(Event_t *event);
00087 
00088    const TGPicture     *GetPicture() const { return fBase; }
00089    TImage              *GetImage() const { return fImage; }
00090    Float_t              GetPeakVal() const { return fPeakVal; }
00091    Float_t              GetScaleMin() const { return fScaleMin; }
00092    Float_t              GetScaleMax() const { return fScaleMax; }
00093    Bool_t               IsThresholdActive() { return fThresholdActive; }
00094 
00095    void Build();
00096    void Glow(EGlowColor col = kGreen);
00097    void StepScale(Float_t step);
00098    void SetScaleValue(Float_t val);
00099    void SetScaleValue(Float_t val, Int_t damping);
00100    void SetOdoValue(Int_t val);
00101    void SetDisplayText(const char *text1, const char *text2 = "");
00102    void SetLabelText(const char *text1, const char *text2 = "");
00103    void SetMinMaxScale(Float_t min, Float_t max);
00104    void SetThresholds(Float_t th1 = 0.0, Float_t th2 = 0.0, Float_t th3 = 0.0)
00105              { fThreshold[0] = th1; fThreshold[1] = th2; fThreshold[2] = th3; }
00106    void SetThresholdColors(EGlowColor col1, EGlowColor col2, EGlowColor col3)
00107              { fThresholdColor[0] = col1; fThresholdColor[1] = col2; fThresholdColor[2] = col3; }
00108    void EnableThreshold() { fThresholdActive = kTRUE; }
00109    void DisableThreshold() { fThresholdActive = kFALSE; Glow(kNoglow); fClient->NeedRedraw(this);}
00110    void EnablePeakMark() { fPeakMark = kTRUE; }
00111    void DisablePeakMark() { fPeakMark = kFALSE; }
00112    void EnableMeanMark() { fMeanMark = kTRUE; }
00113    void DisableMeanMark() { fMeanMark = kFALSE; }
00114    void ResetPeakVal() { fPeakVal = fValue; fClient->NeedRedraw(this); }
00115    void SetMeanValue(Float_t mean) { fMeanVal = mean; fClient->NeedRedraw(this); }
00116 
00117    void OdoClicked() { Emit("OdoClicked()"); }   // *SIGNAL*
00118    void LedClicked() { Emit("LedClicked()"); }   // *SIGNAL*
00119 
00120    ClassDef(TGSpeedo,0)  // Base class for analog meter widget
00121 };
00122 
00123 #endif

Generated on Tue Jul 5 14:20:07 2011 for ROOT_528-00b_version by  doxygen 1.5.1