Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
annotation.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_eve
3/// Demonstrates usage of TGLAnnotation class.
4///
5/// \image html eve_annotation.png
6/// \macro_code
7///
8/// \author Alja Mrak-Tadel
9
10#include <TEveManager.h>
11#include <TGLViewer.h>
12#include <TGLAnnotation.h>
13#include <TEveBox.h>
14#include <TDatime.h>
15#include <TTimer.h>
16#include <TDatime.h>
17
18class MyTimer : public TTimer {
19private:
21
22public:
23 MyTimer(TGLAnnotation *x) : TTimer(1000), m_label(x) {}
24
25 Bool_t Notify() override
26 {
27 // stop timer
28 TurnOff();
29
30 // so some action here
31 TDatime d;
32 m_label->SetText(d.AsString());
34
35 // start timer
36 SetTime(1000);
37 Reset();
38 TurnOn();
39 return true;
40 }
41};
42
43void annotation(Float_t a = 10, Float_t d = 5, Float_t x = 0, Float_t y = 0, Float_t z = 0)
44{
46
47 // add a box in scene
48 auto b = new TEveBox("Box", "Test Title");
49 b->SetMainColor(kCyan);
50 b->SetMainTransparency(0);
51 b->SetVertex(0, x - a, y - a, z - a);
52 b->SetVertex(1, x - a, y + a, z - a);
53 b->SetVertex(2, x + a, y + a, z - a);
54 b->SetVertex(3, x + a, y - a, z - a);
55 b->SetVertex(4, x - a, y - a, z + a);
56 b->SetVertex(5, x - a, y + a, z + a);
57 b->SetVertex(6, x + a, y + a, z + a);
58 b->SetVertex(7, x + a, y - a, z + a);
61
62 // add overlay text
63 auto v = gEve->GetDefaultGLViewer();
64 TDatime time;
65 auto ann = new TGLAnnotation(v, time.AsString(), 0.1, 0.9);
66 ann->SetTextSize(0.1); // % of window diagonal
67
68 // set timer to update text every second
69 auto timer = new MyTimer(ann);
70 timer->SetTime(1000);
71 timer->Reset();
72 timer->TurnOn();
73}
#define d(i)
Definition RSha256.hxx:102
#define b(i)
Definition RSha256.hxx:100
#define a(i)
Definition RSha256.hxx:99
bool Bool_t
Definition RtypesCore.h:63
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
@ kCyan
Definition Rtypes.h:66
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TEveManager * gEve
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition TDatime.h:37
3D box with arbitrary vertices (cuboid).
Definition TEveBox.h:22
void AddElement(TEveElement *element, TEveElement *parent=nullptr)
Add an element.
TGLViewer * GetDefaultGLViewer() const
Get TGLViewer of the default TEveViewer.
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
If global TEveManager* gEve is not set initialize it.
void Redraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
GL-overlay annotation.
void RequestDraw(Short_t LOD=TGLRnrCtx::kLODMed)
Post request for redraw of viewer at level of detail 'LOD' Request is directed via cross thread gVirt...
Handles synchronous and a-synchronous timer events.
Definition TTimer.h:51
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17