| 1 |
|
|---|
| 2 | // this :
|
|---|
| 3 | #include <G4Lab/SteppingAction.h>
|
|---|
| 4 |
|
|---|
| 5 | // Geant4 :
|
|---|
| 6 | #include <G4Step.hh>
|
|---|
| 7 | #include <G4ThreeVector.hh>
|
|---|
| 8 |
|
|---|
| 9 | #ifdef WIN32
|
|---|
| 10 | #include <windows.h>
|
|---|
| 11 | #endif
|
|---|
| 12 | #ifdef APPLE_GL //Beurk
|
|---|
| 13 | #include <gl.h>
|
|---|
| 14 | #else
|
|---|
| 15 | #include <GL/gl.h>
|
|---|
| 16 | #endif
|
|---|
| 17 |
|
|---|
| 18 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 19 | G4Lab::SteppingAction::SteppingAction(
|
|---|
| 20 | )
|
|---|
| 21 | :fEnabled(false)
|
|---|
| 22 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 23 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
|---|
| 24 | {
|
|---|
| 25 | }
|
|---|
| 26 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 27 | G4Lab::SteppingAction::~SteppingAction(
|
|---|
| 28 | )
|
|---|
| 29 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 30 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
|---|
| 31 | {
|
|---|
| 32 | }
|
|---|
| 33 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 34 | void G4Lab::SteppingAction::enable(
|
|---|
| 35 | )
|
|---|
| 36 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 37 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
|---|
| 38 | {
|
|---|
| 39 | fEnabled = true;
|
|---|
| 40 | }
|
|---|
| 41 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 42 | void G4Lab::SteppingAction::disable(
|
|---|
| 43 | )
|
|---|
| 44 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 45 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
|---|
| 46 | {
|
|---|
| 47 | fEnabled = false;
|
|---|
| 48 | }
|
|---|
| 49 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 50 | void G4Lab::SteppingAction::UserSteppingAction(
|
|---|
| 51 | const G4Step* aStep
|
|---|
| 52 | )
|
|---|
| 53 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 54 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
|---|
| 55 | {
|
|---|
| 56 | render(aStep);
|
|---|
| 57 | }
|
|---|
| 58 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 59 | void G4Lab::SteppingAction::render(
|
|---|
| 60 | const G4Step* aStep
|
|---|
| 61 | )
|
|---|
| 62 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 63 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
|---|
| 64 | {
|
|---|
| 65 | if(!aStep) return;
|
|---|
| 66 | if(!fEnabled) return;
|
|---|
| 67 |
|
|---|
| 68 | //G4double charge = step->GetTrack()->GetDefinition()->GetPDGCharge();
|
|---|
| 69 |
|
|---|
| 70 | const G4ThreeVector& begin = aStep->GetPreStepPoint()->GetPosition();
|
|---|
| 71 | const G4ThreeVector& end = aStep->GetPostStepPoint ()->GetPosition();
|
|---|
| 72 |
|
|---|
| 73 | glBegin(GL_LINES);
|
|---|
| 74 | glVertex3d(begin.x(),begin.y(),begin.z());
|
|---|
| 75 | glVertex3d(end.x(),end.y(),end.z());
|
|---|
| 76 | glEnd();
|
|---|
| 77 |
|
|---|
| 78 | // Flush here if we want to have a chance to see
|
|---|
| 79 | // step by step drawing :
|
|---|
| 80 | glFlush();
|
|---|
| 81 | glFinish();
|
|---|
| 82 | }
|
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 |
|
|---|