Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGSpeedo.cxx
Go to the documentation of this file.
1// @(#)root/gui:$Id: TGSpeedo.cxx
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
13/** \class TGSpeedo
14 \ingroup guiwidgets
15
16TGSpeedo is a widget looking like a speedometer, with a needle,
17a counter and a small odometer window.
18
19Three thresholds are configurable, with their glowing color
20A peak mark can be enabled, allowing to keep track of the highest
21value displayed. The mark can be reset by right-clicking on the
22widget.
23
24Two signals are available:
25 - OdoClicked(): when user click on the small odometer window
26 - LedClicked(): when user click on the small led near the counter
27
28*/
29
30
31#include "TSystem.h"
32#include "TGResourcePool.h"
33#include "TImage.h"
34#include "TMath.h"
35#include "TVirtualX.h"
36#include "snprintf.h"
37
38#include "TGSpeedo.h"
39#include <numeric>
40
41
42
43////////////////////////////////////////////////////////////////////////////////
44/// TGSpeedo widget constructor.
45
47 : TGFrame(p, 1, 1), TGWidget (id), fImage(0), fImage2(0), fBase(0)
48{
49 fAngleMin = -133.5;
50 fAngleMax = 133.5;
51 fAngle = -133.5;
52 fScaleMin = 0.0;
53 fScaleMax = 100.0;
54 fValue = 0.0;
55 fCounter = 0;
58 fPeakVal = 0.0;
59 fMeanVal = 0.0;
61 fThreshold[0] = fThreshold[1] = fThreshold[2] = 0.0;
66 fPicName = "speedo.gif";
68 if (!fImage || !fImage->IsValid())
69 Error("TGSpeedo::Build", "%s not found", fPicName.Data());
70 fBufferCount = 0;
71 fBufferSize = 0;
72 Build();
74}
75
76////////////////////////////////////////////////////////////////////////////////
77/// TGSpeedo widget constructor.
78
80 const char *lbl1, const char *lbl2, const char *dsp1,
81 const char *dsp2, int id)
82 : TGFrame(p, 1, 1), TGWidget (id), fImage(0), fImage2(0), fBase(0)
83{
84 fAngleMin = -133.5;
85 fAngleMax = 133.5;
86 fAngle = -133.5;
89 fValue = smin;
90 fCounter = 0;
91 fLabel1 = lbl1;
92 fLabel2 = lbl2;
97 fPeakVal = 0.0;
98 fMeanVal = 0.0;
100 fThreshold[0] = fThreshold[1] = fThreshold[2] = 0.0;
105 fPicName = "speedo.gif";
107 if (!fImage || !fImage->IsValid())
108 Error("TGSpeedo::Build", "%s not found", fPicName.Data());
109 fBufferCount = 0;
110 fBufferSize = 0;
111 Build();
113}
114
115////////////////////////////////////////////////////////////////////////////////
116/// Build TGSpeedo widget.
117
119{
120 TString sc;
121 Float_t step, mark[5];
122 TString ar = "arialbd.ttf";
123 Int_t i, nexe, offset;
124
125 const TGFont *counterFont = fClient->GetFont("-*-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*");
126 if (!counterFont) return;
127 fCounterFS = counterFont->GetFontStruct();
128
129 const TGFont *textFont = fClient->GetFont("-*-helvetica-bold-r-*-*-8-*-*-*-*-*-*-*");
130 if (!textFont) return;
131 fTextFS = textFont->GetFontStruct();
132
133 const TGFont *labelFont = fClient->GetFont("-*-helvetica-bold-r-*-*-14-*-*-*-*-*-*-*");
134 if (!labelFont) return;
135 FontStruct_t labelFS = labelFont->GetFontStruct();
136
137 if (fImage && fImage->IsValid()) {
140 // center of the image
141 Float_t xc = (Float_t)(fBase ? (fBase->GetWidth() + 1) / 2 : 96.0);
142 Float_t yc = (Float_t)(fBase ? (fBase->GetHeight() + 1) / 2 : 96.0);
143
144 // compute scale ticks steps
145 step = (fScaleMax - fScaleMin) / 4.0;
146 mark[0] = fScaleMin;
147 mark[4] = fScaleMax;
148 for (i=1; i<4; i++) {
149 mark[i] = mark[i-1] + step;
150 }
151 // format tick labels
152 if (fScaleMax >= 1000.0) {
153 nexe = 0;
154 while (1) {
155 nexe++;
156 for (i=0; i<5; i++) {
157 mark[i] /= 10.0;
158 }
159 // coverity[loop_condition]: ignore - false positive
160 if (mark[4] < 1000.0) break;
161 }
162 // draw multiplier
163 fImage->DrawText((Int_t)xc - 11, (Int_t)yc + 15, "x10", 12, "#ffffff", ar);
164 sc.Form("%d", nexe);
165 fImage->DrawText((Int_t)xc + 11, (Int_t)yc + 13, sc.Data(), 10, "#ffffff", ar);
166 }
167 else if (fScaleMax < 100.0) {
168 nexe = 0;
169 while (1) {
170 nexe--;
171 for (i=0; i<5; i++) {
172 mark[i] *= 10.0;
173 }
174 // coverity[loop_condition]: ignore - false positive
175 if (mark[4] > 99.9 ) break;
176 }
177 // draw multiplier
178 fImage->DrawText((Int_t)xc - 11, (Int_t)yc + 15, "x10", 12, "#ffffff", ar);
179 sc.Form("%d", nexe);
180 fImage->DrawText((Int_t)xc + 11, (Int_t)yc + 13, sc.Data(), 10, "#ffffff", ar);
181 }
182 // Format and draw scale tickmarks
183 sc.Form("%d",(Int_t)mark[0]);
184 fImage->DrawText((Int_t)xc - 51, (Int_t)yc + 30, sc.Data(), 14, "#ffffff", ar);
185 sc.Form("%d",(Int_t)mark[1]);
186 fImage->DrawText((Int_t)xc - 59, (Int_t)yc - 29, sc.Data(), 14, "#ffffff", ar);
187 sc.Form("%d",(Int_t)mark[2]);
188 offset = gVirtualX->TextWidth(labelFS, sc.Data(), sc.Length()) / 2;
189 fImage->DrawText((Int_t)xc - offset, (Int_t)yc - 65, sc.Data(), 14, "#ffffff", ar);
190 sc.Form("%d",(Int_t)mark[3]);
191 offset = 60 - gVirtualX->TextWidth(labelFS, sc.Data(), sc.Length());
192 fImage->DrawText((Int_t)xc + offset, (Int_t)yc - 29, sc.Data(), 14, "#ffffff", ar);
193 sc.Form("%d",(Int_t)mark[4]);
194 offset = 52 - gVirtualX->TextWidth(labelFS, sc.Data(), sc.Length());
195 fImage->DrawText((Int_t)xc + offset, (Int_t)yc + 30, sc.Data(), 14, "#ffffff", ar);
196 // draw main label (two lines)
197 fImage->DrawText((Int_t)xc + 13, (Int_t)yc - 17, fLabel1.Data(), 14, "#ffffff", ar);
198 fImage->DrawText((Int_t)xc + 13, (Int_t)yc - 4, fLabel2.Data(), 12, "#ffffff", ar);
199 if (fBase)
200 gVirtualX->ShapeCombineMask(fId, 0, 0, fBase->GetMask());
201 }
202}
203
204////////////////////////////////////////////////////////////////////////////////
205/// TGSpeedo widget Destructor.
206
208{
209 if (fImage && fImage->IsValid())
210 delete fImage;
211 if (fImage2 && fImage2->IsValid())
212 delete fImage2;
213 if (fBase)
215}
216
217////////////////////////////////////////////////////////////////////////////////
218/// Return default dimension of the widget.
219
221{
222 if (fBase)
223 return TGDimension(fBase->GetWidth(), fBase->GetHeight());
224 return TGDimension(100, 100);
225}
226
227////////////////////////////////////////////////////////////////////////////////
228/// Compute and return the mean of the circular buffer content.
229
231{
232 if ((fBufferSize == 0) || (fBuffer.size() == 0))
233 return fMeanVal;
234 return std::accumulate(fBuffer.begin(), fBuffer.end(), 0.0f) / fBuffer.size();
235}
236
237////////////////////////////////////////////////////////////////////////////////
238/// Make speedo glowing.
239
241{
242 static EGlowColor act_col = kNoglow;
243 TImage *glowImage = 0;
244
245 if (col == act_col)
246 return;
247
248 if (fImage && fImage->IsValid())
249 delete fImage;
250
251 switch (col) {
252 case kNoglow:
253 break;
254 case kGreen:
255 glowImage = TImage::Open("glow_green.png");
256 if (!glowImage || !glowImage->IsValid()) {
257 Error("TGSpeedo::Glow", "glow_green.png not found");
258 glowImage = 0;
259 }
260 break;
261 case kOrange:
262 glowImage = TImage::Open("glow_orange.png");
263 if (!glowImage || !glowImage->IsValid()) {
264 Error("TGSpeedo::Glow", "glow_orange.png not found");
265 glowImage = 0;
266 }
267 break;
268 case kRed:
269 glowImage = TImage::Open("glow_red.png");
270 if (!glowImage || !glowImage->IsValid()) {
271 Error("TGSpeedo::Glow", "glow_red.png not found");
272 glowImage = 0;
273 }
274 break;
275 }
277 if (fImage && fImage->IsValid() && glowImage && glowImage->IsValid()) {
279 delete glowImage;
280 }
281 act_col = col;
282 Build();
283 DrawText();
284}
285
286////////////////////////////////////////////////////////////////////////////////
287/// Handle mouse button event.
288
290{
291 if (fBase) {
292 int xc = (fBase->GetWidth() + 1) / 2;
293 int yc = (fBase->GetHeight() + 1) / 2;
294 if (event->fType == kButtonRelease && event->fCode == kButton1) {
295 // check if in the selector area
296 if ((event->fX > (xc - 26)) && (event->fX < (xc + 26)) &&
297 (event->fY < (yc + 50)) && (event->fY > (yc + 28))) {
298 OdoClicked();
299 }
300 // check if in the led area
301 else if ((event->fX > (xc + 30)) && (event->fX < (xc + 40)) &&
302 (event->fY > (yc + 57)) && (event->fY < (yc + 67))) {
303 LedClicked();
304 }
305 }
306 if (event->fType == kButtonRelease && event->fCode == kButton3) {
307 ResetPeakVal();
308 }
309 }
310 return kTRUE;
311}
312
313////////////////////////////////////////////////////////////////////////////////
314/// Change the circular buffer size (used for the automatic mean calculation).
315/// SetMeanValue is ignored if SetBufferSize is called with a greater-than-zero
316/// argument. The mean value is then automatically calculated by using the sum
317/// of values contained in the buffer divided by their count.
318/// To disable automatic mean calculation, simply call SetBufferSize with a zero
319/// argument
320
322{
323 if (size < 0) size = 0;
325 fBuffer.clear();
326 fBuffer.reserve(fBufferSize);
327 fBufferCount = 0;
328}
329
330////////////////////////////////////////////////////////////////////////////////
331/// Set actual value of odo meter.
332
334{
335 // avoid useless redraw
336 if (val == fCounter)
337 return;
338 fCounter = val;
339 DrawText();
340 DrawNeedle();
341}
342
343////////////////////////////////////////////////////////////////////////////////
344/// Set small display text (two lines).
345
346void TGSpeedo::SetDisplayText(const char *text1, const char *text2)
347{
348 if (!(fDisplay1.CompareTo(text1)) &&
350 return;
353 DrawText();
354 DrawNeedle();
355}
356
357////////////////////////////////////////////////////////////////////////////////
358/// Set main label text (two lines).
359
360void TGSpeedo::SetLabelText(const char *text1, const char *text2)
361{
362 if (fImage && fImage->IsValid())
363 delete fImage;
364 fLabel1 = text1;
365 fLabel2 = text2;
367 if (!fImage || !fImage->IsValid())
368 Error("TGSpeedo::Build", "%s not found", fPicName.Data());
369 Build();
370 DrawText();
371}
372
373////////////////////////////////////////////////////////////////////////////////
374/// Set min and max scale values.
375
377{
378 if (fImage && fImage->IsValid())
379 delete fImage;
380 fScaleMin = min;
381 fScaleMax = max;
383 if (!fImage || !fImage->IsValid())
384 Error("TGSpeedo::Build", "%s not found", fPicName.Data());
385 Build();
386 DrawText();
387}
388
389////////////////////////////////////////////////////////////////////////////////
390/// Set actual scale (needle position) value.
391
393{
394 // avoid useless redraw
395 if (val == fValue)
396 return;
397
398 fValue = val;
399 if (fValue > fScaleMax)
401 else if (fValue < fScaleMin)
403
404 if (fThresholdActive) {
405 if (fValue < fThreshold[0])
406 Glow(kNoglow);
407 if (fValue >= fThreshold[0] && fValue < fThreshold[1])
409 if (fValue >= fThreshold[1] && fValue < fThreshold[2])
411 if (fValue >= fThreshold[2])
413 }
414 if (fValue > fPeakVal)
416
417 if (fBufferSize > 0) {
418 if ((Int_t)fBuffer.size() < (fBufferCount + 1))
419 fBuffer.push_back(fValue);
420 else
422 ++fBufferCount;
424 fBufferCount = 0;
425 }
426
428 (fAngleMax - fAngleMin)));
429
430 if (fAngle > fAngleMax)
432 else if (fAngle < fAngleMin)
434 DrawNeedle();
435}
436
437////////////////////////////////////////////////////////////////////////////////
438/// Set actual scale (needle position) value.
439
441{
442 Float_t i;
444 Float_t step, new_val = val;
445 // avoid useless redraw
446 if (val == fValue)
447 return;
448
449 if ((damping > 0) || (gVirtualX->InheritsFrom("TGX11")))
450 step = 2.0;
451 else
452 step = 0.15;
453
459
460 if (new_angle > old_angle) {
461 for (i=old_angle; i<new_angle; i+=step) {
462 new_val = (i - fAngleMin) * diff_ratio;
464 if (damping > 0)
466 }
467 }
468 if (new_angle < old_angle) {
469 for (i=old_angle; i>new_angle; i-=step) {
470 new_val = (i - fAngleMin) * diff_ratio;
472 if (damping > 0)
474 }
475 }
476 // Last step
477 SetScaleValue(val);
478}
479
480////////////////////////////////////////////////////////////////////////////////
481/// Increment/decrement scale (needle position) of "step" value.
482
484{
485 SetScaleValue(fValue + step);
486}
487
488////////////////////////////////////////////////////////////////////////////////
489/// Translate distance from center and angle to xy coordinates.
490
492{
493 Float_t xc = (Float_t)(fBase ? (fBase->GetWidth() + 1) / 2 : 96.0);
494 Float_t yc = (Float_t)(fBase ? (fBase->GetHeight() + 1) / 2 : 96.0);
495 *x = (Int_t)(xc + val * sin(angle * TMath::Pi() / 180) + 0.5);
496 *y = (Int_t)(yc - val * cos(angle * TMath::Pi() / 180) + 0.5);
497}
498
499////////////////////////////////////////////////////////////////////////////////
500/// Draw needle in speedo widget.
501
503{
508 (fAngleMax - fAngleMin));
509
510 // compute x/y position of the needle
511 Translate(9.0, fAngle, &xch0, &ych0);
512 Translate(73.0, fAngle, &xch1, &ych1);
513
514 // compute x/y position of the peak mark
516 (fAngleMax - fAngleMin)));
517 Translate(80.0, angle, &xpk0, &ypk0);
518 Translate(67.0, angle, &xpk1, &ypk1);
519
520 fMeanVal = GetMean();
521
522 // compute x/y position of the mean mark
524 (fAngleMax - fAngleMin)));
525 Translate(80.0, angle, &xmn0, &ymn0);
526 Translate(70.0, angle, &xmn1, &ymn1);
527
528 if (fImage2 && fImage2->IsValid()) {
529 // First clone original image.
530 TImage *img = (TImage*)fImage2->Clone("img");
531 if (!img || !img->IsValid()) return;
532 if (fPeakMark) {
533 img->DrawLine(xpk0, ypk0, xpk1, ypk1, "#00ff00", 3);
534 img->DrawLine(xpk0, ypk0, xpk1, ypk1, "#ffffff", 1);
535 }
536 if (fMeanMark) {
537 img->DrawLine(xmn0, ymn0, xmn1, ymn1, "#ffff00", 3);
538 img->DrawLine(xmn0, ymn0, xmn1, ymn1, "#ff0000", 1);
539 }
540 // draw line (used to render the needle) directly on the image
541 img->DrawLine(xch0, ych0, xch1, ych1, "#ff0000", 2);
542 // finally paint image to the widget
543 img->PaintImage(fId, 0, 0, 0, 0, 0, 0, "opaque");
544 // and finally, to avoid memory leaks
545 delete img;
546 }
547 gVirtualX->Update();
548}
549
550////////////////////////////////////////////////////////////////////////////////
551/// Draw text in speedo widget.
552
554{
555 char sval[80];
556 char dsval[80];
558
559 // center of the image
560 Float_t xc = fBase ? (fBase->GetWidth() + 1) / 2 : 96.0;
561 Float_t yc = fBase ? (fBase->GetHeight() + 1) / 2 : 96.0;
562
563 if (fImage && fImage->IsValid()) {
564 // First clone original image.
565 if (fImage2 && fImage2->IsValid())
566 delete fImage2;
567 fImage2 = (TImage*)fImage->Clone("fImage2");
568 if (!fImage2 || !fImage2->IsValid()) return;
569 TString ar = "arialbd.ttf";
570 // format counter value
571 Int_t nexe = 0;
572 Int_t ww = fCounter;
573 if (fCounter >= 10000) {
574 while (1) {
575 nexe++;
576 ww /= 10;
577 if (nexe%3 == 0 && ww < 10000) break;
578 }
579 fImage2->DrawText((Int_t)xc - 9, (Int_t)yc + 72, "x10", 10, "#ffffff", ar);
580 snprintf(sval, 80, "%d", nexe);
581 fImage2->DrawText((Int_t)xc + 9, (Int_t)yc + 69, sval, 8, "#ffffff", ar);
582 }
583 snprintf(sval, 80, "%04d", (int)ww);
584 snprintf(dsval, 80, "%c %c %c %c", sval[0], sval[1], sval[2], sval[3]);
585 // draw text in the counter
586 if (gVirtualX->InheritsFrom("TGX11")) {
587 // as there is a small difference between Windows and Linux...
588 fImage2->DrawText((Int_t)xc - 18, (Int_t)yc + 55, dsval, 12, "#ffffff", ar);
589 }
590 else {
591 fImage2->DrawText((Int_t)xc - 16, (Int_t)yc + 56, dsval, 12, "#ffffff", ar);
592 }
593 // compute the size of the string to draw in the small display box
594 // first line
595 strSize = gVirtualX->TextWidth(fTextFS, fDisplay1.Data(), fDisplay1.Length()) - 6;
596 // draw text directly on the imaget_t)yc + 29, fDispla
597 fImage2->DrawText((Int_t)xc - (strSize / 2), (Int_t)yc + 29, fDisplay1.Data(), 8, "#ffffff", ar);
598 // second line
599 strSize = gVirtualX->TextWidth(fTextFS, fDisplay2.Data(), fDisplay2.Length()) - 6;
600 fImage2->DrawText((Int_t)xc - (strSize / 2), (Int_t)yc + 38, fDisplay2.Data(), 8, "#ffffff", ar);
601 }
602}
603
604////////////////////////////////////////////////////////////////////////////////
605/// Redraw speedo widget.
606
608{
609 char sval[80];
610 char dsval[80];
615 static Bool_t first = kTRUE;
616 if (first) {
618 first = kFALSE;
619 }
621 (fAngleMax - fAngleMin));
622
623 // center of the image
624 Float_t xc = fBase ? (fBase->GetWidth() + 1) / 2 : 96.0;
625 Float_t yc = fBase ? (fBase->GetHeight() + 1) / 2 : 96.0;
626
627 // compute x/y position of the needle
628 Translate(9.0, fAngle, &xch0, &ych0);
629 Translate(73.0, fAngle, &xch1, &ych1);
630
631 // compute x/y position of the peak mark
633 (fAngleMax - fAngleMin)));
634 Translate(80.0, angle, &xpk0, &ypk0);
635 Translate(67.0, angle, &xpk1, &ypk1);
636
637 // compute x/y position of the peak mark
639 (fAngleMax - fAngleMin)));
640 Translate(80.0, angle, &xmn0, &ymn0);
641 Translate(70.0, angle, &xmn1, &ymn1);
642
643 if (fImage && fImage->IsValid()) {
644 // First clone original image.
645 if (fImage2 && fImage2->IsValid())
646 delete fImage2;
647 fImage2 = (TImage*)fImage->Clone("fImage2");
648 if (!fImage2 || !fImage2->IsValid()) return;
649 TString ar = "arialbd.ttf";
650 // format counter value
651 Int_t nexe = 0;
652 Int_t ww = fCounter;
653 if (fCounter >= 10000) {
654 while (1) {
655 nexe++;
656 ww /= 10;
657 if (nexe%3 == 0 && ww < 10000) break;
658 }
659 fImage2->DrawText((Int_t)xc - 9, (Int_t)yc + 72, "x10", 10, "#ffffff", ar);
660 snprintf(sval, 80, "%d", nexe);
661 fImage2->DrawText((Int_t)xc + 9, (Int_t)yc + 69, sval, 8, "#ffffff", ar);
662 }
663 snprintf(sval, 80, "%04d", (int)ww);
664 snprintf(dsval, 80, "%c %c %c %c", sval[0], sval[1], sval[2], sval[3]);
665 // draw text in the counter
666 if (gVirtualX->InheritsFrom("TGX11")) {
667 // as there is a small difference between Windows and Linux...
668 fImage2->DrawText((Int_t)xc - 18, (Int_t)yc + 55, dsval, 12, "#ffffff", ar);
669 }
670 else {
671 fImage2->DrawText((Int_t)xc - 16, (Int_t)yc + 56, dsval, 12, "#ffffff", ar);
672 }
673 // compute the size of the string to draw in the small display box
674 // first line
675 strSize = gVirtualX->TextWidth(fTextFS, fDisplay1.Data(), fDisplay1.Length()) - 6;
676 // draw text directly on the imaget_t)yc + 29, fDispla
677 fImage2->DrawText((Int_t)xc - (strSize / 2), (Int_t)yc + 29, fDisplay1.Data(), 8, "#ffffff", ar);
678 // second line
679 strSize = gVirtualX->TextWidth(fTextFS, fDisplay2.Data(), fDisplay2.Length()) - 6;
680 fImage2->DrawText((Int_t)xc - (strSize / 2), (Int_t)yc + 38, fDisplay2.Data(), 8, "#ffffff", ar);
681 TImage *img = (TImage*)fImage2->Clone("img");
682 if (!img || !img->IsValid()) return;
683 if (fPeakMark) {
684 img->DrawLine(xpk0, ypk0, xpk1, ypk1, "#00ff00", 3);
685 img->DrawLine(xpk0, ypk0, xpk1, ypk1, "#ffffff", 1);
686 }
687 if (fMeanMark) {
688 img->DrawLine(xmn0, ymn0, xmn1, ymn1, "#ffff00", 3);
689 img->DrawLine(xmn0, ymn0, xmn1, ymn1, "#ff0000", 1);
690 }
691 // draw line (used to render the needle) directly on the image
692 img->DrawLine(xch0, ych0, xch1, ych1, "#ff0000", 2);
693 // finally paint image to the widget
694 img->PaintImage(fId, 0, 0, 0, 0, 0, 0, "opaque");
695 // and finally, to avoid memory leaks
696 delete img;
697 }
698}
@ kButtonRelease
Definition GuiTypes.h:60
const Mask_t kButtonPressMask
Definition GuiTypes.h:161
const Handle_t kNone
Definition GuiTypes.h:88
const Mask_t kButtonReleaseMask
Definition GuiTypes.h:162
@ kButton3
Definition GuiTypes.h:214
@ kButton1
Definition GuiTypes.h:214
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
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 const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint angle
R__EXTERN TSystem * gSystem
Definition TSystem.h:572
#define gVirtualX
Definition TVirtualX.h:337
#define snprintf
Definition civetweb.c:1579
TGFont * GetFont(const char *font, Bool_t fixedDefault=kTRUE)
Get a font from the font pool.
Definition TGClient.cxx:356
TGPicturePool * GetPicturePool() const
Definition TGClient.h:126
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition TGClient.cxx:316
Encapsulate fonts used in the GUI system.
Definition TGFont.h:140
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition TGFrame.h:80
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition TGFrame.cxx:331
void DoRedraw() override
Redraw the frame.
Definition TGFrame.cxx:422
TGClient * fClient
Connection to display server.
Definition TGObject.h:25
Handle_t fId
X11/Win32 Window identifier.
Definition TGObject.h:24
const TGPicture * GetPicture(const char *name)
Get a picture from the picture pool.
Definition TGPicture.cxx:80
const TGPicture * fBase
picture used as background
Definition TGSpeedo.h:30
Int_t fBufferSize
circular buffer size
Definition TGSpeedo.h:48
void SetOdoValue(Int_t val)
Set actual value of odo meter.
Definition TGSpeedo.cxx:333
void ResetPeakVal()
Definition TGSpeedo.h:95
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
TString fLabel1
main label (first line)
Definition TGSpeedo.h:34
void StepScale(Float_t step)
Increment/decrement scale (needle position) of "step" value.
Definition TGSpeedo.cxx:483
FontStruct_t fTextFS
Definition TGSpeedo.h:31
EGlowColor fThresholdColor[3]
glowing threshold colors
Definition TGSpeedo.h:44
void SetDisplayText(const char *text1, const char *text2="")
Set small display text (two lines).
Definition TGSpeedo.cxx:346
Float_t fAngleMin
Definition TGSpeedo.h:41
TString fDisplay1
first line in the small display
Definition TGSpeedo.h:36
Float_t fScaleMin
Definition TGSpeedo.h:42
@ kOrange
Definition TGSpeedo.h:25
@ kNoglow
Definition TGSpeedo.h:25
~TGSpeedo() override
TGSpeedo widget Destructor.
Definition TGSpeedo.cxx:207
Float_t fAngle
Definition TGSpeedo.h:38
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:40
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:32
TImage * fImage
image used as background
Definition TGSpeedo.h:28
void OdoClicked()
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:31
void DrawText()
Draw text in speedo widget.
Definition TGSpeedo.cxx:553
TString fDisplay2
second line in the small display
Definition TGSpeedo.h:37
Float_t fScaleMax
needle min and max scale
Definition TGSpeedo.h:42
Float_t fPeakVal
maximum peak mark
Definition TGSpeedo.h:39
Int_t fBufferCount
circular buffer count
Definition TGSpeedo.h:49
TString fPicName
name of picture used as background
Definition TGSpeedo.h:33
Bool_t fThresholdActive
kTRUE if glowing thresholds are active
Definition TGSpeedo.h:45
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:43
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:29
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:47
std::vector< Float_t > fBuffer
circular buffer for mean calculation
Definition TGSpeedo.h:50
TString fLabel2
main label (second line)
Definition TGSpeedo.h:35
Float_t fAngleMax
needle min and max angle
Definition TGSpeedo.h:41
TGDimension GetDefaultSize() const override
Return default dimension of the widget.
Definition TGSpeedo.cxx:220
void LedClicked()
Definition TGSpeedo.h:100
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:46
Float_t fValue
needle angle and corresponding value
Definition TGSpeedo.h:38
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
static TImage * Open(const char *file, EImageFileTypes type=kUnknown)
Open a specified image file.
Definition TImage.cxx:117
virtual void DrawText(Int_t=0, Int_t=0, const char *="", Int_t=12, const char *=nullptr, const char *="fixed", EText3DType=TImage::kPlain, const char *=nullptr, Float_t=0)
Definition TImage.h:200
virtual Bool_t IsValid() const
Definition TImage.h:230
virtual void Merge(const TImage *, const char *="alphablend", Int_t=0, Int_t=0)
Definition TImage.h:172
virtual Pixmap_t GetPixmap()
Definition TImage.h:235
TObject * Clone(const char *) const override
Make a clone of an object using the Streamer facility.
Definition TImage.h:111
virtual Pixmap_t GetMask()
Definition TImage.h:236
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1071
Basic string class.
Definition TString.h:138
Ssiz_t Length() const
Definition TString.h:425
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
Definition TString.cxx:464
const char * Data() const
Definition TString.h:384
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
Definition TSystem.cxx:944
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
Definition TSystem.cxx:435
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
constexpr Double_t Pi()
Definition TMath.h:40
Event structure.
Definition GuiTypes.h:174
EGEventType fType
of event (see EGEventType)
Definition GuiTypes.h:175
Int_t fY
pointer x, y coordinates in event window
Definition GuiTypes.h:178
Int_t fX
Definition GuiTypes.h:178
UInt_t fCode
key or button code
Definition GuiTypes.h:180