File indexing completed on 2025-01-18 10:12:05
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, kGreen, kOrange, kRed };
0026
0027 protected:
0028 TImage *fImage;
0029 TImage *fImage2;
0030 const TGPicture *fBase;
0031 FontStruct_t fTextFS, fCounterFS;
0032 Int_t fCounter;
0033 TString fPicName;
0034 TString fLabel1;
0035 TString fLabel2;
0036 TString fDisplay1;
0037 TString fDisplay2;
0038 Float_t fAngle, fValue;
0039 Float_t fPeakVal;
0040 Float_t fMeanVal;
0041 Float_t fAngleMin, fAngleMax;
0042 Float_t fScaleMin, fScaleMax;
0043 Float_t fThreshold[3];
0044 EGlowColor fThresholdColor[3];
0045 Bool_t fThresholdActive;
0046 Bool_t fPeakMark;
0047 Bool_t fMeanMark;
0048 Int_t fBufferSize;
0049 Int_t fBufferCount;
0050 std::vector<Float_t> fBuffer;
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()"); }
0100 void LedClicked() { Emit("LedClicked()"); }
0101
0102 ClassDefOverride(TGSpeedo,0)
0103 };
0104
0105 #endif