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