12.07.2015 Views

Geant4 User's Guide for Application Developers - Geant4 - CERN

Geant4 User's Guide for Application Developers - Geant4 - CERN

Geant4 User's Guide for Application Developers - Geant4 - CERN

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Visualization{G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();if (pVVisManager) {//----- Get the Stepping Managerconst G4SteppingManager* pSM = GetSteppingManager();//----- Define a line segmentG4Polyline polyline;G4double charge = pSM->GetTrack()->GetDefinition()->GetPDGCharge();G4Colour colour;if (charge < 0.) colour = G4Colour(1., 0., 0.);else if (charge < 0.) colour = G4Colour(0., 0., 1.);else colour = G4Colour(0., 1., 0.);G4VisAttributes attribs(colour);polyline.SetVisAttributes(attribs);polyline.push_back(pSM->GetStep()->GetPreStepPoint()->GetPosition());polyline.push_back(pSM->GetStep()->GetPostStepPoint()->GetPosition());//----- Call a drawing method <strong>for</strong> G4PolylinepVVisManager -> Draw(polyline);}}//----- end of C++ source codeNext, in order that the above C++ source code works, you have to pass the in<strong>for</strong>mation of the MySteppingActionto the Run Manager in the main() function://----- C++ source code: Passing what to do at each step to the Run Managerint main(){...// Run ManagerG4RunManager * runManager = new G4RunManager;}// User initialization classes...runManager->SetUserAction(new MySteppingAction);...//----- end of C++ source codeThus you can visualize tracking steps with various visualization attributes, e.g., color, at each step, automatically.As well as tracking steps, you can visualize any kind 3D object made of line segments, using class G4Polylineand its drawing method, defined in class G4VVisManager. See, <strong>for</strong> example, the implementation of the /vis/scene/add/axes command.8.5.10. Visualization User ActionYou can implement the Draw method of G4VUserVisAction, e.g., the class definition could be:class StandaloneVisAction: public G4VUserVisAction {void Draw();};and the implementation:void StandaloneVisAction::Draw() {250

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!