Download Geant4 User's Guide for Application Developers

Transcript
Visualization
Text is currently drawn only by the OpenGL drivers, such as OGLIX, OGLIXm and OpenInventor. It is not yet
supported on other drivers, including the Windows OpenGL drivers, HepRep, etc.
Note 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 for class G4VMarker mentioned above are available. In addition, the following
access functions are available, too:
//----- Set functions of G4Text
void G4Text::SetText ( const G4String& text ) ;
void G4Text::SetOffset ( double dx, double dy ) ;
//----- Get functions of G4Text
G4String 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, and the 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 for 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 Geant4 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
//----- Instantiation
G4Text text ;
text.SetText ( "Welcome to Geant4 Visualization");
text.SetPosition ( G4Point3D(0.,0.,0.) );
// These three lines are equivalent to:
// G4Text text ( "Welcome to Geant4 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 );
//----- Offsets
G4double 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 codes
8.10. Making a Movie
These instructions are suggestive only. The following procedures have not been tested on all platforms. There
are 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 platforms and systems.
The procedures described here need graphics drivers that can produce picture files that can be converted to a form
suitable for an MPEG encoder. There may be other ways of capturing the screen images and we would be happy
310