Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4VisCommandSceneHandlerCreate Class Reference

#include <G4VisCommandsSceneHandler.hh>

+ Inheritance diagram for G4VisCommandSceneHandlerCreate:

Public Member Functions

 G4VisCommandSceneHandlerCreate ()
 
 ~G4VisCommandSceneHandlerCreate ()
 
G4String GetCurrentValue (G4UIcommand *command)
 
void SetNewValue (G4UIcommand *command, G4String newValue)
 
- Public Member Functions inherited from G4VVisCommand
 G4VVisCommand ()
 
virtual ~G4VVisCommand ()
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()
 
 G4UImessenger (const G4String &path, const G4String &dsc)
 
virtual ~G4UImessenger ()
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
virtual void SetNewValue (G4UIcommand *command, G4String newValue)
 
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 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)
 
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 50 of file G4VisCommandsSceneHandler.hh.

Constructor & Destructor Documentation

◆ G4VisCommandSceneHandlerCreate()

G4VisCommandSceneHandlerCreate::G4VisCommandSceneHandlerCreate ( )

Definition at line 138 of file G4VisCommandsSceneHandler.cc.

138 : fId (0) {
139 G4bool omitable;
140 fpCommand = new G4UIcommand ("/vis/sceneHandler/create", this);
141 fpCommand -> SetGuidance
142 ("Creates an scene handler for a specific graphics system.");
143 fpCommand -> SetGuidance
144 ("Attaches current scene, if any. (You can change attached scenes with"
145 "\n\"/vis/sceneHandler/attach\".) Invents a scene handler name if not"
146 "\nsupplied. This scene handler becomes current.");
147 G4UIparameter* parameter;
148 parameter = new G4UIparameter ("graphics-system-name",
149 's', omitable = false);
150 const G4GraphicsSystemList& gslist =
151 fpVisManager -> GetAvailableGraphicsSystems ();
152 G4String candidates;
153 for (size_t igslist = 0; igslist < gslist.size (); igslist++) {
154 const G4String& name = gslist [igslist] -> GetName ();
155 const G4String& nickname = gslist [igslist] -> GetNickname ();
156 if (nickname.isNull ()) {
157 candidates += name;
158 }
159 else {
160 candidates += nickname;
161 }
162 candidates += " ";
163 }
164 candidates = candidates.strip ();
165 parameter -> SetParameterCandidates(candidates);
166 fpCommand -> SetParameter (parameter);
167 parameter = new G4UIparameter
168 ("scene-handler-name", 's', omitable = true);
169 parameter -> SetCurrentAsDefault (true);
170 fpCommand -> SetParameter (parameter);
171}
bool G4bool
Definition: G4Types.hh:67
G4bool isNull() const
G4String strip(G4int strip_Type=trailing, char c=' ')
static G4VisManager * fpVisManager

◆ ~G4VisCommandSceneHandlerCreate()

G4VisCommandSceneHandlerCreate::~G4VisCommandSceneHandlerCreate ( )

Definition at line 173 of file G4VisCommandsSceneHandler.cc.

173 {
174 delete fpCommand;
175}

Member Function Documentation

◆ GetCurrentValue()

G4String G4VisCommandSceneHandlerCreate::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 183 of file G4VisCommandsSceneHandler.cc.

183 {
184
185 G4String graphicsSystemName;
186 const G4VGraphicsSystem* graphicsSystem =
187 fpVisManager -> GetCurrentGraphicsSystem ();
188 if (graphicsSystem) {
189 graphicsSystemName = graphicsSystem -> GetName ();
190 }
191 else {
192 const G4GraphicsSystemList& gslist =
193 fpVisManager -> GetAvailableGraphicsSystems ();
194 if (gslist.size ()) {
195 graphicsSystemName = gslist [0] -> GetName ();
196 }
197 else {
198 graphicsSystemName = "none";
199 }
200 }
201
202 return graphicsSystemName + " " + NextName ();
203}

◆ SetNewValue()

