1 | // this :
|
---|
2 | #include <ELYSE/HitsCollectionAccessor.h>
|
---|
3 |
|
---|
4 | // Inventor :
|
---|
5 | #include <Inventor/nodes/SoSeparator.h>
|
---|
6 | #include <Inventor/nodes/SoTransform.h>
|
---|
7 | #include <Inventor/nodes/SoLightModel.h>
|
---|
8 | #include <Inventor/nodes/SoDrawStyle.h>
|
---|
9 |
|
---|
10 | #include <Inventor/nodes/SoCube.h> //FIXME
|
---|
11 |
|
---|
12 | // HEPVis :
|
---|
13 | #include <HEPVis/misc/SoStyleCache.h>
|
---|
14 | #include <HEPVis/nodes/SoHighlightMaterial.h>
|
---|
15 |
|
---|
16 | #ifdef WIN32
|
---|
17 | #undef pascal // Clash between windef.h and Geant4/SystemOfUnits.hh
|
---|
18 | #endif
|
---|
19 |
|
---|
20 | // Geant4 :
|
---|
21 | #include <G4LogicalVolume.hh>
|
---|
22 | #include <G4Colour.hh>
|
---|
23 |
|
---|
24 | // Lib :
|
---|
25 | #include <Lib/smanip.h>
|
---|
26 |
|
---|
27 | // G4Lab :
|
---|
28 | #include <G4Lab/Transform3D.h>
|
---|
29 |
|
---|
30 | //////////////////////////////////////////////////////////////////////////////
|
---|
31 | ELYSE::HitsCollectionAccessor::HitsCollectionAccessor(
|
---|
32 | Slash::Core::ISession& aSession
|
---|
33 | ,const std::string& aHC
|
---|
34 | )
|
---|
35 | :G4Lab::HitsCollectionAccessor(aSession,aHC)
|
---|
36 | //////////////////////////////////////////////////////////////////////////////
|
---|
37 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
---|
38 | {
|
---|
39 | }
|
---|
40 | //////////////////////////////////////////////////////////////////////////////
|
---|
41 | ELYSE::HitsCollectionAccessor::~HitsCollectionAccessor(
|
---|
42 | )
|
---|
43 | //////////////////////////////////////////////////////////////////////////////
|
---|
44 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
---|
45 | {
|
---|
46 | }
|
---|
47 | //////////////////////////////////////////////////////////////////////////////
|
---|
48 | void ELYSE::HitsCollectionAccessor::visualize(
|
---|
49 | Slash::Data::IAccessor::Data aData
|
---|
50 | ,void*
|
---|
51 | )
|
---|
52 | //////////////////////////////////////////////////////////////////////////////
|
---|
53 | // The hit must have the "LV" and "TSF" AttDef.
|
---|
54 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
---|
55 | {
|
---|
56 | G4VHit* obj = (G4VHit*)aData;
|
---|
57 | G4LogicalVolume* lv = hitLogicalVolume(*obj);
|
---|
58 | if(!lv) return;
|
---|
59 | G4Transform3D* tsf = hitTransform3D(*obj);
|
---|
60 | if(!tsf) return;
|
---|
61 | G4VSolid* solid = lv->GetSolid();
|
---|
62 | if(!solid) return;
|
---|
63 | //G4Material* material = lv->GetMaterial();
|
---|
64 |
|
---|
65 | SoSeparator* separator = new SoSeparator;
|
---|
66 | separator->setName("sceneGraph");
|
---|
67 |
|
---|
68 | {G4Colour color;
|
---|
69 | if(hitColor(*obj,color)) {
|
---|
70 | SbColor sbColor((float)color.GetRed(),
|
---|
71 | (float)color.GetGreen(),
|
---|
72 | (float)color.GetBlue());
|
---|
73 | float transp = 1.0F - (float)color.GetAlpha();
|
---|
74 | SoStyleCache* styleCache = fSoGC.getStyleCache();
|
---|
75 | separator->addChild(
|
---|
76 | styleCache->getHighlightMaterial
|
---|
77 | (sbColor,fSoGC.getHighlightColor(),transp));
|
---|
78 | } else {
|
---|
79 | separator->addChild(fSoGC.getHighlightMaterial());
|
---|
80 | }
|
---|
81 | separator->addChild(fSoGC.getDrawStyle());
|
---|
82 | separator->addChild(fSoGC.getLightModel());}
|
---|
83 |
|
---|
84 | {SoTransform* transform = new SoTransform;
|
---|
85 | G4Lab::Transform3D* t = new G4Lab::Transform3D(*tsf);
|
---|
86 | SbMatrix* matrix = t->getMatrix();
|
---|
87 | transform->setMatrix(*matrix);
|
---|
88 | delete matrix;
|
---|
89 | delete t;
|
---|
90 | separator->addChild(transform);}
|
---|
91 |
|
---|
92 | // Build name (for picking) :
|
---|
93 | std::string s;
|
---|
94 | Lib::smanip::printf(s,128,"%s/0x%lx",HCName().c_str(),(unsigned long)obj);
|
---|
95 | SbName name(s.c_str());
|
---|
96 |
|
---|
97 | // Representation :
|
---|
98 |
|
---|
99 | //FIXME
|
---|
100 |
|
---|
101 | //FIXME : PM base size :
|
---|
102 | double WCPMTRadius = 0.10*m; // 20-cm PMTs (8-inch)
|
---|
103 |
|
---|
104 | SoCube* soCube = new SoCube;
|
---|
105 | soCube->width.setValue(WCPMTRadius);
|
---|
106 | soCube->height.setValue(WCPMTRadius);
|
---|
107 | soCube->depth.setValue(WCPMTRadius);
|
---|
108 | soCube->setName(name);
|
---|
109 |
|
---|
110 | separator->addChild(soCube);
|
---|
111 |
|
---|
112 | fSoRegion->doIt(SbAddNode(separator,"dynamicScene"));
|
---|
113 | }
|
---|