Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
customContextMenu.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_gui
3/// Example showing how to add a function to the class context menu
4///
5/// \macro_code
6///
7/// \author Ilka Antcheva
8
9#include "TH1.h"
10#include "TClassMenuItem.h"
11#include "TList.h"
12
13void poptest1(int a=5, int b = 56);
14void poptest2(int a, int b, TObject* c);
15void poptest2bis(TObject* c);
16int poptest3();
17void poptest4(char* ch);
18
19
20void customContextMenu()
21{
22 TH1F *h;
23 TH1F *h2;
25 TList *l;
26
27 // Create test histograms
28 h = new TH1F("h","Schtroumpf",100,-4,4);
29 h->FillRandom("gaus");
30 h->Draw();
31
32 h2 = new TH1F("h2","h2",1000,-4,4);
33 h2->FillRandom("gaus",30000);
34
35 // Retrieve menu list from TClass
36 TClass *cl = h->IsA();
37 l = cl->GetMenuList();
38
39 // Add some items to the popup menus
41 "Test object, draw a second h","Draw",h2,"Option_t*");
42 l->AddFirst(n);
44 l->AddFirst(n);
45
47 "test no 4","poptest4",0,"const char*");
48 l->AddFirst(n);
50 "test no 3","poptest3",0,"");
51 l->AddFirst(n);
53 "test no 2 bis","poptest2bis",0,"TObject*",2);
54 l->AddFirst(n);
56 "test no 2","poptest2",0,"int,int,TObject*",2);
57 l->AddFirst(n);
59 "test no 1","poptest1",0,"int,int");
60 l->AddFirst(n);
61}
62
63void poptest1(int a, int b)
64{
65 printf("poptest1 %d %d\n",a,b);
66}
67
68void poptest2(int a, int b, TObject *c)
69{
70 // Remark: the object c will not be asked for since it is the selected object
71 printf("poptest2 %d %d\n",a,b);
72 printf("histo : %lx\n",(Long_t)c);
73 printf("title of the histogram : %s\n",((TH1F*)c)->GetTitle());
74}
75
76void poptest2bis(TObject *c)
77{
78 // Remark: the object c will not be asked for since it is the selected object
79 printf("poptest2bis\n");
80 printf("histo : %lx\n",(Long_t)c);
81 printf("title of the histogram : %s\n",((TH1F*)c)->GetTitle());
82}
83
84int poptest3()
85{
86 printf("poptest3\n");
87 return 12;
88}
89
90void poptest4(const char *ch)
91{
92 printf("poptest4 %s\n",ch);
93}
#define b(i)
Definition RSha256.hxx:100
#define c(i)
Definition RSha256.hxx:101
#define a(i)
Definition RSha256.hxx:99
#define h(i)
Definition RSha256.hxx:106
long Long_t
Definition RtypesCore.h:54
Describes one element of the context menu associated to a class The menu item may describe.
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:80
TList * GetMenuList() const
Return the list of menu items associated with the class.
Definition TClass.cxx:4327
1-D histogram with a float per channel (see TH1 documentation)}
Definition TH1.h:575
virtual void FillRandom(const char *fname, Int_t ntimes=5000, TRandom *rng=nullptr)
Fill histogram following distribution in function fname.
Definition TH1.cxx:3526
A doubly linked list.
Definition TList.h:38
Mother of all ROOT objects.
Definition TObject.h:41
const Int_t n
Definition legend1.C:16
auto * l
Definition textangle.C:4