void G4VisCommandSceneHandlerCreate::SetNewValue ( G4UIcommand command,
G4String  newValue 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 205 of file G4VisCommandsSceneHandler.cc.

206 {
207
209
210 G4String graphicsSystem, newName;
211 std::istringstream is (newValue);
212 is >> graphicsSystem >> newName;
213
214 const G4GraphicsSystemList& gsl =
215 fpVisManager -> GetAvailableGraphicsSystems ();
216 int nSystems = gsl.size ();
217 if (nSystems <= 0) {
218 if (verbosity >= G4VisManager::errors) {
219 G4cout << "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
220 " no graphics systems available."
221 "\n Did you instantiate any in"
222 " YourVisManager::RegisterGraphicsSystems()?"
223 << G4endl;
224 }
225 return;
226 }
227 int iGS; // Selector index.
228 for (iGS = 0; iGS < nSystems; iGS++) {
229 if (graphicsSystem.compareTo (gsl [iGS] -> GetName (),
230 G4String::ignoreCase) == 0 ||
231 graphicsSystem.compareTo (gsl [iGS] -> GetNickname (),
232 G4String::ignoreCase) == 0) {
233 break; // Match found.
234 }
235 }
236 if (iGS < 0 || iGS >= nSystems) {
237 // Invalid command line argument or non.
238 // This shouldn't happen!!!!!!
239 if (verbosity >= G4VisManager::errors) {
240 G4cout << "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
241 " invalid graphics system specified."
242 << G4endl;
243 }
244 return;
245 }
246
247 // Check UI session compatibility.
248 if (!gsl[iGS]->IsUISessionCompatible()) {
249 G4String fallbackNickname = gsl[iGS]->GetNickname() + "_FALLBACK";
250 for (iGS = 0; iGS < nSystems; iGS++) {
251 if (fallbackNickname.compareTo (gsl [iGS] -> GetNickname (),
252 G4String::ignoreCase) == 0) {
253 break; // Match found.
254 }
255 }
256 if (iGS < 0 || iGS >= nSystems) {
257 if (verbosity >= G4VisManager::errors) {
258 G4cout << "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
259 " could not find fallback graphics system."
260 << G4endl;
261 }
262 return;
263 }
264 if (verbosity >= G4VisManager::warnings) {
265 G4cout << "WARNING: G4VisCommandSceneHandlerCreate::SetNewValue:"
266 " using fallback graphics system."
267 << G4endl;
268 }
269 }
270
271 // Set current graphics system in preparation for
272 // creating scene handler.
273 G4VGraphicsSystem* pSystem = gsl [iGS];
274 fpVisManager -> SetCurrentGraphicsSystem (pSystem);
275 if (verbosity >= G4VisManager::confirmations) {
276 G4cout << "Graphics system set to " << pSystem -> GetName () << G4endl;
277 }
278
279 // Now deal with name of scene handler.
280 G4String nextName = NextName ();
281 if (newName == "") {
282 newName = nextName;
283 }
284 if (newName == nextName) fId++;
285
286 const G4SceneHandlerList& list = fpVisManager -> GetAvailableSceneHandlers ();
287 size_t iScene;
288 for (iScene = 0; iScene < list.size (); iScene++) {
289 G4VSceneHandler* sceneHandler = list [iScene];
290 if (sceneHandler -> GetName () == newName) {
291 if (verbosity >= G4VisManager::errors) {
292 G4cout << "ERROR: Scene handler \"" << newName
293 << "\" already exists." << G4endl;
294 }
295 return;
296 }
297 }
298
299 //Create scene handler.
300 fpVisManager -> CreateSceneHandler (newName);
301 if (fpVisManager -> GetCurrentSceneHandler () -> GetName () != newName) {
302 if (verbosity >= G4VisManager::errors) {
303 G4cout << "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
304 " Curious name mismatch."
305 "\n Current name \""
306 << fpVisManager -> GetCurrentSceneHandler () -> GetName ()
307 << "\" is not the new name \""
308 << newName
309 << "\".\n Please report to vis coordinator."
310 << G4endl;
311 }
312 return;
313 }
314
315 if (verbosity >= G4VisManager::confirmations) {
316 G4cout << "New scene handler \"" << newName << "\" created." << G4endl;
317 }
318
319 // Attach scene.
320 if (fpVisManager -> GetCurrentScene ())
321 G4UImanager::GetUIpointer () -> ApplyCommand ("/vis/sceneHandler/attach");
322}
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
@ ignoreCase
Definition: G4String.hh:111
G4int compareTo(const char *, caseCompare mode=exact) const
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:51
static Verbosity GetVerbosity()

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