Logo ROOT   6.14/05
Reference Guide
selection_sigs.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_eve
3 /// Test signals from TEveSelection class.
4 ///
5 /// \macro_code
6 ///
7 /// \author Matevz Tadel
8 
9 #include "TEveSelection.h" // To enforce auto-loading of libEve.
10 
11 class SigTestSpitter
12 {
13  TEveSelection *fSel;
14  TString fPrefix;
15 
16 public:
17  SigTestSpitter(TEveSelection* sel, const TString& prefix) :
18  fSel(sel), fPrefix(prefix)
19  {
20  fSel->Connect("SelectionAdded(TEveElement*)", "SigTestSpitter", this, "Added(TEveElement*)");
21  fSel->Connect("SelectionRemoved(TEveElement*)", "SigTestSpitter", this, "Removed(TEveElement*)");
22  fSel->Connect("SelectionCleared()", "SigTestSpitter", this, "Cleared()");
23  }
24  ~SigTestSpitter()
25  {
26  fSel->Disconnect("SelectionAdded(TEveElement*)", this, "Added(TEveElement*)");
27  fSel->Disconnect("SelectionRemoved(TEveElement*)", this, "Removed(TEveElement*)");
28  fSel->Disconnect("SelectionCleared()", this, "Cleared()");
29  }
30  // ----------------------------------------------------------------
31  void Added(TEveElement* el)
32  {
33  printf("%s Added 0x%lx '%s'\n", fPrefix.Data(), (ULong_t)el, el ? el->GetElementName() : "");
34  }
35  void Removed(TEveElement* el)
36  {
37  printf("%s Removed 0x%lx '%s'\n", fPrefix.Data(), (ULong_t)el, el ? el->GetElementName() : "");
38  }
39  void Cleared()
40  {
41  printf("%s Cleared'\n", fPrefix.Data());
42  }
43 };
44 
45 void selection_sigs()
46 {
48 
49  new SigTestSpitter(gEve->GetSelection(), "Selection");
50  new SigTestSpitter(gEve->GetHighlight(), "Highlight");
51 }
Basic string class.
Definition: TString.h:131
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
If global TEveManager* gEve is not set initialize it.
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot...
Definition: TQObject.cxx:867
R__EXTERN TEveManager * gEve
Definition: TEveManager.h:243
Make sure there is a SINGLE running TEveSelection for each selection type (select/highlight).
Definition: TEveSelection.h:21
virtual const char * GetElementName() const
Virtual function for retrieving name of the element.
TEveSelection * GetHighlight() const
Definition: TEveManager.h:130
unsigned long ULong_t
Definition: RtypesCore.h:51
TEveSelection * GetSelection() const
Definition: TEveManager.h:129
Bool_t Disconnect(const char *signal=0, void *receiver=0, const char *slot=0)
Disconnects signal of this object from slot of receiver.
Definition: TQObject.cxx:1025
Base class for TEveUtil visualization elements, providing hierarchy management, rendering control and...
Definition: TEveElement.h:33
const char * Data() const
Definition: TString.h:364