Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
annotation.C File Reference

Detailed Description

Demonstrates usage of TGLAnnotation class.

#include <TEveManager.h>
#include <TGLViewer.h>
#include <TGLAnnotation.h>
#include <TEveBox.h>
#include <TDatime.h>
#include <TTimer.h>
#include <TDatime.h>
class MyTimer : public TTimer
{
private:
TGLAnnotation* m_label;
public:
MyTimer(TGLAnnotation* x) : TTimer(1000), m_label(x)
{
}
virtual Bool_t Notify()
{
// stop timer
// so some action here
m_label->SetText(d.AsString());
// start timer
SetTime(1000);
Reset();
TurnOn();
return true;
}
};
void annotation(Float_t a=10, Float_t d=5, Float_t x=0, Float_t y=0, Float_t z=0)
{
// add a box in scene
auto b = new TEveBox("Box", "Test Title");
b->SetMainColor(kCyan);
b->SetMainTransparency(0);
b->SetVertex(0, x - a, y - a, z - a);
b->SetVertex(1, x - a, y + a, z - a);
b->SetVertex(2, x + a, y + a, z - a);
b->SetVertex(3, x + a, y - a, z - a);
b->SetVertex(4, x - a, y - a, z + a);
b->SetVertex(5, x - a, y + a, z + a);
b->SetVertex(6, x + a, y + a, z + a);
b->SetVertex(7, x + a, y - a, z + a);
// add overlay text
TDatime time;
auto ann = new TGLAnnotation(v, time.AsString(), 0.1, 0.9);
ann->SetTextSize(0.1);// % of window diagonal
// set timer to update text every second
auto timer = new MyTimer(ann);
timer->SetTime(1000);
timer->Reset();
timer->TurnOn();
}
#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
const Bool_t kTRUE
Definition RtypesCore.h:100
@ kCyan
Definition Rtypes.h:66
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
const char * AsString() const
Return the date & time as a string (ctime() format).
Definition TDatime.cxx:102
3D box with arbitrary vertices (cuboid).
Definition TEveBox.h:22
void AddElement(TEveElement *element, TEveElement *parent=0)
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 SetText(const TString &x)
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
virtual void TurnOff()
Remove timer from system timer list.
Definition TTimer.cxx:229
virtual void TurnOn()
Add the timer to the system timer list.
Definition TTimer.cxx:241
void Reset()
Reset the timer.
Definition TTimer.cxx:157
void SetTime(Long_t milliSec)
Definition TTimer.h:91
virtual Bool_t Notify()
Notify when timer times out.
Definition TTimer.cxx:143
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Author
Alja Mrak-Tadel

Definition in file annotation.C.