| 1 | // this :
|
|---|
| 2 | #include <G4Lab/TrajectoryContainerAccessor.h>
|
|---|
| 3 |
|
|---|
| 4 | // Inventor :
|
|---|
| 5 | #include <Inventor/nodes/SoSeparator.h>
|
|---|
| 6 | #include <Inventor/nodes/SoLightModel.h>
|
|---|
| 7 | #include <Inventor/nodes/SoDrawStyle.h>
|
|---|
| 8 |
|
|---|
| 9 | // HEPVis :
|
|---|
| 10 | #include <HEPVis/nodes/SoHighlightMaterial.h>
|
|---|
| 11 |
|
|---|
| 12 | #ifdef WIN32
|
|---|
| 13 | #undef pascal // Clash between windef.h and Geant4/SystemOfUnits.hh
|
|---|
| 14 | #endif
|
|---|
| 15 |
|
|---|
| 16 | // Lib :
|
|---|
| 17 | #include <Slash/Core/ISession.h>
|
|---|
| 18 | #include <Slash/Data/IIterator.h>
|
|---|
| 19 | #include <Lib/Out.h>
|
|---|
| 20 | #include <Lib/Variable.h>
|
|---|
| 21 | #include <Lib/smanip.h>
|
|---|
| 22 |
|
|---|
| 23 | // G4Lab :
|
|---|
| 24 | #include <G4Lab/SoG4RunManager.h>
|
|---|
| 25 |
|
|---|
| 26 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 27 | G4Lab::TrajectoryContainerAccessor::TrajectoryContainerAccessor(
|
|---|
| 28 | Slash::Core::ISession& aSession
|
|---|
| 29 | ,G4RunManager* aRunManager
|
|---|
| 30 | )
|
|---|
| 31 | :OnX::InventorAccessor(aSession)
|
|---|
| 32 | ,fType("TrajectoryContainer")
|
|---|
| 33 | ,fRunManager(aRunManager)
|
|---|
| 34 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 35 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
|---|
| 36 | {
|
|---|
| 37 | }
|
|---|
| 38 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 39 | G4Lab::TrajectoryContainerAccessor::~TrajectoryContainerAccessor(
|
|---|
| 40 | )
|
|---|
| 41 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 42 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
|---|
| 43 | {
|
|---|
| 44 | }
|
|---|
| 45 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 46 | std::string G4Lab::TrajectoryContainerAccessor::name(
|
|---|
| 47 | ) const
|
|---|
| 48 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 49 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
|---|
| 50 | {
|
|---|
| 51 | return fType;
|
|---|
| 52 | }
|
|---|
| 53 | namespace G4Lab {
|
|---|
| 54 | class TrajectoryContainerIterator : public virtual Slash::Data::IIterator {
|
|---|
| 55 | public: //Slash::Data::IIterator
|
|---|
| 56 | virtual Slash::Data::IAccessor::Data object() { return fValue; }
|
|---|
| 57 | virtual void next() { fValue = 0; }
|
|---|
| 58 | virtual void* tag() { return 0;}
|
|---|
| 59 | public:
|
|---|
| 60 | TrajectoryContainerIterator(void* aValue):fValue(aValue) {}
|
|---|
| 61 | virtual ~TrajectoryContainerIterator(){}
|
|---|
| 62 | private:
|
|---|
| 63 | void* fValue;
|
|---|
| 64 | };
|
|---|
| 65 | }
|
|---|
| 66 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 67 | Slash::Data::IIterator* G4Lab::TrajectoryContainerAccessor::iterator(
|
|---|
| 68 | )
|
|---|
| 69 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 70 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
|---|
| 71 | {
|
|---|
| 72 | return new TrajectoryContainerIterator(this);
|
|---|
| 73 | }
|
|---|
| 74 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 75 | Slash::Core::IValue* G4Lab::TrajectoryContainerAccessor::findValue(
|
|---|
| 76 | Slash::Data::IAccessor::Data aData
|
|---|
| 77 | ,const std::string& aName
|
|---|
| 78 | ,void* aTag
|
|---|
| 79 | )
|
|---|
| 80 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 81 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
|---|
| 82 | {
|
|---|
| 83 | return 0;
|
|---|
| 84 | }
|
|---|
| 85 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 86 | void G4Lab::TrajectoryContainerAccessor::beginVisualize(
|
|---|
| 87 | )
|
|---|
| 88 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 89 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
|---|
| 90 | {
|
|---|
| 91 | OnX::InventorAccessor::beginVisualize();
|
|---|
| 92 | std::string value;
|
|---|
| 93 | int number = 1;
|
|---|
| 94 | if(fSession.parameterValue("modeling.events",value)) {
|
|---|
| 95 | if(!Lib::smanip::toint(value,number)) number = 1;
|
|---|
| 96 | }
|
|---|
| 97 |
|
|---|
| 98 | // Search if an SoG4RunManager had been introduced already :
|
|---|
| 99 | SoG4RunManager* node =
|
|---|
| 100 | (SoG4RunManager*)fSoRegion->findNode("type","SoG4RunManager");
|
|---|
| 101 | if(node) {
|
|---|
| 102 | //debug fSession.out().println("debug : find soG4RunManager.");
|
|---|
| 103 | node->numberOfEvents.setValue(number);
|
|---|
| 104 | node->touch();
|
|---|
| 105 |
|
|---|
| 106 | } else {
|
|---|
| 107 |
|
|---|
| 108 | //debug fSession.out().println("debug : create soG4RunManager.");
|
|---|
| 109 |
|
|---|
| 110 | SoSeparator* separator = new SoSeparator;
|
|---|
| 111 | separator->setName("sceneGraph");
|
|---|
| 112 |
|
|---|
| 113 | separator->addChild(fSoGC.getHighlightMaterial());
|
|---|
| 114 | separator->addChild(fSoGC.getDrawStyle());
|
|---|
| 115 | separator->addChild(fSoGC.getLightModel());
|
|---|
| 116 |
|
|---|
| 117 | SoG4RunManager* soG4RunManager = new SoG4RunManager(fRunManager);
|
|---|
| 118 | soG4RunManager->numberOfEvents.setValue(number);
|
|---|
| 119 | separator->addChild(soG4RunManager);
|
|---|
| 120 |
|
|---|
| 121 | fSoRegion->doIt(SbAddNode(separator,"dynamicScene"));
|
|---|
| 122 | }
|
|---|
| 123 | }
|
|---|
| 124 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 125 | void G4Lab::TrajectoryContainerAccessor::visualize(
|
|---|
| 126 | Slash::Data::IAccessor::Data,void*
|
|---|
| 127 | )
|
|---|
| 128 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 129 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
|---|
| 130 | {
|
|---|
| 131 | }
|
|---|
| 132 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 133 | void G4Lab::TrajectoryContainerAccessor::endVisualize(
|
|---|
| 134 | )
|
|---|
| 135 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 136 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
|---|
| 137 | {
|
|---|
| 138 | }
|
|---|