source: snovis/trunk/source/G4Lab/DigitsCollectionAccessor.h@ 288

Last change on this file since 288 was 288, checked in by barrand, 18 years ago
  • Property svn:eol-style set to native
File size: 3.0 KB
Line 
1#ifndef G4Lab_DigitsCollectionAccessor_h
2#define G4Lab_DigitsCollectionAccessor_h
3
4// Inheritance :
5#include <OnX/Inventor/InventorAccessor.h>
6
7#include <G4Transform3D.hh>
8
9class G4VDigiCollection;
10class G4VDigi;
11class G4LogicalVolume;
12class G4Colour;
13class G4RunManager;
14
15namespace Slash {namespace Core {class ISession;}}
16namespace Slash {namespace Core {class IWriter;}}
17
18#include <map>
19#include <G4AttDef.hh>
20#include <G4String.hh>
21
22namespace G4Lab {
23
24class DigitsCollectionBaseAccessor : public OnX::InventorAccessor {
25public: //Slash::Data::IAccessor
26 virtual std::string name() const;
27 virtual Slash::Core::IValue* findValue(Slash::Data::IAccessor::Data,const std::string&,void*);
28public: //Slash::Data::IVisualizer
29 virtual void beginVisualize();
30 virtual void visualize(Slash::Data::IAccessor::Data,void*);
31public:
32 DigitsCollectionBaseAccessor(Slash::Core::ISession&,G4RunManager*,
33 const std::string& = "");
34 virtual ~DigitsCollectionBaseAccessor();
35 const std::string& DCName() const;
36protected:
37 static G4LogicalVolume* digiLogicalVolume(const G4VDigi&);
38 static G4Transform3D* digiTransform3D(const G4VDigi&);
39 static bool digiColor(const G4VDigi&,G4Colour&);
40 void setProperties(G4VDigi&);
41protected:
42 G4VDigiCollection* getCollection(Slash::Core::IWriter&,const std::string&);
43protected:
44 std::string fType;
45 G4RunManager* fRunManager;
46 std::map<G4String,G4AttDef>* fAttDefs;
47 std::string fDC;
48};
49
50}
51
52#include <G4VDigi.hh>
53#include <G4TDigiCollection.hh>
54#include <Slash/Data/IIterator.h>
55
56namespace G4Lab {
57
58template <class T>
59class DigitsCollectionAccessor : public DigitsCollectionBaseAccessor {
60public: //Slash::Data::IAccessor
61 virtual Slash::Data::IIterator* iterator() {
62 const std::vector<std::string>& args = iteratorArguments();
63 if(args.size()) fDC = args[0];
64 clearProperties();
65 fAttDefs = 0;
66 G4VDigiCollection* vdc = getCollection(printer(),fDC);
67 if(!vdc) return 0;
68 typedef G4TDigiCollection<T> Collection;
69 Collection* dc = dynamic_cast<Collection*>(vdc);
70 if(!dc) return 0;
71 if(dc->entries()) {
72 G4VDigi* digi = (*dc)[0];
73 if(digi) setProperties(*digi);
74 }
75 class Iterator : public virtual Slash::Data::IIterator {
76 public: //Slash::Data::IIterator
77 virtual Slash::Data::IAccessor::Data object() {
78 if(fCurrent>=fVector.entries()) return 0;
79 G4VDigi* digi = fVector[fCurrent];
80 return digi;
81 }
82 virtual void next() { fCurrent++;}
83 virtual void* tag() { return 0;}
84 public:
85 Iterator(Collection& aVector):fVector(aVector),fCurrent(0) {}
86 virtual ~Iterator() {}
87 private:
88 Collection& fVector;
89 int fCurrent;
90 };
91 return new Iterator(*dc);
92 }
93public:
94 DigitsCollectionAccessor(Slash::Core::ISession& aSession,
95 G4RunManager* aRunManager,
96 const std::string& aName = "")
97 :DigitsCollectionBaseAccessor(aSession,aRunManager,aName){}
98 virtual ~DigitsCollectionAccessor(){}
99};
100
101
102}
103
104#endif
Note: See TracBrowser for help on using the repository browser.