// this : #include // Inventor : #include #include #include #include #include // HEPVis : #include #include #include #ifdef WIN32 #undef pascal // Clash between windef.h and Geant4/SystemOfUnits.hh #endif // Geant4 : #include #include #include #include #include #include #include #include #include #include #include #include // Lib : #include #include #include #include #include #include // G4Lab : #include #include ////////////////////////////////////////////////////////////////////////////// G4Lab::DigitsCollectionBaseAccessor::DigitsCollectionBaseAccessor( Slash::Core::ISession& aSession ,G4RunManager* aRunManager ,const std::string& aDC ) :OnX::InventorAccessor(aSession) ,fType("DC") ,fRunManager(aRunManager) ,fAttDefs(0) ,fDC(aDC) ////////////////////////////////////////////////////////////////////////////// //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// { if(fDC!="") fType = fDC; } ////////////////////////////////////////////////////////////////////////////// G4Lab::DigitsCollectionBaseAccessor::~DigitsCollectionBaseAccessor( ) ////////////////////////////////////////////////////////////////////////////// //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// { } ////////////////////////////////////////////////////////////////////////////// std::string G4Lab::DigitsCollectionBaseAccessor::name( ) const ////////////////////////////////////////////////////////////////////////////// //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// { return fType; } ////////////////////////////////////////////////////////////////////////////// const std::string& G4Lab::DigitsCollectionBaseAccessor::DCName( ) const ////////////////////////////////////////////////////////////////////////////// //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// { return fDC; } ////////////////////////////////////////////////////////////////////////////// Slash::Core::IValue* G4Lab::DigitsCollectionBaseAccessor::findValue( Slash::Data::IAccessor::Data aData ,const std::string& aName ,void* ) ////////////////////////////////////////////////////////////////////////////// //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// { if(!fAttDefs) { Lib::Out out(printer()); out << "G4Lab::DigitsCollectionBaseAccessor::value :" << " problem to get AttDefs fot digi collection " << Lib::sout(fDC) << "." << Lib::endl; return new Lib::Value(); } G4VDigi* obj = (G4VDigi*)aData; std::vector* vec = obj->CreateAttValues(); if(!vec) { Lib::Out out(printer()); out << "G4Lab::DigitsCollectionBaseAccessor::value :" << " problem to get AttValues fot digi collection " << Lib::sout(fDC) << "." << Lib::endl; return new Lib::Value(); } unsigned int number = vec->size(); for(unsigned int index=0;indexGetSolid(); if(!solid) return; //G4Material* material = lv->GetMaterial(); int old_nstep = HepPolyhedron::GetNumberOfRotationSteps(); HepPolyhedron::SetNumberOfRotationSteps(fSoGC.getRotationSteps()); G4Polyhedron* g4Polyhedron = solid->CreatePolyhedron(); HepPolyhedron::SetNumberOfRotationSteps(old_nstep); if(!g4Polyhedron) return; G4Lab::Polyhedron* polyhedron = new G4Lab::Polyhedron(*g4Polyhedron); delete g4Polyhedron; if(!polyhedron) return; SoSeparator* separator = new SoSeparator; separator->setName("sceneGraph"); G4Colour color; if(digiColor(*obj,color)) { SbColor sbColor((float)color.GetRed(), (float)color.GetGreen(), (float)color.GetBlue()); float transp = 1.0F - (float)color.GetAlpha(); SoStyleCache* styleCache = fSoGC.getStyleCache(); separator->addChild( styleCache->getHighlightMaterial (sbColor,fSoGC.getHighlightColor(),transp)); } else { separator->addChild(fSoGC.getHighlightMaterial()); } separator->addChild(fSoGC.getDrawStyle()); separator->addChild(fSoGC.getLightModel()); SoTransform* transform = new SoTransform; G4Lab::Transform3D* t = new G4Lab::Transform3D(*tsf); SbMatrix* matrix = t->getMatrix(); transform->setMatrix(*matrix); delete matrix; delete t; separator->addChild(transform); // Build name (for picking) : std::string s; Lib::smanip::printf(s,128,"%s/0x%lx",fDC.c_str(),(unsigned long)obj); SbName name(s.c_str()); //FIXME : can't cache due to the below setName for picking. //FIXME SoPolyhedron* soPolyhedron = fSoGC.getPolyhedron(*polyhedron); SoPolyhedron* soPolyhedron = new SoPolyhedron(*polyhedron); if(fSoGC.getModeling()==SbModeling_wire_frame) { soPolyhedron->solid.setValue(FALSE); //FIXME : handle reduceWireFrame. soPolyhedron->reducedWireFrame.setValue(TRUE); } else { soPolyhedron->solid.setValue(TRUE); } delete polyhedron; soPolyhedron->setName(name); separator->addChild(soPolyhedron); fSoRegion->doIt(SbAddNode(separator,"dynamicScene")); } ////////////////////////////////////////////////////////////////////////////// void G4Lab::DigitsCollectionBaseAccessor::setProperties( G4VDigi& aDigi ) ////////////////////////////////////////////////////////////////////////////// //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// { fAttDefs = (std::map*)aDigi.GetAttDefs(); if(!fAttDefs) return; std::map::const_iterator it; for(it=fAttDefs->begin();it!=fAttDefs->end();++it) { const std::string& sname = (*it).second.GetName(); if((sname!="LV") && (sname!="TSF") && (sname!="Color")) { const std::string& stype = (*it).second.GetValueType(); if(stype=="G4int") { addProperty((*it).first,Lib::Property::INTEGER); } else if((stype=="G4double")||(stype=="G4float")) { addProperty((*it).first,Lib::Property::DOUBLE); } else { addProperty((*it).first,Lib::Property::STRING); } } } } ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// G4VDigiCollection* G4Lab::DigitsCollectionBaseAccessor::getCollection( Slash::Core::IWriter& aPrinter ,const std::string& aName ) ////////////////////////////////////////////////////////////////////////////// //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// { if(!fRunManager) { Lib::Out out(aPrinter); out << "No G4RunManager." << Lib::endl; return 0; } const G4Event* event = fRunManager->GetCurrentEvent(); if(!event) { Lib::Out out(aPrinter); out << "No event." << Lib::endl; return 0; } G4DigiManager* digiManager = G4DigiManager::GetDMpointer(); if(!digiManager) { Lib::Out out(aPrinter); out << "No G4DigiManager." << Lib::endl; return 0; } // Get Digi collection of this event G4DCofThisEvent* dce = event->GetDCofThisEvent(); if(!dce) { Lib::Out out(aPrinter); out << "No G4DCofThisEvent." << Lib::endl; return 0; } G4int cid = digiManager->GetDigiCollectionID(aName); int nc = dce->GetNumberOfCollections(); if((cid<0)||(cid>=nc)) { Lib::Out out(aPrinter); out << "Collection id not found for " << Lib::sout(aName) << Lib::endl; return 0; } G4VDigiCollection* dc = dce->GetDC(cid); if(!dce) { Lib::Out out(aPrinter); out << "No G4VDigiCollection for " << Lib::sout(aName) << Lib::endl; return 0; } return dc; } ////////////////////////////////////////////////////////////////////////////// G4LogicalVolume* G4Lab::DigitsCollectionBaseAccessor::digiLogicalVolume( const G4VDigi& aDigi ) ////////////////////////////////////////////////////////////////////////////// //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// { std::vector* vec = aDigi.CreateAttValues(); if(!vec) return 0; std::string value; unsigned int number = vec->size(); for(unsigned int index=0;index* vec = aDigi.CreateAttValues(); if(!vec) return 0; std::string value; unsigned int number = vec->size(); for(unsigned int index=0;index* vec = aDigi.CreateAttValues(); if(vec) { std::string value; unsigned int number = vec->size(); for(unsigned int index=0;index