Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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#include "TGFrame.h"
17#include "TGWidget.h"
18#include "TGPicture.h"
19#include "TImage.h"
20
21
22class TGSpeedo : public TGFrame, public TGWidget {
23
24public:
26// clang++ <v20 (-Wshadow) complains about shadowing Rtypes.h global enum EColor. Let's silence warning:
27#if defined(__clang__) && __clang_major__ < 20
28#pragma clang diagnostic push
29#pragma clang diagnostic ignored "-Wshadow"
30#endif
32#if defined(__clang__) && __clang_major__ < 20
33#pragma clang diagnostic pop
34#endif
35
36protected:
37 TImage *fImage; ///< image used as background
38 TImage *fImage2; ///< intermediate image used as background
39 const TGPicture *fBase; ///< picture used as background
40 FontStruct_t fTextFS, fCounterFS; ///< font structures for text rendering
41 Int_t fCounter; ///< small odo meter (4 digits)
42 TString fPicName; ///< name of picture used as background
43 TString fLabel1; ///< main label (first line)
44 TString fLabel2; ///< main label (second line)
45 TString fDisplay1; ///< first line in the small display
46 TString fDisplay2; ///< second line in the small display
47 Float_t fAngle, fValue; ///< needle angle and corresponding value
48 Float_t fPeakVal; ///< maximum peak mark
49 Float_t fMeanVal; ///< mean value mark
50 Float_t fAngleMin, fAngleMax; ///< needle min and max angle
51 Float_t fScaleMin, fScaleMax; ///< needle min and max scale
52 Float_t fThreshold[3]; ///< glowing thresholds
53 EGlowColor fThresholdColor[3]; ///< glowing threshold colors
54 Bool_t fThresholdActive; ///< kTRUE if glowing thresholds are active
55 Bool_t fPeakMark; ///< kTRUE if peak mark is active
56 Bool_t fMeanMark; ///< kTRUE if mean mark is active
57 Int_t fBufferSize; ///< circular buffer size
58 Int_t fBufferCount; ///< circular buffer count
59 std::vector<Float_t> fBuffer; ///< circular buffer for mean calculation
60
61 void DoRedraw() override;
62 void DrawNeedle();
63 void DrawText();
64 void Translate(Float_t val, Float_t angle, Int_t *x, Int_t *y);
65
66public:
67 TGSpeedo(const TGWindow *p = nullptr, int id = -1);
69 const char *lbl1 = "", const char *lbl2 = "",
70 const char *dsp1 = "", const char *dsp2 = "", int id = -1);
71 ~TGSpeedo() override;
72
73 TGDimension GetDefaultSize() const override;
74 Bool_t HandleButton(Event_t *event) override;
75
76 const TGPicture *GetPicture() const { return fBase; }
77 TImage *GetImage() const { return fImage; }
78 Int_t GetOdoVal() const { return fCounter; }
79 Float_t GetPeakVal() const { return fPeakVal; }
80 Float_t GetScaleMin() const { return fScaleMin; }
81 Float_t GetScaleMax() const { return fScaleMax; }
84
85 void Build();
86 void Glow(EGlowColor col = kGreen);
87 void StepScale(Float_t step);
88 void SetScaleValue(Float_t val);
90 void SetOdoValue(Int_t val);
91 void SetDisplayText(const char *text1, const char *text2 = "");
92 void SetLabelText(const char *text1, const char *text2 = "");
93 void SetMinMaxScale(Float_t min, Float_t max);
94 void SetThresholds(Float_t th1 = 0.0, Float_t th2 = 0.0, Float_t th3 = 0.0)
95 { fThreshold[0] = th1; fThreshold[1] = th2; fThreshold[2] = th3; }
105 void SetMeanValue(Float_t mean) { fMeanVal = mean; fClient->NeedRedraw(this); }
107
108 void OdoClicked() { Emit("OdoClicked()"); } // *SIGNAL*
109 void LedClicked() { Emit("LedClicked()"); } // *SIGNAL*
110
111 ClassDefOverride(TGSpeedo,0) // Base class for analog meter widget
112};
113
114#endif
Handle_t FontStruct_t
Pointer to font structure.
Definition GuiTypes.h:39
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
#define ClassDefOverride(name, id)
Definition Rtypes.h:348
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint angle
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition TGClient.cxx:380
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition TGFrame.h:80
TGClient * fClient
Connection to display server.
Definition TGObject.h:25
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition TGPicture.h:25
TGSpeedo is a widget looking like a speedometer, with a needle, a counter and a small odometer window...
Definition TGSpeedo.h:22
const TGPicture * fBase
picture used as background
Definition TGSpeedo.h:39
Int_t fBufferSize
circular buffer size
Definition TGSpeedo.h:57
void SetOdoValue(Int_t val)
Set actual value of odo meter.
Definition TGSpeedo.cxx:333
void ResetPeakVal()
Definition TGSpeedo.h:104
Float_t GetMean()
Compute and return the mean of the circular buffer content.
Definition TGSpeedo.cxx:230
Bool_t HandleButton(Event_t *event) override
Handle mouse button event.
Definition TGSpeedo.cxx:289
Float_t GetScaleMin() const
Definition TGSpeedo.h:80
void DisableMeanMark()
Definition TGSpeedo.h:103
void EnableThreshold()
Definition TGSpeedo.h:98
TString fLabel1
main label (first line)
Definition TGSpeedo.h:43
void StepScale(Float_t step)
Increment/decrement scale (needle position) of "step" value.
Definition TGSpeedo.cxx:483
FontStruct_t fTextFS
Definition TGSpeedo.h:40
EGlowColor fThresholdColor[3]
glowing threshold colors
Definition TGSpeedo.h:53
void SetDisplayText(const char *text1, const char *text2="")
Set small display text (two lines).
Definition TGSpeedo.cxx:346
Float_t fAngleMin
Definition TGSpeedo.h:50
TString fDisplay1
first line in the small display
Definition TGSpeedo.h:45
Float_t fScaleMin
Definition TGSpeedo.h:51
@ kOrange
Definition TGSpeedo.h:31
@ kNoglow
Definition TGSpeedo.h:25
~TGSpeedo() override
TGSpeedo widget Destructor.
Definition TGSpeedo.cxx:207
Float_t fAngle
Definition TGSpeedo.h:47
Bool_t IsThresholdActive()
Definition TGSpeedo.h:82
void Glow(EGlowColor col=kGreen)
Make speedo glowing.
Definition TGSpeedo.cxx:240
void SetMinMaxScale(Float_t min, Float_t max)
Set min and max scale values.
Definition TGSpeedo.cxx:376
Float_t fMeanVal
mean value mark
Definition TGSpeedo.h:49
const TGPicture * GetPicture() const
Definition TGSpeedo.h:76
TGSpeedo(const TGWindow *p=nullptr, int id=-1)
TGSpeedo widget constructor.
Definition TGSpeedo.cxx:46
Int_t fCounter
small odo meter (4 digits)
Definition TGSpeedo.h:41
TImage * fImage
image used as background
Definition TGSpeedo.h:37
Float_t GetPeakVal() const
Definition TGSpeedo.h:79
void OdoClicked()
Definition TGSpeedo.h:108
void DisableThreshold()
Definition TGSpeedo.h:99
void SetBufferSize(Int_t size)
Change the circular buffer size (used for the automatic mean calculation).
Definition TGSpeedo.cxx:321
FontStruct_t fCounterFS
font structures for text rendering
Definition TGSpeedo.h:40
void DrawText()
Draw text in speedo widget.
Definition TGSpeedo.cxx:553
void SetThresholds(Float_t th1=0.0, Float_t th2=0.0, Float_t th3=0.0)
Definition TGSpeedo.h:94
void SetThresholdColors(EGlowColor col1, EGlowColor col2, EGlowColor col3)
Definition TGSpeedo.h:96
TString fDisplay2
second line in the small display
Definition TGSpeedo.h:46
Int_t GetOdoVal() const
Definition TGSpeedo.h:78
Float_t fScaleMax
needle min and max scale
Definition TGSpeedo.h:51
Float_t fPeakVal
maximum peak mark
Definition TGSpeedo.h:48
Int_t fBufferCount
circular buffer count
Definition TGSpeedo.h:58
TString fPicName
name of picture used as background
Definition TGSpeedo.h:42
Bool_t fThresholdActive
kTRUE if glowing thresholds are active
Definition TGSpeedo.h:54
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:491
Float_t fThreshold[3]
glowing thresholds
Definition TGSpeedo.h:52
void SetLabelText(const char *text1, const char *text2="")
Set main label text (two lines).
Definition TGSpeedo.cxx:360
TImage * fImage2
intermediate image used as background
Definition TGSpeedo.h:38
void SetScaleValue(Float_t val)
Set actual scale (needle position) value.
Definition TGSpeedo.cxx:392
Bool_t fMeanMark
kTRUE if mean mark is active
Definition TGSpeedo.h:56
void EnableMeanMark()
Definition TGSpeedo.h:102
void SetMeanValue(Float_t mean)
Definition TGSpeedo.h:105
void EnablePeakMark()
Definition TGSpeedo.h:100
std::vector< Float_t > fBuffer
circular buffer for mean calculation
Definition TGSpeedo.h:59
Float_t GetScaleMax() const
Definition TGSpeedo.h:81
TString fLabel2
main label (second line)
Definition TGSpeedo.h:44
Float_t fAngleMax
needle min and max angle
Definition TGSpeedo.h:50
TGDimension GetDefaultSize() const override
Return default dimension of the widget.
Definition TGSpeedo.cxx:220
void DisablePeakMark()
Definition TGSpeedo.h:101
void LedClicked()
Definition TGSpeedo.h:109
TImage * GetImage() const
Definition TGSpeedo.h:77
void Build()
Build TGSpeedo widget.
Definition TGSpeedo.cxx:118
void DoRedraw() override
Redraw speedo widget.
Definition TGSpeedo.cxx:607
void DrawNeedle()
Draw needle in speedo widget.
Definition TGSpeedo.cxx:502
Bool_t fPeakMark
kTRUE if peak mark is active
Definition TGSpeedo.h:55
Float_t fValue
needle angle and corresponding value
Definition TGSpeedo.h:47
The widget base class.
Definition TGWidget.h:43
ROOT GUI Window base class.
Definition TGWindow.h:23
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:138
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:22
auto * th2
Definition textalign.C:18
auto * th1
Definition textalign.C:14