Logo ROOT   6.08/07
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 ClassImp(iterplugin)
25 
26 void iterplugin::ProcessNode()
27 {
28  if (!fIterator) return;
29  TString path;
30  fIterator->GetPath(path);
31  if (!path.Contains(Form("REPLICA_%d",fReplica))) return;
32  Int_t level = fIterator->GetLevel();
33  TGeoVolume *vol = fIterator->GetNode(level)->GetVolume();
34  vol->SetLineColor(fColor);
35 }
36 
void GetPath(TString &path) const
Returns the path for the current node.
Definition: TGeoNode.cxx:1183
virtual void ProcessNode()=0
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition: TGeoVolume.h:61
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
TGeoNode * GetNode(Int_t level) const
Returns current node at a given level.
Definition: TGeoNode.cxx:1172
Definition: Rtypes.h:61
#define ClassDef(name, id)
Definition: Rtypes.h:254
Int_t GetLevel() const
Definition: TGeoNode.h:286
char * Form(const char *fmt,...)
const TGeoIterator * fIterator
Definition: TGeoNode.h:234
#define ClassImp(name)
Definition: Rtypes.h:279
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:567
virtual void SetLineColor(Color_t lcolor)
Set the line color.
TGeoVolume * GetVolume() const
Definition: TGeoNode.h:106