Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4VisCommandSceneHandlerCreate Class Reference

#include <G4VisCommandsSceneHandler.hh>

Inheritance diagram for G4VisCommandSceneHandlerCreate:
Collaboration 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, 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 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 50 of file G4VisCommandsSceneHandler.hh.

Constructor & Destructor Documentation

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 (const auto gs: gslist) {
154  const G4String& name = gs -> GetName ();
155  candidates += name + ' ';
156  for (const auto& nickname: gs -> GetNicknames ()) {
157  if (nickname != name) candidates += nickname + ' ';
158  }
159  }
160  candidates = candidates.strip ();
161  parameter -> SetParameterCandidates(candidates);
162  fpCommand -> SetParameter (parameter);
163  parameter = new G4UIparameter
164  ("scene-handler-name", 's', omitable = true);
165  parameter -> SetCurrentAsDefault (true);
166  fpCommand -> SetParameter (parameter);
167 }
const XML_Char * name
Definition: expat.h:151
G4String strip(G4int strip_Type=trailing, char c=' ')
bool G4bool
Definition: G4Types.hh:79
static G4VisManager * fpVisManager

Here is the call graph for this function:

G4VisCommandSceneHandlerCreate::~G4VisCommandSceneHandlerCreate ( )

Definition at line 169 of file G4VisCommandsSceneHandler.cc.

169  {
170  delete fpCommand;
171 }

Member Function Documentation

G4String G4VisCommandSceneHandlerCreate::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 179 of file G4VisCommandsSceneHandler.cc.

