Download Geant4 User's Guide for Application Developers

Transcript
Visualization
#include
#include
#include
#include
#include
#include
"globals.hh"
"G4VisExecutive.hh"
"G4VisExtent.hh"
"G4UImanager.hh"
"G4UIterminal.hh"
"G4UItcsh.hh"
#include "StandaloneVisAction.hh"
int main() {
G4VisManager* visManager = new G4VisExecutive;
visManager->Initialize ();
visManager->SetUserAction
(new StandaloneVisAction,
G4VisExtent(-5*m,5*m,-5*m,5*m,-5*m,5*m));
// 2nd argument optional.
G4UImanager* UI = G4UImanager::GetUIpointer ();
UI->ApplyCommand ("/control/execute standalone.g4m");
G4UIsession* session = new G4UIterminal(new G4UItcsh);
session->SessionStart();
delete session;
delete visManager;
}
8.6. Visualization Attributes
Visualization attributes are extra pieces of information associated with the visualizable objects. This information
is necessary only for visualization, and is not included in geometrical information such as shapes, position, and
orientation. Typical examples of visualization attributes are Color, Visible/Invisible, Wireframe/Solid. For example, in visualizing a box, the Visualization Manager must know its colour. If an object to be visualized has not
been assigned a set of visualization attributes, then an appropriate default set is used automatically.
A set of visualization attributes is held by an instance of class G4VisAttributes defined in the graphics_reps
category. In the following, we explain the main fields of the G4VisAttributes one by one.
8.6.1. Visibility
Visibility is a boolean flag to control the visibility of objects that are passed to the Visualization Manager for
visualization. Visibility is set with the following access function:
void G4VisAttributes::SetVisibility (G4bool visibility);
If you give false to the argument, and if culling is activated (see below), visualization is skipped for objects for
which this set of visualization attributes is assigned. The default value of visibility is true.
Note that whether an object is visible or not is also affected by the current culling policy, which can be tuned
with visualization commands.
By default the following public static function is defined:
static const G4VisAttributes& GetInvisible();
which returns a reference to a const object in which visibility is set to false. It can be used as follows:
experimentalHall_logical -> SetVisAttributes (G4VisAttributes::GetInvisible());
Direct access to the public static const data member G4VisAttributes::Invisible is also possible but
deprecated on account of initialisation issues with dynamic libraries.
252