Logo ROOT   6.12/07
Reference Guide
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 
18 class MyTimer : public TTimer
19 {
20 private:
21  TGLAnnotation* m_label;
22 
23 public:
24  MyTimer(TGLAnnotation* x) : TTimer(1000), m_label(x)
25  {
26  }
27 
28  virtual Bool_t Notify()
29  {
30  // stop timer
31  TurnOff();
32 
33  // so some action here
34  TDatime d;
35  m_label->SetText(d.AsString());
37 
38  // start timer
39  SetTime(1000);
40  Reset();
41  TurnOn();
42  return true;
43  }
44 };
45 
46 void annotation(Float_t a=10, Float_t d=5, Float_t x=0, Float_t y=0, Float_t z=0)
47 {
49 
50  // add a box in scene
51  TEveBox* b = new TEveBox("Box", "Test Title");
52  b->SetMainColor(kCyan);
53  b->SetMainTransparency(0);
54  b->SetVertex(0, x - a, y - a, z - a);
55  b->SetVertex(1, x - a, y + a, z - a);
56  b->SetVertex(2, x + a, y + a, z - a);
57  b->SetVertex(3, x + a, y - a, z - a);
58  b->SetVertex(4, x - a, y - a, z + a);
59  b->SetVertex(5, x - a, y + a, z + a);
60  b->SetVertex(6, x + a, y + a, z + a);
61  b->SetVertex(7, x + a, y - a, z + a);
62  gEve->AddElement(b);
64 
65  // add overlay text
67  TDatime time;
68  TGLAnnotation* ann = new TGLAnnotation(v, time.AsString(), 0.1, 0.9);
69  ann->SetTextSize(0.1);// % of window diagonal
70 
71  // set timer to update text every second
72  MyTimer* timer = new MyTimer(ann);
73  timer->SetTime(1000);
74  timer->Reset();
75  timer->TurnOn();
76 }
void SetVertex(Int_t i, Float_t x, Float_t y, Float_t z)
Set vertex &#39;i&#39;.
Definition: TEveBox.cxx:48
void Reset()
Reset the timer.
Definition: TTimer.cxx:157
float Float_t
Definition: RtypesCore.h:53
GL-overlay annotation.
Definition: TGLAnnotation.h:25
3D box with arbitrary vertices (cuboid).
Definition: TEveBox.h:21
bool Bool_t
Definition: RtypesCore.h:59
void Redraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
Definition: TEveManager.h:168
void AddElement(TEveElement *element, TEveElement *parent=0)
Add an element.
Double_t x[n]
Definition: legend1.C:17
void SetTextSize(Float_t x)
Definition: TGLAnnotation.h:93
virtual void SetMainColor(Color_t color)
Set main color.
Definition: TEveShape.cxx:58
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
If global TEveManager* gEve is not set initialize it.
virtual Bool_t Notify()
Notify when timer times out.
Definition: TTimer.cxx:143
void RequestDraw(Short_t LOD=TGLRnrCtx::kLODMed)
Post request for redraw of viewer at level of detail &#39;LOD&#39; Request is directed via cross thread gVirt...
Definition: TGLViewer.cxx:440
SVector< double, 2 > v
Definition: Dict.h:5
auto * a
Definition: textangle.C:12
R__EXTERN TEveManager * gEve
Definition: TEveManager.h:243
void SetText(const TString &x)
Definition: TGLAnnotation.h:78
virtual void TurnOff()
Remove timer from system timer list.
Definition: TTimer.cxx:229
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:51
Base GL viewer object - used by both standalone and embedded (in pad) GL.
Definition: TGLViewer.h:53
TGLViewer * GetDefaultGLViewer() const
Get TGLViewer of the default TEveViewer.
virtual void SetMainTransparency(Char_t t)
Set main-transparency.
Double_t y[n]
Definition: legend1.C:17
const char * AsString() const
Return the date & time as a string (ctime() format).
Definition: TDatime.cxx:101
Definition: Rtypes.h:59
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
virtual void TurnOn()
Add the timer to the system timer list.
Definition: TTimer.cxx:241
const Bool_t kTRUE
Definition: RtypesCore.h:87
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition: TDatime.h:37
void SetTime(Long_t milliSec)
Definition: TTimer.h:90