Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
G4VisCommandSceneActivateModel Class Reference

#include <G4VisCommandsScene.hh>

Inheritance diagram for G4VisCommandSceneActivateModel:
G4VVisCommandScene G4VVisCommand G4UImessenger

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
 

Additional Inherited Members

- Static Public Member Functions inherited from G4VVisCommand
static void SetVisManager (G4VisManager *)
 
- 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
 
- Static Protected Attributes inherited from G4VVisCommand
static G4VisManagerfpVisManager = 0
 
static G4Colour fCurrentColour = G4Colour::White()
 
static G4Colour fCurrentTextColour = G4Colour::Blue()
 
static G4Text::Layout fCurrentTextLayout = G4Text::left
 
static G4double fCurrentLineWidth = 1.
 
static
G4ModelingParameters::PVNameCopyNoPath 
fCurrentTouchablePath
 

Detailed Description

Definition at line 51 of file G4VisCommandsScene.hh.

Constructor & Destructor Documentation

G4VisCommandSceneActivateModel::G4VisCommandSceneActivateModel ( )

Definition at line 58 of file G4VisCommandsScene.cc.

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

Definition at line 78 of file G4VisCommandsScene.cc.

78  {
79  delete fpCommand;
80 }

Member Function Documentation

G4String G4VisCommandSceneActivateModel::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 82 of file G4VisCommandsScene.cc.

82  {
83  return "";
84 }
void G4VisCommandSceneActivateModel::SetNewValue ( G4UIcommand command,
G4String  newValue 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 86 of file G4VisCommandsScene.cc.

References G4UIcommand::ConvertToBool(), G4VisManager::errors, G4VVisCommand::fpVisManager, G4cout, G4endl, G4VisManager::GetCurrentScene(), G4VisManager::GetCurrentSceneHandler(), G4VisManager::GetVerbosity(), G4Scene::SetEndOfEventModelList(), G4Scene::SetEndOfRunModelList(), G4Scene::SetRunDurationModelList(), G4VVisCommand::UpdateVisManagerScene(), and G4VisManager::warnings.

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

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