Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TGSpeedo.h
Go to the documentation of this file.
1 // @(#)root/gui:$Id: TGSpeedo.h
2 // Author: Bertrand Bellenot 26/10/06
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TGSpeedo
13 #define ROOT_TGSpeedo
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // TGSpeedo //
18 // //
19 // TGSpeedo is a widget looking like a speedometer, with a needle, //
20 // a counter and a small odometer window. //
21 // //
22 // Three thresholds are configurable, with their glowing color //
23 // A peak mark can be enabled, allowing to keep track of the highest //
24 // value displayed. The mark can be reset by right-clicking on the //
25 // widget. //
26 // Two signals are available: //
27 // OdoClicked(): when user click on the small odometer window //
28 // LedClicked(): when user click on the small led near the counter //
29 // //
30 //////////////////////////////////////////////////////////////////////////
31 
32 #include "TGFrame.h"
33 #include "TGWidget.h"
34 #include "TGPicture.h"
35 #include "TImage.h"
36 
37 
38 class TGSpeedo : public TGFrame, public TGWidget {
39 
40 public:
41  enum EGlowColor { kNoglow, kGreen, kOrange, kRed };
42 
43 protected:
44  TImage *fImage; // image used as background
45  TImage *fImage2; // intermediate image used as background
46  const TGPicture *fBase; // picture used as background
47  FontStruct_t fTextFS, fCounterFS; // font structures for text rendering
48  Int_t fCounter; // small odo meter (4 digits)
49  TString fPicName; // name of picture used as background
50  TString fLabel1; // main label (first line)
51  TString fLabel2; // main label (second line)
52  TString fDisplay1; // first line in the small display
53  TString fDisplay2; // second line in the small display
54  Float_t fAngle, fValue; // needle angle and corresponding value
55  Float_t fPeakVal; // maximum peak mark
56  Float_t fMeanVal; // mean value mark
57  Float_t fAngleMin, fAngleMax; // needle min and max angle
58  Float_t fScaleMin, fScaleMax; // needle min and max scale
59  Float_t fThreshold[3]; // glowing thresholds
60  EGlowColor fThresholdColor[3]; // glowing threshold colors
61  Bool_t fThresholdActive; // kTRUE if glowing threhsholds are active
62  Bool_t fPeakMark; // kTRUE if peak mark is active
63  Bool_t fMeanMark; // kTRUE if mean mark is active
64 
65  virtual void DoRedraw();
66  void DrawNeedle();
67  void DrawText();
68  void Translate(Float_t val, Float_t angle, Int_t *x, Int_t *y);
69 
70 public:
71  TGSpeedo(const TGWindow *p = 0, int id = -1);
72  TGSpeedo(const TGWindow *p, Float_t smin, Float_t smax,
73  const char *lbl1 = "", const char *lbl2 = "",
74  const char *dsp1 = "", const char *dsp2 = "", int id = -1);
75  virtual ~TGSpeedo();
76 
77  virtual TGDimension GetDefaultSize() const;
78  virtual Bool_t HandleButton(Event_t *event);
79 
80  const TGPicture *GetPicture() const { return fBase; }
81  TImage *GetImage() const { return fImage; }
82  Float_t GetPeakVal() const { return fPeakVal; }
83  Float_t GetScaleMin() const { return fScaleMin; }
84  Float_t GetScaleMax() const { return fScaleMax; }
85  Bool_t IsThresholdActive() { return fThresholdActive; }
86 
87  void Build();
88  void Glow(EGlowColor col = kGreen);
89  void StepScale(Float_t step);
90  void SetScaleValue(Float_t val);
91  void SetScaleValue(Float_t val, Int_t damping);
92  void SetOdoValue(Int_t val);
93  void SetDisplayText(const char *text1, const char *text2 = "");
94  void SetLabelText(const char *text1, const char *text2 = "");
95  void SetMinMaxScale(Float_t min, Float_t max);
96  void SetThresholds(Float_t th1 = 0.0, Float_t th2 = 0.0, Float_t th3 = 0.0)
97  { fThreshold[0] = th1; fThreshold[1] = th2; fThreshold[2] = th3; }
98  void SetThresholdColors(EGlowColor col1, EGlowColor col2, EGlowColor col3)
99  { fThresholdColor[0] = col1; fThresholdColor[1] = col2; fThresholdColor[2] = col3; }
100  void EnableThreshold() { fThresholdActive = kTRUE; }
101  void DisableThreshold() { fThresholdActive = kFALSE; Glow(kNoglow); fClient->NeedRedraw(this);}
102  void EnablePeakMark() { fPeakMark = kTRUE; }
103  void DisablePeakMark() { fPeakMark = kFALSE; }
104  void EnableMeanMark() { fMeanMark = kTRUE; }
105  void DisableMeanMark() { fMeanMark = kFALSE; }
106  void ResetPeakVal() { fPeakVal = fValue; fClient->NeedRedraw(this); }
107  void SetMeanValue(Float_t mean) { fMeanVal = mean; fClient->NeedRedraw(this); }
108 
109  void OdoClicked() { Emit("OdoClicked()"); } // *SIGNAL*
110  void LedClicked() { Emit("LedClicked()"); } // *SIGNAL*
111 
112  ClassDef(TGSpeedo,0) // Base class for analog meter widget
113 };
114 
115 #endif