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

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