Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:12:05

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, kGreen, kOrange, kRed };
0026 
0027 protected:
0028    TImage          *fImage;               ///< image used as background
0029    TImage          *fImage2;              ///< intermediate image used as background
0030    const TGPicture *fBase;                ///< picture used as background
0031    FontStruct_t     fTextFS, fCounterFS;  ///< font structures for text rendering
0032    Int_t            fCounter;             ///< small odo meter (4 digits)
0033    TString          fPicName;             ///< name of picture used as background
0034    TString          fLabel1;              ///< main label (first line)
0035    TString          fLabel2;              ///< main label (second line)
0036    TString          fDisplay1;            ///< first line in the small display
0037    TString          fDisplay2;            ///< second line in the small display
0038    Float_t          fAngle, fValue;       ///< needle angle and corresponding value
0039    Float_t          fPeakVal;             ///< maximum peak mark
0040    Float_t          fMeanVal;             ///< mean value mark
0041    Float_t          fAngleMin, fAngleMax; ///< needle min and max angle
0042    Float_t          fScaleMin, fScaleMax; ///< needle min and max scale
0043    Float_t          fThreshold[3];        ///< glowing thresholds
0044    EGlowColor       fThresholdColor[3];   ///< glowing threshold colors
0045    Bool_t           fThresholdActive;     ///< kTRUE if glowing thresholds are active
0046    Bool_t           fPeakMark;            ///< kTRUE if peak mark is active
0047    Bool_t           fMeanMark;            ///< kTRUE if mean mark is active
0048    Int_t            fBufferSize;          ///< circular buffer size
0049    Int_t            fBufferCount;         ///< circular buffer count
0050    std::vector<Float_t> fBuffer;          ///< circular buffer for mean calculation
0051 
0052    void     DoRedraw() override;
0053    void     DrawNeedle();
0054    void     DrawText();
0055    void     Translate(Float_t val, Float_t angle, Int_t *x, Int_t *y);
0056 
0057 public:
0058    TGSpeedo(const TGWindow *p = nullptr, int id = -1);
0059    TGSpeedo(const TGWindow *p, Float_t smin, Float_t smax,
0060             const char *lbl1 = "", const char *lbl2 = "",
0061             const char *dsp1 = "", const char *dsp2 = "", int id = -1);
0062    ~TGSpeedo() override;
0063 
0064    TGDimension          GetDefaultSize() const override;
0065    Bool_t               HandleButton(Event_t *event) override;
0066 
0067    const TGPicture     *GetPicture() const { return fBase; }
0068    TImage              *GetImage() const { return fImage; }
0069    Int_t                GetOdoVal() const { return fCounter; }
0070    Float_t              GetPeakVal() const { return fPeakVal; }
0071    Float_t              GetScaleMin() const { return fScaleMin; }
0072    Float_t              GetScaleMax() const { return fScaleMax; }
0073    Bool_t               IsThresholdActive() { return fThresholdActive; }
0074    Float_t              GetMean();
0075 
0076    void Build();
0077    void Glow(EGlowColor col = kGreen);
0078    void StepScale(Float_t step);
0079    void SetScaleValue(Float_t val);
0080    void SetScaleValue(Float_t val, Int_t damping);
0081    void SetOdoValue(Int_t val);
0082    void SetDisplayText(const char *text1, const char *text2 = "");
0083    void SetLabelText(const char *text1, const char *text2 = "");
0084    void SetMinMaxScale(Float_t min, Float_t max);
0085    void SetThresholds(Float_t th1 = 0.0, Float_t th2 = 0.0, Float_t th3 = 0.0)
0086              { fThreshold[0] = th1; fThreshold[1] = th2; fThreshold[2] = th3; }
0087    void SetThresholdColors(EGlowColor col1, EGlowColor col2, EGlowColor col3)
0088              { fThresholdColor[0] = col1; fThresholdColor[1] = col2; fThresholdColor[2] = col3; }
0089    void EnableThreshold() { fThresholdActive = kTRUE; }
0090    void DisableThreshold() { fThresholdActive = kFALSE; Glow(kNoglow); fClient->NeedRedraw(this);}
0091    void EnablePeakMark() { fPeakMark = kTRUE; }
0092    void DisablePeakMark() { fPeakMark = kFALSE; }
0093    void EnableMeanMark() { fMeanMark = kTRUE; }
0094    void DisableMeanMark() { fMeanMark = kFALSE; }
0095    void ResetPeakVal() { fPeakVal = fValue; fClient->NeedRedraw(this); }
0096    void SetMeanValue(Float_t mean) { fMeanVal = mean; fClient->NeedRedraw(this); }
0097    void SetBufferSize(Int_t size);
0098 
0099    void OdoClicked() { Emit("OdoClicked()"); }   // *SIGNAL*
0100    void LedClicked() { Emit("LedClicked()"); }   // *SIGNAL*
0101 
0102    ClassDefOverride(TGSpeedo,0)  // Base class for analog meter widget
0103 };
0104 
0105 #endif