Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-12 09:27:00

0001 // @(#)root/gui:$Id: TGSpeedo.h
0002 // Author: Bertrand Bellenot   26/10/06
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TGSpeedo
0013 #define ROOT_TGSpeedo
0014 
0015 
0016 #include "TGFrame.h"
0017 #include "TGWidget.h"
0018 #include "TGPicture.h"
0019 #include "TImage.h"
0020 
0021 
0022 class TGSpeedo : public TGFrame, public TGWidget {
0023 
0024 public:
0025    enum EGlowColor { kNoglow,
0026 // clang++ <v20 (-Wshadow) complains about shadowing Rtypes.h global enum EColor. Let's silence warning:
0027 #if defined(__clang__) && __clang_major__ < 20
0028 #pragma clang diagnostic push
0029 #pragma clang diagnostic ignored "-Wshadow"
0030 #endif
0031       kGreen, kOrange, kRed };
0032 #if defined(__clang__) && __clang_major__ < 20
0033 #pragma clang diagnostic pop
0034 #endif
0035 
0036 protected:
0037    TImage          *fImage;               ///< image used as background
0038    TImage          *fImage2;              ///< intermediate image used as background
0039    const TGPicture *fBase;                ///< picture used as background
0040    FontStruct_t     fTextFS, fCounterFS;  ///< font structures for text rendering
0041    Int_t            fCounter;             ///< small odo meter (4 digits)
0042    TString          fPicName;             ///< name of picture used as background
0043    TString          fLabel1;              ///< main label (first line)
0044    TString          fLabel2;              ///< main label (second line)
0045    TString          fDisplay1;            ///< first line in the small display
0046    TString          fDisplay2;            ///< second line in the small display
0047    Float_t          fAngle, fValue;       ///< needle angle and corresponding value
0048    Float_t          fPeakVal;             ///< maximum peak mark
0049    Float_t          fMeanVal;             ///< mean value mark
0050    Float_t          fAngleMin, fAngleMax; ///< needle min and max angle
0051    Float_t          fScaleMin, fScaleMax; ///< needle min and max scale
0052    Float_t          fThreshold[3];        ///< glowing thresholds
0053    EGlowColor       fThresholdColor[3];   ///< glowing threshold colors
0054    Bool_t           fThresholdActive;     ///< kTRUE if glowing thresholds are active
0055    Bool_t           fPeakMark;            ///< kTRUE if peak mark is active
0056    Bool_t           fMeanMark;            ///< kTRUE if mean mark is active
0057    Int_t            fBufferSize;          ///< circular buffer size
0058    Int_t            fBufferCount;         ///< circular buffer count
0059    std::vector<Float_t> fBuffer;          ///< circular buffer for mean calculation
0060 
0061    void     DoRedraw() override;
0062    void     DrawNeedle();
0063    void     DrawText();
0064    void     Translate(Float_t val, Float_t angle, Int_t *x, Int_t *y);
0065 
0066 public:
0067    TGSpeedo(const TGWindow *p = nullptr, int id = -1);
0068    TGSpeedo(const TGWindow *p, Float_t smin, Float_t smax,
0069             const char *lbl1 = "", const char *lbl2 = "",
0070             const char *dsp1 = "", const char *dsp2 = "", int id = -1);
0071    ~TGSpeedo() override;
0072 
0073    TGDimension          GetDefaultSize() const override;
0074    Bool_t               HandleButton(Event_t *event) override;
0075 
0076    const TGPicture     *GetPicture() const { return fBase; }
0077    TImage              *GetImage() const { return fImage; }
0078    Int_t                GetOdoVal() const { return fCounter; }
0079    Float_t              GetPeakVal() const { return fPeakVal; }
0080    Float_t              GetScaleMin() const { return fScaleMin; }
0081    Float_t              GetScaleMax() const { return fScaleMax; }
0082    Bool_t               IsThresholdActive() { return fThresholdActive; }
0083    Float_t              GetMean();
0084 
0085    void Build();
0086    void Glow(EGlowColor col = kGreen);
0087    void StepScale(Float_t step);
0088    void SetScaleValue(Float_t val);
0089    void SetScaleValue(Float_t val, Int_t damping);
0090    void SetOdoValue(Int_t val);
0091    void SetDisplayText(const char *text1, const char *text2 = "");
0092    void SetLabelText(const char *text1, const char *text2 = "");
0093    void SetMinMaxScale(Float_t min, Float_t max);
0094    void SetThresholds(Float_t th1 = 0.0, Float_t th2 = 0.0, Float_t th3 = 0.0)
0095              { fThreshold[0] = th1; fThreshold[1] = th2; fThreshold[2] = th3; }
0096    void SetThresholdColors(EGlowColor col1, EGlowColor col2, EGlowColor col3)
0097              { fThresholdColor[0] = col1; fThresholdColor[1] = col2; fThresholdColor[2] = col3; }
0098    void EnableThreshold() { fThresholdActive = kTRUE; }
0099    void DisableThreshold() { fThresholdActive = kFALSE; Glow(kNoglow); fClient->NeedRedraw(this);}
0100    void EnablePeakMark() { fPeakMark = kTRUE; }
0101    void DisablePeakMark() { fPeakMark = kFALSE; }
0102    void EnableMeanMark() { fMeanMark = kTRUE; }
0103    void DisableMeanMark() { fMeanMark = kFALSE; }
0104    void ResetPeakVal() { fPeakVal = fValue; fClient->NeedRedraw(this); }
0105    void SetMeanValue(Float_t mean) { fMeanVal = mean; fClient->NeedRedraw(this); }
0106    void SetBufferSize(Int_t size);
0107 
0108    void OdoClicked() { Emit("OdoClicked()"); }   // *SIGNAL*
0109    void LedClicked() { Emit("LedClicked()"); }   // *SIGNAL*
0110 
0111    ClassDefOverride(TGSpeedo,0)  // Base class for analog meter widget
0112 };
0113 
0114 #endif