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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

VisualizationNote that class G4Text also inherits G4VMarker. Size of text is recognized as "font size", i.e., height of the text.All the access functions defined <strong>for</strong> class G4VMarker mentioned above are available. In addition, the followingaccess functions are available, too://----- Set functions of G4Textvoid G4Text::SetText ( const G4String& text ) ;void G4Text::SetOffset ( double dx, double dy ) ;//----- Get functions of G4TextG4String G4Text::GetText () const;G4double G4Text::GetXOffset () const;G4double G4Text::GetYOffset () const;Method SetText() defines text to be visualized, and GetText() returns the defined text. Method SetOffset()defines x (horizontal) and y (vertical) offsets in the screen coordinates. By default, both offsets are zero, andthe text starts from the 3D position given to the constructor or to the method G4VMarker:SetPosition().Offsets should be given with the same units as the one adopted <strong>for</strong> the size, i.e., world-size or screen-size units.Example 8.8 shows sample C++ source code to define text with the following properties:• Text: "Welcome to <strong>Geant4</strong> Visualization"• Position: (0.,0.,0.) in the world coordinates• Horizontal offset: 10 pixels• Vertical offset: -20 pixels• Colour: blue (default)Example 8.8. An example of defining text.//----- C++ source codes: An example of defining a visualizable text//----- InstantiationG4Text text ;text.SetText ( "Welcome to <strong>Geant4</strong> Visualization");text.SetPosition ( G4Point3D(0.,0.,0.) );// These three lines are equivalent to:// G4Text text ( "Welcome to <strong>Geant4</strong> Visualization",// G4Point3D(0.,0.,0.) );//----- Size (font size in units of pixels)G4double fontsize = 24.; // Should be 24. * pixels - to be implemented.text.SetScreenSize ( fontsize );//----- OffsetsG4double x_offset = 10.; // Should be 10. * pixels - to be implemented.G4double y_offset = -20.; // Should be -20. * pixels - to be implemented.text.SetOffset( x_offset, y_offset );//----- Color (Blue is the default setting, and so the codes below are omissible)G4Colour blue( 0., 0., 1. );G4VisAttributes att ( blue );text.SetVisAttributes ( att );//----- end of C++ source codes8.10. Making a MovieThese instructions are suggestive only. The following procedures have not been tested on all plat<strong>for</strong>ms. Thereare clearly some instructions that apply only to Unix-like systems with an X-Windows based windowing system.However, it should not be difficult to take the ideas presented here and extend them to other plat<strong>for</strong>ms and systems.The procedures described here need graphics drivers that can produce picture files that can be converted to a <strong>for</strong>msuitable <strong>for</strong> an MPEG encoder. There may be other ways of capturing the screen images and we would be happyto hear about them. Graphics drivers currently capable of producing picture files are: More in<strong>for</strong>mations aboutMPEG encoderDriverFile type266

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

Saved successfully!

Ooh no, something went wrong!