| [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 |
|
|---|
| 9 | class G4VDigiCollection;
|
|---|
| 10 | class G4VDigi;
|
|---|
| 11 | class G4LogicalVolume;
|
|---|
| 12 | class G4Colour;
|
|---|
| 13 |
|
|---|
| 14 | namespace Slash {namespace Core {class ISession;}}
|
|---|
| 15 | namespace Slash {namespace Core {class IWriter;}}
|
|---|
| 16 |
|
|---|
| 17 | #include <map>
|
|---|
| 18 | #include <G4AttDef.hh>
|
|---|
| 19 | #include <G4String.hh>
|
|---|
| 20 |
|
|---|
| 21 | namespace G4Lab {
|
|---|
| 22 |
|
|---|
| 23 | class DigitsCollectionBaseAccessor : public OnX::InventorAccessor {
|
|---|
| 24 | public: //Slash::Data::IAccessor
|
|---|
| 25 | virtual std::string name() const;
|
|---|
| 26 | virtual Slash::Core::IValue* findValue(Slash::Data::IAccessor::Data,const std::string&,void*);
|
|---|
| 27 | public: //Slash::Data::IVisualizer
|
|---|
| 28 | virtual void beginVisualize();
|
|---|
| 29 | virtual void visualize(Slash::Data::IAccessor::Data,void*);
|
|---|
| 30 | public:
|
|---|
| 31 | DigitsCollectionBaseAccessor(Slash::Core::ISession&,const std::string& = "");
|
|---|
| 32 | virtual ~DigitsCollectionBaseAccessor();
|
|---|
| 33 | const std::string& DCName() const;
|
|---|
| 34 | protected:
|
|---|
| 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&);
|
|---|
| 40 | protected:
|
|---|
| 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 |
|
|---|
| 52 | namespace G4Lab {
|
|---|
| 53 |
|
|---|
| 54 | template <class T>
|
|---|
| 55 | class DigitsCollectionAccessor : public DigitsCollectionBaseAccessor {
|
|---|
| 56 | public: //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 | }
|
|---|
| 89 | public:
|
|---|
| 90 | DigitsCollectionAccessor(Slash::Core::ISession& aSession,const std::string& aName = "")
|
|---|
| 91 | :DigitsCollectionBaseAccessor(aSession,aName){}
|
|---|
| 92 | virtual ~DigitsCollectionAccessor(){}
|
|---|
| 93 | };
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 | }
|
|---|
| 97 |
|
|---|
| 98 | #endif
|
|---|