Logo ROOT   6.10/09
Reference Guide
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:
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; }
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; }
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
Bool_t fThresholdActive
Definition: TGSpeedo.h:61
Handle_t FontStruct_t
Definition: GuiTypes.h:38
const TGPicture * GetPicture() const
Definition: TGSpeedo.h:80
TText * th3
Definition: textalign.C:21
Int_t fCounter
Definition: TGSpeedo.h:48
float Float_t
Definition: RtypesCore.h:53
TString fDisplay2
Definition: TGSpeedo.h:53
void SetDisplayText(const char *text1, const char *text2="")
Set small display text (two lines).
Definition: TGSpeedo.cxx:319
Float_t GetScaleMax() const
Definition: TGSpeedo.h:84
void DrawNeedle()
Draw needle in speedo widget.
Definition: TGSpeedo.cxx:465
void StepScale(Float_t step)
Increment/decrement scale (needle position) of "step" value.
Definition: TGSpeedo.cxx:446
Bool_t IsThresholdActive()
Definition: TGSpeedo.h:85
void DrawText()
Draw text in speedo widget.
Definition: TGSpeedo.cxx:514
Basic string class.
Definition: TString.h:129
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
void Translate(Float_t val, Float_t angle, Int_t *x, Int_t *y)
Translate distance from center and angle to xy coordinates.
Definition: TGSpeedo.cxx:454
void DisablePeakMark()
Definition: TGSpeedo.h:103
An abstract interface to image processing library.
Definition: TImage.h:29
Float_t fAngle
Definition: TGSpeedo.h:54
void SetMinMaxScale(Float_t min, Float_t max)
Set min and max scale values.
Definition: TGSpeedo.cxx:349
Double_t x[n]
Definition: legend1.C:17
Float_t fValue
Definition: TGSpeedo.h:54
#define ClassDef(name, id)
Definition: Rtypes.h:297
TString fPicName
Definition: TGSpeedo.h:49
TGSpeedo(const TGWindow *p=0, int id=-1)
TGSpeedo widget constructor.
Definition: TGSpeedo.cxx:50
TText * th2
Definition: textalign.C:17
TImage * fImage2
Definition: TGSpeedo.h:45
EGlowColor
Definition: TGSpeedo.h:41
virtual TGDimension GetDefaultSize() const
Return default dimension of the widget.
Definition: TGSpeedo.cxx:220
void EnablePeakMark()
Definition: TGSpeedo.h:102
void SetOdoValue(Int_t val)
Set actual value of odo meter.
Definition: TGSpeedo.cxx:306
void DisableThreshold()
Definition: TGSpeedo.h:101
Float_t fMeanVal
Definition: TGSpeedo.h:56
Float_t GetPeakVal() const
Definition: TGSpeedo.h:82
void LedClicked()
Definition: TGSpeedo.h:110
TImage * fImage
Definition: TGSpeedo.h:44
TText * th1
Definition: textalign.C:13
Float_t fAngleMax
Definition: TGSpeedo.h:57
void ResetPeakVal()
Definition: TGSpeedo.h:106
FontStruct_t fTextFS
Definition: TGSpeedo.h:47
void SetThresholdColors(EGlowColor col1, EGlowColor col2, EGlowColor col3)
Definition: TGSpeedo.h:98
void SetScaleValue(Float_t val)
Set actual scale (needle position) value.
Definition: TGSpeedo.cxx:365
Bool_t fPeakMark
Definition: TGSpeedo.h:62
void DisableMeanMark()
Definition: TGSpeedo.h:105
void Glow(EGlowColor col=kGreen)
Make speedo glowing.
Definition: TGSpeedo.cxx:230
TString fLabel2
Definition: TGSpeedo.h:51
void SetLabelText(const char *text1, const char *text2="")
Set main label text (two lines).
Definition: TGSpeedo.cxx:333
virtual ~TGSpeedo()
TGSpeedo widget Destructor.
Definition: TGSpeedo.cxx:207
TImage * GetImage() const
Definition: TGSpeedo.h:81
FontStruct_t fCounterFS
Definition: TGSpeedo.h:47
TString fDisplay1
Definition: TGSpeedo.h:52
const Bool_t kFALSE
Definition: RtypesCore.h:92
void Build()
Build TGSpeedo widget.
Definition: TGSpeedo.cxx:118
Float_t fScaleMin
Definition: TGSpeedo.h:58
Float_t fScaleMax
Definition: TGSpeedo.h:58
Double_t y[n]
Definition: legend1.C:17
void EnableThreshold()
Definition: TGSpeedo.h:100
Float_t GetScaleMin() const
Definition: TGSpeedo.h:83
void SetMeanValue(Float_t mean)
Definition: TGSpeedo.h:107
Bool_t fMeanMark
Definition: TGSpeedo.h:63
Float_t fAngleMin
Definition: TGSpeedo.h:57
EGlowColor fThresholdColor[3]
Definition: TGSpeedo.h:60
TGClient * fClient
Definition: TGObject.h:37
Float_t fPeakVal
Definition: TGSpeedo.h:55
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:370
TString fLabel1
Definition: TGSpeedo.h:50
const TGPicture * fBase
Definition: TGSpeedo.h:46
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:164
void OdoClicked()
Definition: TGSpeedo.h:109
void SetThresholds(Float_t th1=0.0, Float_t th2=0.0, Float_t th3=0.0)
Definition: TGSpeedo.h:96
const Bool_t kTRUE
Definition: RtypesCore.h:91
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event.
Definition: TGSpeedo.cxx:279
virtual void DoRedraw()
Redraw speedo widget.
Definition: TGSpeedo.cxx:568
void EnableMeanMark()
Definition: TGSpeedo.h:104
Float_t fThreshold[3]
Definition: TGSpeedo.h:59