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

#include <G4VisCommandsScene.hh>

Inheritance diagram for G4VisCommandSceneActivateModel:
Collaboration diagram for G4VisCommandSceneActivateModel:

Public Member Functions

 G4VisCommandSceneActivateModel ()
 
virtual ~G4VisCommandSceneActivateModel ()
 
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 51 of file G4VisCommandsScene.hh.

Constructor & Destructor Documentation

G4VisCommandSceneActivateModel::G4VisCommandSceneActivateModel ( )

Definition at line 61 of file G4VisCommandsScene.cc.

61  {
62  G4bool omitable;
63  fpCommand = new G4UIcommand ("/vis/scene/activateModel", this);
64  fpCommand -> SetGuidance
65  ("Activate or de-activate model.");
66  fpCommand -> SetGuidance
67  ("Attempts to match search string to name of model - use unique sub-string.");
68  fpCommand -> SetGuidance
69  ("Use \"/vis/scene/list\" to see model names.");
70  fpCommand -> SetGuidance
71  ("If name == \"all\" (default), all models are activated.");
72  G4UIparameter* parameter;
73  parameter = new G4UIparameter ("search-string", 's', omitable = true);
74  parameter -> SetDefaultValue ("all");
75  fpCommand -> SetParameter (parameter);
76  parameter = new G4UIparameter ("activate", 'b', omitable = true);
77  parameter -> SetDefaultValue (true);
78  fpCommand -> SetParameter (parameter);
79 }
bool G4bool
Definition: G4Types.hh:79
G4VisCommandSceneActivateModel::~G4VisCommandSceneActivateModel ( )
virtual

Definition at line 81 of file G4VisCommandsScene.cc.

81  {
82  delete fpCommand;
83 }

Member Function Documentation

G4String G4VisCommandSceneActivateModel::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 85 of file G4VisCommandsScene.cc.

85  {
86  return "";
87 }
void G4VisCommandSceneActivateModel::SetNewValue ( G4UIcommand command,
G4String  newValue 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 89 of file G4VisCommandsScene.cc.

90  {
91 
93 
94  G4String searchString, activateString;
95  std::istringstream is (newValue);
96  is >> searchString >> activateString;
97  G4bool activate = G4UIcommand::ConvertToBool(activateString);
98 
100  if (!pScene) {
101  if (verbosity >= G4VisManager::errors) {
102  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
103  }
104  return;
105  }
106 
108  if (!pSceneHandler) {
109  if (verbosity >= G4VisManager::errors) {
110  G4cerr << "ERROR: No current sceneHandler. Please create one." << G4endl;
111  }
112  return;
113  }
114 
115  if (searchString == "all" && !activate) {
116  if (verbosity >= G4VisManager::warnings) {
117  G4cout <<
118  "WARNING: You are not allowed to de-activate all models."
119  "\n Command ignored."
120  << G4endl;
121  }
122  return;
123  }
124 
125  G4bool any = false;
126 
127  std::vector<G4Scene::Model>& runDurationModelList =
128  pScene->SetRunDurationModelList();
129  for (size_t i = 0; i < runDurationModelList.size(); i++) {
130  const G4String& modelName =
131  runDurationModelList[i].fpModel->GetGlobalDescription();
132  if (searchString == "all" || modelName.find(searchString)
133  != std::string::npos) {
134  any = true;
135  runDurationModelList[i].fActive = activate;
136  if (verbosity >= G4VisManager::warnings) {
137  G4cout << "Model \"" << modelName;
138  if (activate) G4cout << "\" activated.";
139  else G4cout << "\" de-activated.";
140  G4cout << G4endl;
141  }
142  }
143  }
144 
145  std::vector<G4Scene::Model>& endOfEventModelList =
146  pScene->SetEndOfEventModelList();
147  for (size_t i = 0; i < endOfEventModelList.size(); i++) {
148  const G4String& modelName =
149  endOfEventModelList[i].fpModel->GetGlobalDescription();
150  if (searchString == "all" || modelName.find(searchString)
151  != std::string::npos) {
152  any = true;
153  endOfEventModelList[i].fActive = activate;
154  if (verbosity >= G4VisManager::warnings) {
155  G4cout << "Model \"" << modelName;
156  if (activate) G4cout << "\" activated.";
157  else G4cout << "\" de-activated.";
158  G4cout << G4endl;
159  }
160  }
161  }
162 
163  std::vector<G4Scene::Model>& endOfRunModelList =
164  pScene->SetEndOfRunModelList();
165  for (size_t i = 0; i < endOfRunModelList.size(); i++) {
166  const G4String& modelName =
167  endOfRunModelList[i].fpModel->GetGlobalDescription();
168  if (searchString == "all" || modelName.find(searchString)
169  != std::string::npos) {
170  any = true;
171  endOfRunModelList[i].fActive = activate;
172  if (verbosity >= G4VisManager::warnings) {
173  G4cout << "Model \"" << modelName;
174  if (activate) G4cout << "\" activated.";
175  else G4cout << "\" de-activated.";
176  G4cout << G4endl;
177  }
178  }
179  }
180 
181  if (!any) {
182  if (verbosity >= G4VisManager::warnings) {
183  G4cout << "WARNING: No match found." << G4endl;
184  }
185  return;
186  }
187 
188  const G4String& currentSceneName = pScene -> GetName ();
189  UpdateVisManagerScene (currentSceneName);
190 }
void UpdateVisManagerScene(const G4String &sceneName="")
std::vector< Model > & SetEndOfRunModelList()
G4GLOB_DLL std::ostream G4cout
static G4bool ConvertToBool(const char *st)
Definition: G4UIcommand.cc:437
bool G4bool
Definition: G4Types.hh:79
std::vector< Model > & SetRunDurationModelList()
std::vector< Model > & SetEndOfEventModelList()
G4VSceneHandler * GetCurrentSceneHandler() const
static Verbosity GetVerbosity()
#define G4endl
Definition: G4ios.hh:61
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: