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