Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
iterplugin.cxx
Go to the documentation of this file.
1#include "TROOT.h"
2#include "TGeoNode.h"
3#include "TGeoVolume.h"
4#include "TGeoManager.h"
6
7////////////////////////////////////////////////////////////////////////////////
8
10public:
12 ~iterplugin() override {}
13 // Process current node
14 void ProcessNode() override;
15 void Select(Int_t replica, Int_t color)
16 {
17 fReplica = replica;
18 fColor = color;
19 }
20
21 Int_t fColor; // Current color
22 Int_t fReplica; // replica number (1 to 4)
23
24 ClassDefOverride(iterplugin, 0) // A simple user iterator plugin that changes volume color
25};
26
28{
29 if (!fIterator)
30 return;
31 TString path;
32 fIterator->GetPath(path);
33 if (!path.Contains(Form("REPLICA_%d", fReplica)))
34 return;
35 Int_t level = fIterator->GetLevel();
36 TGeoVolume *vol = fIterator->GetNode(level)->GetVolume();
37 vol->SetLineColor(fColor);
38}
@ kGreen
Definition Rtypes.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2489
const TGeoIterator * fIterator
Definition TGeoNode.h:226
Int_t GetLevel() const
Definition TGeoNode.h:294
void GetPath(TString &path) const
Returns the path for the current node.
TGeoNode * GetNode(Int_t level) const
Returns current node at a given level.
TGeoVolume * GetVolume() const
Definition TGeoNode.h:99
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition TGeoVolume.h:43
void SetLineColor(Color_t lcolor) override
Set the line color.
Basic string class.
Definition TString.h:139
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:632
~iterplugin() override
void ProcessNode() override
Int_t fReplica
void Select(Int_t replica, Int_t color)