Logo ROOT   6.08/07
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 #ifndef ROOT_TGFrame
33 #include "TGFrame.h"
34 #endif
35 #ifndef ROOT_TGWidget
36 #include "TGWidget.h"
37 #endif
38 #ifndef ROOT_TGPicture
39 #include "TGPicture.h"
40 #endif
41 #ifndef ROOT_TImage
42 #include "TImage.h"
43 #endif
44 
45 
46 class TGSpeedo : public TGFrame, public TGWidget {
47 
48 public:
50 
51 protected:
52  TImage *fImage; // image used as background
53  TImage *fImage2; // intermediate image used as background
54  const TGPicture *fBase; // picture used as background
55  FontStruct_t fTextFS, fCounterFS; // font structures for text rendering
56  Int_t fCounter; // small odo meter (4 digits)
57  TString fPicName; // name of picture used as background
58  TString fLabel1; // main label (first line)
59  TString fLabel2; // main label (second line)
60  TString fDisplay1; // first line in the small display
61  TString fDisplay2; // second line in the small display
62  Float_t fAngle, fValue; // needle angle and corresponding value
63  Float_t fPeakVal; // maximum peak mark
64  Float_t fMeanVal; // mean value mark
65  Float_t fAngleMin, fAngleMax; // needle min and max angle
66  Float_t fScaleMin, fScaleMax; // needle min and max scale
67  Float_t fThreshold[3]; // glowing thresholds
68  EGlowColor fThresholdColor[3]; // glowing threshold colors
69  Bool_t fThresholdActive; // kTRUE if glowing threhsholds are active
70  Bool_t fPeakMark; // kTRUE if peak mark is active
71  Bool_t fMeanMark; // kTRUE if mean mark is active
72 
73  virtual void DoRedraw();
74  void DrawNeedle();
75  void DrawText();
76  void Translate(Float_t val, Float_t angle, Int_t *x, Int_t *y);
77 
78 public:
79  TGSpeedo(const TGWindow *p = 0, int id = -1);
80  TGSpeedo(const TGWindow *p, Float_t smin, Float_t smax,
81  const char *lbl1 = "", const char *lbl2 = "",
82  const char *dsp1 = "", const char *dsp2 = "", int id = -1);
83  virtual ~TGSpeedo();
84 
85  virtual TGDimension GetDefaultSize() const;
86  virtual Bool_t HandleButton(Event_t *event);
87 
88  const TGPicture *GetPicture() const { return fBase; }
89  TImage *GetImage() const { return fImage; }
90  Float_t GetPeakVal() const { return fPeakVal; }
91  Float_t GetScaleMin() const { return fScaleMin; }
92  Float_t GetScaleMax() const { return fScaleMax; }
94 
95  void Build();
96  void Glow(EGlowColor col = kGreen);
97  void StepScale(Float_t step);
98  void SetScaleValue(Float_t val);
99  void SetScaleValue(Float_t val, Int_t damping);
100  void SetOdoValue(Int_t val);
101  void SetDisplayText(const char *text1, const char *text2 = "");
102  void SetLabelText(const char *text1, const char *text2 = "");
103  void SetMinMaxScale(Float_t min, Float_t max);
104  void SetThresholds(Float_t th1 = 0.0, Float_t th2 = 0.0, Float_t th3 = 0.0)
105  { fThreshold[0] = th1; fThreshold[1] = th2; fThreshold[2] = th3; }
107  { fThresholdColor[0] = col1; fThresholdColor[1] = col2; fThresholdColor[2] = col3; }
108  void EnableThreshold() { fThresholdActive = kTRUE; }
109  void DisableThreshold() { fThresholdActive = kFALSE; Glow(kNoglow); fClient->NeedRedraw(this);}
110  void EnablePeakMark() { fPeakMark = kTRUE; }
111  void DisablePeakMark() { fPeakMark = kFALSE; }
112  void EnableMeanMark() { fMeanMark = kTRUE; }
113  void DisableMeanMark() { fMeanMark = kFALSE; }
114  void ResetPeakVal() { fPeakVal = fValue; fClient->NeedRedraw(this); }
115  void SetMeanValue(Float_t mean) { fMeanVal = mean; fClient->NeedRedraw(this); }
116 
117  void OdoClicked() { Emit("OdoClicked()"); } // *SIGNAL*
118  void LedClicked() { Emit("LedClicked()"); } // *SIGNAL*
119 
120  ClassDef(TGSpeedo,0) // Base class for analog meter widget
121 };
122 
123 #endif
Bool_t fThresholdActive
Definition: TGSpeedo.h:69
Handle_t FontStruct_t
Definition: GuiTypes.h:40
const TGPicture * GetPicture() const
Definition: TGSpeedo.h:88
TText * th3
Definition: textalign.C:21
Int_t fCounter
Definition: TGSpeedo.h:56
float Float_t
Definition: RtypesCore.h:53
TString fDisplay2
Definition: TGSpeedo.h:61
void SetDisplayText(const char *text1, const char *text2="")
Set small display text (two lines).
Definition: TGSpeedo.cxx:320
Float_t GetScaleMax() const
Definition: TGSpeedo.h:92
void DrawNeedle()
Draw needle in speedo widget.
Definition: TGSpeedo.cxx:466
void StepScale(Float_t step)
Increment/decrement scale (needle position) of "step" value.
Definition: TGSpeedo.cxx:447
Bool_t IsThresholdActive()
Definition: TGSpeedo.h:93
void DrawText()
Draw text in speedo widget.
Definition: TGSpeedo.cxx:515
Basic string class.
Definition: TString.h:137
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:455
const Bool_t kFALSE
Definition: Rtypes.h:92
void DisablePeakMark()
Definition: TGSpeedo.h:111
An abstract interface to image processing library.
Definition: TImage.h:37
Float_t fAngle
Definition: TGSpeedo.h:62
void SetMinMaxScale(Float_t min, Float_t max)
Set min and max scale values.
Definition: TGSpeedo.cxx:350
Double_t x[n]
Definition: legend1.C:17
Float_t fValue
Definition: TGSpeedo.h:62
#define ClassDef(name, id)
Definition: Rtypes.h:254
TString fPicName
Definition: TGSpeedo.h:57
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:53
EGlowColor
Definition: TGSpeedo.h:49
virtual TGDimension GetDefaultSize() const
Return default dimension of the widget.
Definition: TGSpeedo.cxx:221
void EnablePeakMark()
Definition: TGSpeedo.h:110
void SetOdoValue(Int_t val)
Set actual value of odo meter.
Definition: TGSpeedo.cxx:307
void DisableThreshold()
Definition: TGSpeedo.h:109
Float_t fMeanVal
Definition: TGSpeedo.h:64
Float_t GetPeakVal() const
Definition: TGSpeedo.h:90
void Emit(const char *signal)
Acitvate signal without args.
Definition: TQObject.cxx:561
void LedClicked()
Definition: TGSpeedo.h:118
TImage * fImage
Definition: TGSpeedo.h:52
TText * th1
Definition: textalign.C:13
Float_t fAngleMax
Definition: TGSpeedo.h:65
void ResetPeakVal()
Definition: TGSpeedo.h:114
FontStruct_t fTextFS
Definition: TGSpeedo.h:55
void SetThresholdColors(EGlowColor col1, EGlowColor col2, EGlowColor col3)
Definition: TGSpeedo.h:106
void SetScaleValue(Float_t val)
Set actual scale (needle position) value.
Definition: TGSpeedo.cxx:366
Bool_t fPeakMark
Definition: TGSpeedo.h:70
void DisableMeanMark()
Definition: TGSpeedo.h:113
void Glow(EGlowColor col=kGreen)
Make speedo glowing.
Definition: TGSpeedo.cxx:231
TString fLabel2
Definition: TGSpeedo.h:59
void SetLabelText(const char *text1, const char *text2="")
Set main label text (two lines).
Definition: TGSpeedo.cxx:334
virtual ~TGSpeedo()
TGSpeedo widget Destructor.
Definition: TGSpeedo.cxx:208
TImage * GetImage() const
Definition: TGSpeedo.h:89
FontStruct_t fCounterFS
Definition: TGSpeedo.h:55
TString fDisplay1
Definition: TGSpeedo.h:60
void Build()
Build TGSpeedo widget.
Definition: TGSpeedo.cxx:118
Float_t fScaleMin
Definition: TGSpeedo.h:66
Float_t fScaleMax
Definition: TGSpeedo.h:66
Double_t y[n]
Definition: legend1.C:17
void EnableThreshold()
Definition: TGSpeedo.h:108
Float_t GetScaleMin() const
Definition: TGSpeedo.h:91
void SetMeanValue(Float_t mean)
Definition: TGSpeedo.h:115
Bool_t fMeanMark
Definition: TGSpeedo.h:71
Float_t fAngleMin
Definition: TGSpeedo.h:65
EGlowColor fThresholdColor[3]
Definition: TGSpeedo.h:68
TGClient * fClient
Definition: TGObject.h:41
Float_t fPeakVal
Definition: TGSpeedo.h:63
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:370
TString fLabel1
Definition: TGSpeedo.h:58
const TGPicture * fBase
Definition: TGSpeedo.h:54
void OdoClicked()
Definition: TGSpeedo.h:117
const Bool_t kTRUE
Definition: Rtypes.h:91
void SetThresholds(Float_t th1=0.0, Float_t th2=0.0, Float_t th3=0.0)
Definition: TGSpeedo.h:104
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event.
Definition: TGSpeedo.cxx:280
virtual void DoRedraw()
Redraw speedo widget.
Definition: TGSpeedo.cxx:570
void EnableMeanMark()
Definition: TGSpeedo.h:112
Float_t fThreshold[3]
Definition: TGSpeedo.h:67