179  {
180 
181  G4String graphicsSystemName;
182  const G4VGraphicsSystem* graphicsSystem =
183  fpVisManager -> GetCurrentGraphicsSystem ();
184  if (graphicsSystem) {
185  graphicsSystemName = graphicsSystem -> GetName ();
186  }
187  else {
188  const G4GraphicsSystemList& gslist =
189  fpVisManager -> GetAvailableGraphicsSystems ();
190  if (gslist.size ()) {
191  graphicsSystemName = gslist [0] -> GetName ();
192  }
193  else {
194  graphicsSystemName = "none";
195  }
196  }
197 
198  return graphicsSystemName + " " + NextName ();
199 }
static G4VisManager * fpVisManager
void G4VisCommandSceneHandlerCreate::SetNewValue ( G4UIcommand command,
G4String  newValue 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 201 of file G4VisCommandsSceneHandler.cc.

202  {
203 
205 
206  G4String graphicsSystem, newName;
207  std::istringstream is (newValue);
208  is >> graphicsSystem >> newName;
209 
210  const G4GraphicsSystemList& gsl =
211  fpVisManager -> GetAvailableGraphicsSystems ();
212  G4int nSystems = gsl.size ();
213  if (nSystems <= 0) {
214  if (verbosity >= G4VisManager::errors) {
215  G4cerr << "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
216  " no graphics systems available."
217  "\n Did you instantiate any in"
218  " YourVisManager::RegisterGraphicsSystems()?"
219  << G4endl;
220  }
221  return;
222  }
223  G4int iGS; // Selector index.
224  G4bool found = false;
225  for (iGS = 0; iGS < nSystems; iGS++) {
226  const auto& gs = gsl[iGS];
227  if (graphicsSystem.compareTo(gs->GetName(), G4String::ignoreCase) == 0) {
228  found = true;
229  break; // Match found
230  } else {
231  const auto& nicknames = gs->GetNicknames();
232  for (size_t i = 0; i < nicknames.size(); ++i) {
233  const auto& nickname = nicknames[i];
234  if (graphicsSystem.compareTo (nickname, G4String::ignoreCase) == 0) {
235  found = true;
236  break; // Match found
237  }
238  }
239  if (found) {
240  break; // Match found
241  }
242  }
243  }
244  if (!found) {
245  // Invalid command line argument or none.
246  // This shouldn't happen!!!!!!
247  if (verbosity >= G4VisManager::errors) {
248  G4cerr <<
249  "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
250  "\n invalid graphics system \""
251  << graphicsSystem
252  << "\" requested."
253  << G4endl;
254  }
255  return;
256  }
257 
258  // Check UI session compatibility.
259  G4bool fallback = false;
260  while (!gsl[iGS]->IsUISessionCompatible()) {
261  // Not compatible, search for a fallback
262  fallback = false;
263  G4String fallbackNickname = gsl[iGS]->GetNickname() + "_FALLBACK";
264  for (iGS = 0; iGS < nSystems; iGS++) {
265  const auto& nicknames = gsl[iGS]->GetNicknames();
266  for (size_t i = 0; i < nicknames.size(); ++i) {
267  const auto& nickname = nicknames[i];
268  if (fallbackNickname.compareTo (nickname, G4String::ignoreCase) == 0) {
269  fallback = true;
270  break; // Match found
271  }
272  }
273  if (fallback) {
274  break; // Match found
275  }
276  }
277  if (iGS < 0 || iGS >= nSystems) {
278  if (verbosity >= G4VisManager::errors) {
279  G4cerr <<
280  "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
281  " could not find fallback graphics system for \""
282  << graphicsSystem
283  << "\"."
284  << G4endl;
285  }
286  return;
287  }
288  // A fallback system found...but go back and check this too.
289  }
290 
291  // A graphics system has been found
292  G4VGraphicsSystem* pSystem = gsl [iGS];
293 
294  if (fallback && verbosity >= G4VisManager::warnings) {
295  G4cout << "WARNING: G4VisCommandSceneHandlerCreate::SetNewValue:"
296  "\n Using fallback graphics system: "
297  << pSystem -> GetName ()
298  << " ("
299  << pSystem -> GetNickname ()
300  << ')'
301  << G4endl;
302  }
303 
304  // Set current graphics system in preparation for
305  // creating scene handler.
306  fpVisManager -> SetCurrentGraphicsSystem (pSystem);
307  if (verbosity >= G4VisManager::confirmations) {
308  G4cout << "Graphics system set to "
309  << pSystem -> GetName ()
310  << " ("
311  << pSystem -> GetNickname ()
312  << ')'
313  << G4endl;
314  }
315 
316  // Now deal with name of scene handler.
317  G4String nextName = NextName ();
318  if (newName == "") {
319  newName = nextName;
320  }
321  if (newName == nextName) fId++;
322 
323  const G4SceneHandlerList& list = fpVisManager -> GetAvailableSceneHandlers ();
324  size_t iScene;
325  for (iScene = 0; iScene < list.size (); iScene++) {
326  G4VSceneHandler* sceneHandler = list [iScene];
327  if (sceneHandler -> GetName () == newName) {
328  if (verbosity >= G4VisManager::errors) {
329  G4cerr << "ERROR: Scene handler \"" << newName
330  << "\" already exists." << G4endl;
331  }
332  return;
333  }
334  }
335 
336  //Create scene handler.
337  fpVisManager -> CreateSceneHandler (newName);
338  if (fpVisManager -> GetCurrentSceneHandler () -> GetName () != newName) {
339  if (verbosity >= G4VisManager::errors) {
340  G4cerr << "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
341  " Curious name mismatch."
342  "\n Current name \""
343  << fpVisManager -> GetCurrentSceneHandler () -> GetName ()
344  << "\" is not the new name \""
345  << newName
346  << "\".\n Please report to vis coordinator."
347  << G4endl;
348  }
349  return;
350  }
351 
352  if (verbosity >= G4VisManager::confirmations) {
353  G4cout << "New scene handler \"" << newName << "\" created." << G4endl;
354  }
355 
356  // Attach scene.
357  if (fpVisManager -> GetCurrentScene ())
358  G4UImanager::GetUIpointer () -> ApplyCommand ("/vis/sceneHandler/attach");
359 }
int G4int
Definition: G4Types.hh:78
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:59
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
static Verbosity GetVerbosity()
G4int compareTo(const char *, caseCompare mode=exact) const
#define G4endl
Definition: G4ios.hh:61
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: