Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4VisCommandSceneAddAxes Class Reference

#include <G4VisCommandsSceneAdd.hh>

Inheritance diagram for G4VisCommandSceneAddAxes:
Collaboration diagram for G4VisCommandSceneAddAxes:

Public Member Functions

 G4VisCommandSceneAddAxes ()
 
virtual ~G4VisCommandSceneAddAxes ()
 
G4String GetCurrentValue (G4UIcommand *command)
 
void SetNewValue (G4UIcommand *command, G4String newValue)
 
- Public Member Functions inherited from G4VVisCommandScene
 G4VVisCommandScene ()
 
virtual ~G4VVisCommandScene ()
 
- Public Member Functions inherited from G4VVisCommand
 G4VVisCommand ()
 
virtual ~G4VVisCommand ()
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()
 
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
virtual ~G4UImessenger ()
 
G4bool operator== (const G4UImessenger &messenger) const
 
G4bool CommandsShouldBeInMaster () const
 

Additional Inherited Members

- Static Public Member Functions inherited from G4VVisCommand
static void SetVisManager (G4VisManager *)
 
static const G4ColourGetCurrentColour ()
 
static G4double GetCurrentLineWidth ()
 
static const G4ColourGetCurrentTextColour ()
 
static G4Text::Layout GetCurrentTextLayout ()
 
static G4double GetCurrentTextSize ()
 
- Protected Member Functions inherited from G4VVisCommandScene
G4String CurrentSceneName ()
 
- Protected Member Functions inherited from G4VVisCommand
void UpdateVisManagerScene (const G4String &sceneName="")
 
- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (G4String s)
 
G4double StoD (G4String s)
 
G4bool StoB (G4String s)
 
void AddUIcommand (G4UIcommand *newCommand)
 
void CreateDirectory (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 
- Static Protected Member Functions inherited from G4VVisCommand
static G4String ConvertToString (G4double x, G4double y, const char *unitName)
 
static void ConvertToDoublePair (const G4String &paramString, G4double &xval, G4double &yval)
 
- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir
 
G4String baseDirName
 
G4bool commandsShouldBeInMaster
 
- Static Protected Attributes inherited from G4VVisCommand
static G4VisManagerfpVisManager = 0
 
static G4int fErrorCode = 0
 
static G4Colour fCurrentColour = G4Colour::White()
 
static G4double fCurrentLineWidth = 1.
 
static G4Colour fCurrentTextColour = G4Colour::Blue()
 
static G4Text::Layout fCurrentTextLayout = G4Text::left
 
static G4double fCurrentTextSize = 12.
 
static
G4ModelingParameters::PVNameCopyNoPath 
fCurrentTouchablePath
 

Detailed Description

Definition at line 80 of file G4VisCommandsSceneAdd.hh.

Constructor & Destructor Documentation

G4VisCommandSceneAddAxes::G4VisCommandSceneAddAxes ( )

Definition at line 265 of file G4VisCommandsSceneAdd.cc.

265  {
266  G4bool omitable;
267  fpCommand = new G4UIcommand ("/vis/scene/add/axes", this);
268  fpCommand -> SetGuidance ("Add axes.");
269  fpCommand -> SetGuidance
270  ("Draws axes at (x0, y0, z0) of given length and colour.");
271  fpCommand -> SetGuidance
272  ("If \"colour-string\" is \"auto\", x, y and z will be red, green and blue"
273  "\n respectively. Otherwise it can be one of the pre-defined text-specified"
274  "\n colours - see information printed by the vis manager at start-up or"
275  "\n use \"/vis/list\".");
276  fpCommand -> SetGuidance
277  ("If \"length\" is negative, it is set to about 25% of scene extent.");
278  fpCommand -> SetGuidance
279  ("If \"showtext\" is false, annotations are suppressed.");
280  G4UIparameter* parameter;
281  parameter = new G4UIparameter ("x0", 'd', omitable = true);
282  parameter->SetDefaultValue (0.);
283  fpCommand->SetParameter (parameter);
284  parameter = new G4UIparameter ("y0", 'd', omitable = true);
285  parameter->SetDefaultValue (0.);
286  fpCommand->SetParameter (parameter);
287  parameter = new G4UIparameter ("z0", 'd', omitable = true);
288  parameter->SetDefaultValue (0.);
289  fpCommand->SetParameter (parameter);
290  parameter = new G4UIparameter ("length", 'd', omitable = true);
291  parameter->SetDefaultValue (-1.);
292  fpCommand->SetParameter (parameter);
293  parameter = new G4UIparameter ("unit", 's', omitable = true);
294  parameter->SetDefaultValue ("m");
295  fpCommand->SetParameter (parameter);
296  parameter = new G4UIparameter ("colour-string", 's', omitable = true);
297  parameter->SetDefaultValue ("auto");
298  fpCommand->SetParameter (parameter);
299  parameter = new G4UIparameter ("showtext", 'b', omitable = true);
300  parameter->SetDefaultValue ("true");
301  fpCommand->SetParameter (parameter);
302 }
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:152
void SetDefaultValue(const char *theDefaultValue)
bool G4bool
Definition: G4Types.hh:79

Here is the call graph for this function:

G4VisCommandSceneAddAxes::~G4VisCommandSceneAddAxes ( )
virtual

Definition at line 304 of file G4VisCommandsSceneAdd.cc.

304  {
305  delete fpCommand;
306 }

Member Function Documentation

G4String G4VisCommandSceneAddAxes::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 308 of file G4VisCommandsSceneAdd.cc.

308  {
309  return "";
310 }
void G4VisCommandSceneAddAxes::SetNewValue ( G4UIcommand command,
G4String  newValue 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 312 of file G4VisCommandsSceneAdd.cc.

312  {
313 
315  G4bool warn(verbosity >= G4VisManager::warnings);
316 
317  G4Scene* pScene = fpVisManager->GetCurrentScene();
318  if (!pScene) {
319  if (verbosity >= G4VisManager::errors) {
320  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
321  }
322  return;
323  } else {
324  if (pScene->GetExtent().GetExtentRadius() <= 0.) {
325  if (verbosity >= G4VisManager::errors) {
326  G4cerr
327  << "ERROR: Scene has no extent. Add volumes or use \"/vis/scene/add/extent\"."
328  << G4endl;
329  }
330  return;
331  }
332  }
333 
334  G4String unitString, colourString, showTextString;
335  G4double x0, y0, z0, length;
336  std::istringstream is (newValue);
337  is >> x0 >> y0 >> z0 >> length >> unitString
338  >> colourString >> showTextString;
339  G4bool showText = G4UIcommand::ConvertToBool(showTextString);
340 
341 
342  G4double unit = G4UIcommand::ValueOf(unitString);
343  x0 *= unit; y0 *= unit; z0 *= unit;
344  const G4VisExtent& sceneExtent = pScene->GetExtent(); // Existing extent.
345  if (length < 0.) {
346  const G4double lengthMax = 0.5 * sceneExtent.GetExtentRadius();
347  const G4double intLog10Length = std::floor(std::log10(lengthMax));
348  length = std::pow(10,intLog10Length);
349  if (5.*length < lengthMax) length *= 5.;
350  else if (2.*length < lengthMax) length *= 2.;
351  } else {
352  length *= unit;
353  }
354 
355  // Consult scene for arrow width...
356  G4double arrowWidth =
357  0.005 * fCurrentLineWidth * sceneExtent.GetExtentRadius();
358  // ...but limit it to length/50.
359  if (arrowWidth > length/50.) arrowWidth = length/50.;
360 
361  G4VModel* model = new G4AxesModel
362  (x0, y0, z0, length, arrowWidth, colourString, newValue,
363  showText, fCurrentTextSize);
364 
365  G4bool successful = pScene -> AddRunDurationModel (model, warn);
366  const G4String& currentSceneName = pScene -> GetName ();
367  if (successful) {
368  if (verbosity >= G4VisManager::confirmations) {
369  G4cout << "Axes of length " << G4BestUnit(length,"Length")
370  << "have been added to scene \"" << currentSceneName << "\"."
371  << G4endl;
372  }
373  }
374  else G4VisCommandsSceneAddUnsuccessful(verbosity);
375  UpdateVisManagerScene (currentSceneName);
376 }
void UpdateVisManagerScene(const G4String &sceneName="")
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
static G4double fCurrentTextSize
static void G4VisCommandsSceneAddUnsuccessful(G4VisManager::Verbosity verbosity)
G4double GetExtentRadius() const
Definition: G4VisExtent.cc:73
G4GLOB_DLL std::ostream G4cout
const G4VisExtent & GetExtent() const
static G4bool ConvertToBool(const char *st)
Definition: G4UIcommand.cc:437
bool G4bool
Definition: G4Types.hh:79
static G4double ValueOf(const char *unitName)
Definition: G4UIcommand.cc:309
static G4double fCurrentLineWidth
static Verbosity GetVerbosity()
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
const XML_Char XML_Content * model
Definition: expat.h:151
G4Scene * GetCurrentScene() const
G4GLOB_DLL std::ostream G4cerr
static G4VisManager * fpVisManager

Here is the call graph for this function:


The documentation for this class was generated from the following files: