Logo ROOT  
Reference Guide
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"
5 #include "TVirtualGeoPainter.h"
6 
7 ////////////////////////////////////////////////////////////////////////////////
8 
9 class iterplugin : public TGeoIteratorPlugin
10 {
11 public:
12  iterplugin() : TGeoIteratorPlugin(), fColor(kGreen), fReplica(1) {}
13  virtual ~iterplugin() {}
14  // Process current node
15  virtual void ProcessNode();
16  void Select(Int_t replica, Int_t color) {fReplica=replica; fColor=color;}
17 
18  Int_t fColor; // Current color
19  Int_t fReplica; // replica number (1 to 4)
20 
21  ClassDef(iterplugin, 0) // A simple user iterator plugin that changes volume color
22 };
23 
24 void iterplugin::ProcessNode()
25 {
26  if (!fIterator) return;
27  TString path;
28  fIterator->GetPath(path);
29  if (!path.Contains(Form("REPLICA_%d",fReplica))) return;
30  Int_t level = fIterator->GetLevel();
31  TGeoVolume *vol = fIterator->GetNode(level)->GetVolume();
32  vol->SetLineColor(fColor);
33 }
34 
kGreen
@ kGreen
Definition: Rtypes.h:66
Form
char * Form(const char *fmt,...)
TGeoNode::GetVolume
TGeoVolume * GetVolume() const
Definition: TGeoNode.h:97
Int_t
int Int_t
Definition: RtypesCore.h:45
TGeoVolume.h
TString::Contains
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:624
TString
Basic string class.
Definition: TString.h:136
TROOT.h
TGeoManager.h
TVirtualGeoPainter.h
TGeoVolume::GetNode
TGeoNode * GetNode(const char *name) const
get the pointer to a daughter node
Definition: TGeoVolume.cxx:2060
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TGeoVolume::SetLineColor
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TGeoVolume.cxx:2036
TGeoVolume
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition: TGeoVolume.h:49
TGeoNode.h
TGeoIteratorPlugin
Definition: TGeoNode.h:221
TGeoIteratorPlugin::ProcessNode
virtual void ProcessNode()=0