File indexing completed on 2026-09-12 09:27:00
0001
0002
0003
0004
0005
0006
0007
0008
0009
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
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;
0038 TImage *fImage2;
0039 const TGPicture *fBase;
0040 FontStruct_t fTextFS, fCounterFS;
0041 Int_t fCounter;
0042 TString fPicName;
0043 TString fLabel1;
0044 TString fLabel2;
0045 TString fDisplay1;
0046 TString fDisplay2;
0047 Float_t fAngle, fValue;
0048 Float_t fPeakVal;
0049 Float_t fMeanVal;
0050 Float_t fAngleMin, fAngleMax;
0051 Float_t fScaleMin, fScaleMax;
0052 Float_t fThreshold[3];
0053 EGlowColor fThresholdColor[3];
0054 Bool_t fThresholdActive;
0055 Bool_t fPeakMark;
0056 Bool_t fMeanMark;
0057 Int_t fBufferSize;
0058 Int_t fBufferCount;
0059 std::vector<Float_t> fBuffer;
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()"); }
0109 void LedClicked() { Emit("LedClicked()"); }
0110
0111 ClassDefOverride(TGSpeedo,0)
0112 };
0113
0114 #endif