Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches

Detailed Description

Simple TStructViewer tutorial.

#include "TRandom.h"
#include "TList.h"
#include "TROOT.h"
#include "TStructViewer.h"
const Int_t ncl = 12;
const char *clnames[ncl] = {"TH1F", "TGraph", "TGraphErrors", "TF1", "TPaveText", "TAxis",
"TF2", "TH2D", "TLatex", "TText", "TCutG", "THnSparseF"};
// Function creating elements of lists
{
for (Int_t i = 0; i < nobj; i++) {
if (maxDepth && gRandom->Rndm() < pList) {
TList *slist = new TList();
slist->SetName(Form("list_%d_%d", maxDepth, i));
list->Add(slist);
} else {
TNamed *named = (TNamed *)gROOT->ProcessLine(Form("new %s;", clnames[icl]));
named->SetName(Form("%s_%d_%d", clnames[icl], maxDepth, i));
list->Add(named);
}
}
}
// function creating a hierarchy of objects to test the TStructViewer
{
TList *list = new TList();
list->SetName("SuperList");
gROOT->GetListOfTasks()->Add(list);
return list;
}
// function adding colors to viewer
{
for (int i = 0; i < ncl; i++)
sv->SetColor(clnames[i], (Int_t)gRandom->Integer(8) + 2);
}
void gviz3d()
{
// Creating a pointer to list
TList *pointer = crazy(2, 10);
// Creating a viewer
TStructViewer *sv = new TStructViewer(pointer);
// adding colors
sv->Draw();
}
int Int_t
Definition RtypesCore.h:45
float Float_t
Definition RtypesCore.h:57
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define gROOT
Definition TROOT.h:406
R__EXTERN TRandom * gRandom
Definition TRandom.h:62
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2489
A doubly linked list.
Definition TList.h:38
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
Double_t Rndm() override
Machine independent random number generator.
Definition TRandom.cxx:559
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
Definition TRandom.cxx:682
virtual UInt_t Integer(UInt_t imax)
Returns a random integer uniformly distributed on the interval [ 0, imax-1 ].
Definition TRandom.cxx:361
Author
Timur Pocheptsov

Definition in file gviz3d.C.