Logo ROOT  
Reference Guide
No Matches
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
64 Int_t fBufferSize; // circular buffer size
65 Int_t fBufferCount; // circular buffer count
66 std::vector<Float_t> fBuffer; // circular buffer for mean calculation
68 virtual void DoRedraw();
69 void DrawNeedle();
70 void DrawText();
71 void Translate(Float_t val, Float_t angle, Int_t *x, Int_t *y);
74 TGSpeedo(const TGWindow *p = 0, int id = -1);
75 TGSpeedo(const TGWindow *p, Float_t smin, Float_t smax,
76 const char *lbl1 = "", const char *lbl2 = "",
77 const char *dsp1 = "", const char *dsp2 = "", int id = -1);
78 virtual ~TGSpeedo();
80 virtual TGDimension GetDefaultSize() const;
81 virtual Bool_t HandleButton(Event_t *event);
83 const TGPicture *GetPicture() const { return fBase; }
84 TImage *GetImage() const { return fImage; }
85 Int_t GetOdoVal() const { return fCounter; }
86 Float_t GetPeakVal() const { return fPeakVal; }
87 Float_t GetScaleMin() const { return fScaleMin; }
88 Float_t GetScaleMax() const { return fScaleMax; }
92 void Build();
93 void Glow(EGlowColor col = kGreen);
94 void StepScale(Float_t step);
95 void SetScaleValue(Float_t val);
96 void SetScaleValue(Float_t val, Int_t damping);
97 void SetOdoValue(Int_t val);
98 void SetDisplayText(const char *text1, const char *text2 = "");
99 void SetLabelText(const char *text1, const char *text2 = "");
100 void SetMinMaxScale(Float_t min, Float_t max);
101 void SetThresholds(Float_t th1 = 0.0, Float_t th2 = 0.0, Float_t th3 = 0.0)
102 { fThreshold[0] = th1; fThreshold[1] = th2; fThreshold[2] = th3; }
104 { fThresholdColor[0] = col1; fThresholdColor[1] = col2; fThresholdColor[2] = col3; }
112 void SetMeanValue(Float_t mean) { fMeanVal = mean; fClient->NeedRedraw(this); }
113 void SetBufferSize(Int_t size);
115 void OdoClicked() { Emit("OdoClicked()"); } // *SIGNAL*
116 void LedClicked() { Emit("LedClicked()"); } // *SIGNAL*
118 ClassDef(TGSpeedo,0) // Base class for analog meter widget
Handle_t FontStruct_t
Pointer to font structure.
Definition GuiTypes.h:39
int Int_t
Definition RtypesCore.h:45
const Bool_t kFALSE
Definition RtypesCore.h:92
float Float_t
Definition RtypesCore.h:57
const Bool_t kTRUE
Definition RtypesCore.h:91
#define ClassDef(name, id)
Definition Rtypes.h:325
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition TGClient.cxx:371
TGClient * fClient
Definition TGObject.h:37
const TGPicture * fBase
Definition TGSpeedo.h:46
Int_t fBufferSize
Definition TGSpeedo.h:64
void SetOdoValue(Int_t val)
Set actual value of odo meter.
Definition TGSpeedo.cxx:338
virtual ~TGSpeedo()
TGSpeedo widget Destructor.
Definition TGSpeedo.cxx:212
void ResetPeakVal()
Definition TGSpeedo.h:111
Float_t GetMean()
Compute and return the mean of the circular buffer content.
Definition TGSpeedo.cxx:235
Float_t GetScaleMin() const
Definition TGSpeedo.h:87
void DisableMeanMark()
Definition TGSpeedo.h:110
void EnableThreshold()
Definition TGSpeedo.h:105
TString fLabel1
Definition TGSpeedo.h:50
void StepScale(Float_t step)
Increment/decrement scale (needle position) of "step" value.
Definition TGSpeedo.cxx:488
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:351
Float_t fAngleMin
Definition TGSpeedo.h:57
TString fDisplay1
Definition TGSpeedo.h:52
virtual void DoRedraw()
Redraw speedo widget.
Definition TGSpeedo.cxx:612
Float_t fScaleMin
Definition TGSpeedo.h:58
@ kOrange
Definition TGSpeedo.h:41
@ kNoglow
Definition TGSpeedo.h:41
Float_t fAngle
Definition TGSpeedo.h:54
Bool_t IsThresholdActive()
Definition TGSpeedo.h:89
void Glow(EGlowColor col=kGreen)
Make speedo glowing.
Definition TGSpeedo.cxx:245
void SetMinMaxScale(Float_t min, Float_t max)
Set min and max scale values.
Definition TGSpeedo.cxx:381
Float_t fMeanVal
Definition TGSpeedo.h:56
const TGPicture * GetPicture() const
Definition TGSpeedo.h:83
Int_t fCounter
Definition TGSpeedo.h:48
TImage * fImage
Definition TGSpeedo.h:44
Float_t GetPeakVal() const
Definition TGSpeedo.h:86
void OdoClicked()
Definition TGSpeedo.h:115
void DisableThreshold()
Definition TGSpeedo.h:106
void SetBufferSize(Int_t size)
Change the circular buffer size (used for the automatic mean calculation).
Definition TGSpeedo.cxx:326
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event.
Definition TGSpeedo.cxx:294
FontStruct_t fCounterFS
Definition TGSpeedo.h:47
void DrawText()
Draw text in speedo widget.
Definition TGSpeedo.cxx:558
void SetThresholds(Float_t th1=0.0, Float_t th2=0.0, Float_t th3=0.0)
Definition TGSpeedo.h:101
void SetThresholdColors(EGlowColor col1, EGlowColor col2, EGlowColor col3)
Definition TGSpeedo.h:103
TString fDisplay2
Definition TGSpeedo.h:53
Int_t GetOdoVal() const
Definition TGSpeedo.h:85
Float_t fScaleMax
Definition TGSpeedo.h:58
Float_t fPeakVal
Definition TGSpeedo.h:55
Int_t fBufferCount
Definition TGSpeedo.h:65
virtual TGDimension GetDefaultSize() const
Return default dimension of the widget.
Definition TGSpeedo.cxx:225
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:496
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:365
TImage * fImage2
Definition TGSpeedo.h:45
void SetScaleValue(Float_t val)
Set actual scale (needle position) value.
Definition TGSpeedo.cxx:397
Bool_t fMeanMark
Definition TGSpeedo.h:63
void EnableMeanMark()
Definition TGSpeedo.h:109
void SetMeanValue(Float_t mean)
Definition TGSpeedo.h:112
void EnablePeakMark()
Definition TGSpeedo.h:107
std::vector< Float_t > fBuffer
Definition TGSpeedo.h:66
Float_t GetScaleMax() const
Definition TGSpeedo.h:88
TString fLabel2
Definition TGSpeedo.h:51
Float_t fAngleMax
Definition TGSpeedo.h:57
void DisablePeakMark()
Definition TGSpeedo.h:108
void LedClicked()
Definition TGSpeedo.h:116
TImage * GetImage() const
Definition TGSpeedo.h:84
void Build()
Build TGSpeedo widget.
Definition TGSpeedo.cxx:123
void DrawNeedle()
Draw needle in speedo widget.
Definition TGSpeedo.cxx:507
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:136
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Event structure.
Definition GuiTypes.h:174
auto * th3
Definition textalign.C:21
auto * th2
Definition textalign.C:17
auto * th1
Definition textalign.C:13