Geant4  10.03
G4VisCommandsSceneAdd.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4VisCommandsSceneAdd.cc 98766 2016-08-09 14:17:17Z gcosmo $
28 // /vis/scene/add commands - John Allison 9th August 1998
29 
30 #include "G4VisCommandsSceneAdd.hh"
31 
33 #include "G4LogicalVolumeStore.hh"
34 #include "G4PhysicalVolumeModel.hh"
35 #include "G4LogicalVolumeModel.hh"
36 #include "G4ModelingParameters.hh"
37 #include "G4HitsModel.hh"
38 #include "G4DigiModel.hh"
39 #include "G4MagneticFieldModel.hh"
40 #include "G4PSHitsModel.hh"
41 #include "G4TrajectoriesModel.hh"
42 #include "G4ScaleModel.hh"
43 #include "G4TextModel.hh"
44 #include "G4ArrowModel.hh"
45 #include "G4AxesModel.hh"
47 #include "G4ParticleTable.hh"
48 #include "G4ParticleDefinition.hh"
49 #include "G4ApplicationState.hh"
50 #include "G4VUserVisAction.hh"
51 #include "G4CallbackModel.hh"
52 #include "G4UnionSolid.hh"
53 #include "G4SubtractionSolid.hh"
54 #include "G4Polyhedron.hh"
55 #include "G4UImanager.hh"
56 #include "G4UIcommand.hh"
57 #include "G4UIcmdWithAString.hh"
59 #include "G4UIcmdWithAnInteger.hh"
60 #include "G4Tokenizer.hh"
61 #include "G4RunManager.hh"
62 #ifdef G4MULTITHREADED
63 #include "G4MTRunManager.hh"
64 #endif
65 #include "G4StateManager.hh"
66 #include "G4Run.hh"
67 #include "G4Event.hh"
68 #include "G4Trajectory.hh"
69 #include "G4TrajectoryPoint.hh"
70 #include "G4RichTrajectory.hh"
71 #include "G4RichTrajectoryPoint.hh"
72 #include "G4SmoothTrajectory.hh"
74 #include "G4AttDef.hh"
75 #include "G4AttCheck.hh"
76 #include "G4Polyline.hh"
77 #include "G4UnitsTable.hh"
78 #include "G4PhysicalConstants.hh"
79 #include "G4SystemOfUnits.hh"
80 
81 #include <sstream>
82 
83 // Local function with some frequently used error printing...
86  if (verbosity >= G4VisManager::warnings) {
87  G4cout <<
88  "WARNING: For some reason, possibly mentioned above, it has not been"
89  "\n possible to add to the scene."
90  << G4endl;
91  }
92 }
93 
95 
97  fpCommand = new G4UIcommand("/vis/scene/add/arrow", this);
98  fpCommand -> SetGuidance ("Adds arrow to current scene.");
99  G4bool omitable;
100  G4UIparameter* parameter;
101  parameter = new G4UIparameter ("x1", 'd', omitable = false);
102  fpCommand -> SetParameter (parameter);
103  parameter = new G4UIparameter ("y1", 'd', omitable = false);
104  fpCommand -> SetParameter (parameter);
105  parameter = new G4UIparameter ("z1", 'd', omitable = false);
106  fpCommand -> SetParameter (parameter);
107  parameter = new G4UIparameter ("x2", 'd', omitable = false);
108  fpCommand -> SetParameter (parameter);
109  parameter = new G4UIparameter ("y2", 'd', omitable = false);
110  fpCommand -> SetParameter (parameter);
111  parameter = new G4UIparameter ("z2", 'd', omitable = false);
112  fpCommand -> SetParameter (parameter);
113  parameter = new G4UIparameter ("unit", 's', omitable = true);
114  parameter->SetDefaultValue ("m");
115  fpCommand->SetParameter (parameter);
116 }
117 
119  delete fpCommand;
120 }
121 
123  return "";
124 }
125 
127 {
129  G4bool warn(verbosity >= G4VisManager::warnings);
130 
131  G4Scene* pScene = fpVisManager->GetCurrentScene();
132  if (!pScene) {
133  if (verbosity >= G4VisManager::errors) {
134  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
135  }
136  return;
137  }
138 
139  G4String unitString;
140  G4double x1, y1, z1, x2, y2, z2;
141  std::istringstream is(newValue);
142  is >> x1 >> y1 >> z1 >> x2 >> y2 >> z2 >> unitString;
143  G4double unit = G4UIcommand::ValueOf(unitString);
144  x1 *= unit; y1 *= unit; z1 *= unit;
145  x2 *= unit; y2 *= unit; z2 *= unit;
146 
147  // Consult scene for arrow width.
148  const G4VisExtent& sceneExtent = pScene->GetExtent();
149  G4double arrowWidth =
150  0.005 * fCurrentLineWidth * sceneExtent.GetExtentRadius();
151 
152  G4VModel* model = new G4ArrowModel
153  (x1, y1, z1, x2, y2, z2,
154  arrowWidth, fCurrentColour, newValue);
155 
156  const G4String& currentSceneName = pScene -> GetName ();
157  G4bool successful = pScene -> AddRunDurationModel (model, warn);
158  if (successful) {
159  if (verbosity >= G4VisManager::confirmations) {
160  G4cout << "Arrow has been added to scene \""
161  << currentSceneName << "\"."
162  << G4endl;
163  }
164  }
165  else G4VisCommandsSceneAddUnsuccessful(verbosity);
166  UpdateVisManagerScene (currentSceneName);
167 }
168 
170 
172  fpCommand = new G4UIcommand("/vis/scene/add/arrow2D", this);
173  fpCommand -> SetGuidance ("Adds 2D arrow to current scene.");
174  G4bool omitable;
175  G4UIparameter* parameter;
176  parameter = new G4UIparameter ("x1", 'd', omitable = false);
177  fpCommand -> SetParameter (parameter);
178  parameter = new G4UIparameter ("y1", 'd', omitable = false);
179  fpCommand -> SetParameter (parameter);
180  parameter = new G4UIparameter ("x2", 'd', omitable = false);
181  fpCommand -> SetParameter (parameter);
182  parameter = new G4UIparameter ("y2", 'd', omitable = false);
183  fpCommand -> SetParameter (parameter);
184 }
185 
187  delete fpCommand;
188 }
189 
191  return "";
192 }
193 
195 {
197  G4bool warn(verbosity >= G4VisManager::warnings);
198 
199  G4Scene* pScene = fpVisManager->GetCurrentScene();
200  if (!pScene) {
201  if (verbosity >= G4VisManager::errors) {
202  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
203  }
204  return;
205  }
206 
207  G4double x1, y1, x2, y2;
208  std::istringstream is(newValue);
209  is >> x1 >> y1 >> x2 >> y2;
210 
211  Arrow2D* arrow2D = new Arrow2D
212  (x1, y1, x2, y2, fCurrentLineWidth, fCurrentColour);
213  G4VModel* model =
215  model->SetType("Arrow2D");
216  model->SetGlobalTag("Arrow2D");
217  model->SetGlobalDescription("Arrow2D: " + newValue);
218  const G4String& currentSceneName = pScene -> GetName ();
219  G4bool successful = pScene -> AddRunDurationModel (model, warn);
220  if (successful) {
221  if (verbosity >= G4VisManager::confirmations) {
222  G4cout << "A 2D arrow has been added to scene \""
223  << currentSceneName << "\"."
224  << G4endl;
225  }
226  }
227  else G4VisCommandsSceneAddUnsuccessful(verbosity);
228  UpdateVisManagerScene (currentSceneName);
229 }
230 
233  G4double x2, G4double y2,
234  G4double width, const G4Colour& colour):
235  fWidth(width), fColour(colour)
236 {
237  fShaftPolyline.push_back(G4Point3D(x1,y1,0));
238  fShaftPolyline.push_back(G4Point3D(x2,y2,0));
239  G4Vector3D arrowDirection = G4Vector3D(x2-x1,y2-y1,0).unit();
240  G4Vector3D arrowPointLeftDirection(arrowDirection);
241  arrowPointLeftDirection.rotateZ(150.*deg);
242  G4Vector3D arrowPointRightDirection(arrowDirection);
243  arrowPointRightDirection.rotateZ(-150.*deg);
244  fHeadPolyline.push_back(G4Point3D(x2,y2,0)+0.04*arrowPointLeftDirection);
245  fHeadPolyline.push_back(G4Point3D(x2,y2,0));
246  fHeadPolyline.push_back(G4Point3D(x2,y2,0)+0.04*arrowPointRightDirection);
247  G4VisAttributes va;
248  va.SetLineWidth(fWidth);
249  va.SetColour(fColour);
250  fShaftPolyline.SetVisAttributes(va);
251  fHeadPolyline.SetVisAttributes(va);
252 }
253 
254 void G4VisCommandSceneAddArrow2D::Arrow2D::operator()
255  (G4VGraphicsScene& sceneHandler, const G4Transform3D&)
256 {
257  sceneHandler.BeginPrimitives2D();
258  sceneHandler.AddPrimitive(fShaftPolyline);
259  sceneHandler.AddPrimitive(fHeadPolyline);
260  sceneHandler.EndPrimitives2D();
261 }
262 
264 
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 }
303 
305  delete fpCommand;
306 }
307 
309  return "";
310 }
311 
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 }
377 
379 
381  G4bool omitable;
382  fpCommand = new G4UIcommand ("/vis/scene/add/date", this);
383  fpCommand -> SetGuidance ("Adds date to current scene.");
384  fpCommand -> SetGuidance
385  ("If \"date\"is omitted, the current date and time is drawn."
386  "\nOtherwise, the string, including the rest of the line, is drawn.");
387  G4UIparameter* parameter;
388  parameter = new G4UIparameter ("size", 'i', omitable = true);
389  parameter -> SetGuidance ("Screen size of text in pixels.");
390  parameter -> SetDefaultValue (18);
391  fpCommand -> SetParameter (parameter);
392  parameter = new G4UIparameter ("x-position", 'd', omitable = true);
393  parameter -> SetGuidance ("x screen position in range -1 < x < 1.");
394  parameter -> SetDefaultValue (0.95);
395  fpCommand -> SetParameter (parameter);
396  parameter = new G4UIparameter ("y-position", 'd', omitable = true);
397  parameter -> SetGuidance ("y screen position in range -1 < y < 1.");
398  parameter -> SetDefaultValue (0.9);
399  fpCommand -> SetParameter (parameter);
400  parameter = new G4UIparameter ("layout", 's', omitable = true);
401  parameter -> SetGuidance ("Layout, i.e., adjustment: left|centre|right.");
402  parameter -> SetDefaultValue ("right");
403  fpCommand -> SetParameter (parameter);
404  parameter = new G4UIparameter ("date", 's', omitable = true);
405  parameter -> SetDefaultValue ("-");
406  fpCommand -> SetParameter (parameter);
407 }
408 
410  delete fpCommand;
411 }
412 
414  return "";
415 }
416 
418 {
420  G4bool warn(verbosity >= G4VisManager::warnings);
421 
422  G4Scene* pScene = fpVisManager->GetCurrentScene();
423  if (!pScene) {
424  if (verbosity >= G4VisManager::errors) {
425  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
426  }
427  return;
428  }
429 
430  G4int size;
431  G4double x, y;
432  G4String layoutString, dateString;
433  std::istringstream is(newValue);
434  is >> size >> x >> y >> layoutString >> dateString;
435  // Read rest of line, if any.
436  const size_t NREMAINDER = 100;
437  char remainder[NREMAINDER];
438  remainder[0]='\0'; // In case there is nothing remaining.
439  is.getline(remainder, NREMAINDER);
440  dateString += remainder;
441  G4Text::Layout layout = G4Text::right;
442  if (layoutString(0) == 'l') layout = G4Text::left;
443  else if (layoutString(0) == 'c') layout = G4Text::centre;
444  else if (layoutString(0) == 'r') layout = G4Text::right;
445 
446  Date* date = new Date(fpVisManager, size, x, y, layout, dateString);
447  G4VModel* model =
449  model->SetType("Date");
450  model->SetGlobalTag("Date");
451  model->SetGlobalDescription("Date");
452  const G4String& currentSceneName = pScene -> GetName ();
453  G4bool successful = pScene -> AddRunDurationModel (model, warn);
454  if (successful) {
455  if (verbosity >= G4VisManager::confirmations) {
456  G4cout << "Date has been added to scene \""
457  << currentSceneName << "\"."
458  << G4endl;
459  }
460  }
461  else G4VisCommandsSceneAddUnsuccessful(verbosity);
462  UpdateVisManagerScene (currentSceneName);
463 }
464 
465 void G4VisCommandSceneAddDate::Date::operator()
466  (G4VGraphicsScene& sceneHandler, const G4Transform3D&)
467 {
468  G4String time;
469  if (fDate == "-") {
470  time = fTimer.GetClockTime();
471  } else {
472  time = fDate;
473  }
474  // Check for \n, starting from back, and erase.
475  std::string::size_type i = time.rfind('\n');
476  if (i != std::string::npos) time.erase(i);
477  G4Text text(time, G4Point3D(fX, fY, 0.));
478  text.SetScreenSize(fSize);
479  text.SetLayout(fLayout);
480  G4VisAttributes textAtts(G4Colour(0.,1.,1));
481  text.SetVisAttributes(textAtts);
482  sceneHandler.BeginPrimitives2D();
483  sceneHandler.AddPrimitive(text);
484  sceneHandler.EndPrimitives2D();
485 }
486 
488 
490  fpCommand = new G4UIcmdWithoutParameter ("/vis/scene/add/digis", this);
491  fpCommand -> SetGuidance ("Adds digis to current scene.");
492  fpCommand -> SetGuidance
493  ("Digis are drawn at end of event when the scene in which"
494  "\nthey are added is current.");
495 }
496 
498  delete fpCommand;
499 }
500 
502  return "";
503 }
504 
506 
508  G4bool warn(verbosity >= G4VisManager::warnings);
509 
510  G4Scene* pScene = fpVisManager->GetCurrentScene();
511  if (!pScene) {
512  if (verbosity >= G4VisManager::errors) {
513  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
514  }
515  return;
516  }
517 
518  G4DigiModel* model = new G4DigiModel;
519  const G4String& currentSceneName = pScene -> GetName ();
520  G4bool successful = pScene -> AddEndOfEventModel (model, warn);
521  if (successful) {
522  if (verbosity >= G4VisManager::confirmations) {
523  G4cout << "Digis, if any, will be drawn at end of run in scene \""
524  << currentSceneName << "\"."
525  << G4endl;
526  }
527  }
528  else G4VisCommandsSceneAddUnsuccessful(verbosity);
529  UpdateVisManagerScene (currentSceneName);
530 }
531 
533 
535  G4bool omitable;
536  fpCommand = new G4UIcommand ("/vis/scene/add/eventID", this);
537  fpCommand -> SetGuidance ("Adds eventID to current scene.");
538  fpCommand -> SetGuidance
539  ("Run and event numbers are drawn at end of event or run when"
540  "\n the scene in which they are added is current.");
541  G4UIparameter* parameter;
542  parameter = new G4UIparameter ("size", 'i', omitable = true);
543  parameter -> SetGuidance ("Screen size of text in pixels.");
544  parameter -> SetDefaultValue (18);
545  fpCommand -> SetParameter (parameter);
546  parameter = new G4UIparameter ("x-position", 'd', omitable = true);
547  parameter -> SetGuidance ("x screen position in range -1 < x < 1.");
548  parameter -> SetDefaultValue (-0.95);
549  fpCommand -> SetParameter (parameter);
550  parameter = new G4UIparameter ("y-position", 'd', omitable = true);
551  parameter -> SetGuidance ("y screen position in range -1 < y < 1.");
552  parameter -> SetDefaultValue (0.9);
553  fpCommand -> SetParameter (parameter);
554  parameter = new G4UIparameter ("layout", 's', omitable = true);
555  parameter -> SetGuidance ("Layout, i.e., adjustment: left|centre|right.");
556  parameter -> SetDefaultValue ("left");
557  fpCommand -> SetParameter (parameter);
558 }
559 
561  delete fpCommand;
562 }
563 
565  return "";
566 }
567 
569 {
571  G4bool warn(verbosity >= G4VisManager::warnings);
572 
573  G4Scene* pScene = fpVisManager->GetCurrentScene();
574  if (!pScene) {
575  if (verbosity >= G4VisManager::errors) {
576  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
577  }
578  return;
579  }
580 
581  G4int size;
582  G4double x, y;
583  G4String layoutString;
584  std::istringstream is(newValue);
585  is >> size >> x >> y >> layoutString;
586 
587  G4Text::Layout layout = G4Text::right;
588  if (layoutString(0) == 'l') layout = G4Text::left;
589  else if (layoutString(0) == 'c') layout = G4Text::centre;
590  else if (layoutString(0) == 'r') layout = G4Text::right;
591 
592  EventID* eventID = new EventID(fpVisManager, size, x, y, layout);
593  G4VModel* model =
595  model->SetType("EventID");
596  model->SetGlobalTag("EventID");
597  model->SetGlobalDescription("EventID");
598  const G4String& currentSceneName = pScene -> GetName ();
599  G4bool successful = pScene -> AddEndOfEventModel (model, warn);
600  if (successful) {
601  if (verbosity >= G4VisManager::confirmations) {
602  G4cout << "EventID has been added to scene \""
603  << currentSceneName << "\"."
604  << G4endl;
605  }
606  }
607  else G4VisCommandsSceneAddUnsuccessful(verbosity);
608  UpdateVisManagerScene (currentSceneName);
609 }
610 
611 void G4VisCommandSceneAddEventID::EventID::operator()
612  (G4VGraphicsScene& sceneHandler, const G4Transform3D&)
613 {
614  const G4Run* currentRun = 0;
616 #ifdef G4MULTITHREADED
619  }
620 #endif
621  if (runManager) currentRun = runManager->GetCurrentRun();
622 
623  G4VModel* model = fpVisManager->GetCurrentSceneHandler()->GetModel();
624  const G4ModelingParameters* mp = 0;
625  const G4Event* currentEvent = 0;
626  if (model) {
627  mp = model->GetModelingParameters();
628  currentEvent = mp->GetEvent();
629  } else {
630  G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
631  if (verbosity >= G4VisManager::errors) {
632  G4cerr << "ERROR: No model defined for this SceneHandler : "
633  << fpVisManager->GetCurrentSceneHandler()->GetName()
634  << G4endl;
635  }
636  }
637  if (currentRun && currentEvent) {
638  G4int runID = currentRun->GetRunID();
639  G4int eventID = currentEvent->GetEventID();
640  std::ostringstream oss;
641  if (fpVisManager->GetCurrentScene()->GetRefreshAtEndOfEvent()) {
642  oss << "Run " << runID << " Event " << eventID;
643  } else {
644  G4int nEvents = 0;
645 #ifdef G4MULTITHREADED
647  // Vis sub-thread - run in progress
648 #else
650  G4ApplicationState state = stateManager->GetCurrentState();
651  if (state == G4State_EventProc) {
652  // Run in progress
653 #endif
654  nEvents = currentRun->GetNumberOfEventToBeProcessed();
655  } else {
656  // Rebuilding from kept events
657  const std::vector<const G4Event*>* events =
658  currentRun->GetEventVector();
659  if (events) nEvents = events->size();
660  }
661 #ifndef G4MULTITHREADED
662  // In sequential mode we can recognise the last event and avoid
663  // drawing the event ID. But for MT mode there is no way of
664  // knowing so we have to accept that the event ID will be drawn
665  // at each event, the same characters over and over - but hey!
666  if (eventID < nEvents - 1) return; // Not last event.
667 #endif
668  oss << "Run " << runID << " (" << nEvents << " event";
669  if (nEvents != 1) oss << 's';
670  oss << ')';
671  }
672  G4Text text(oss.str(), G4Point3D(fX, fY, 0.));
673  text.SetScreenSize(fSize);
674  text.SetLayout(fLayout);
675  G4VisAttributes textAtts(G4Colour(0.,1.,1));
676  text.SetVisAttributes(textAtts);
677  sceneHandler.BeginPrimitives2D();
678  sceneHandler.AddPrimitive(text);
679  sceneHandler.EndPrimitives2D();
680  }
681 }
682 
684 
686  fpCommand = new G4UIcommand("/vis/scene/add/extent", this);
687  fpCommand -> SetGuidance
688  ("Adds a dummy model with given extent to the current scene."
689  "\nRequires the limits: xmin, xmax, ymin, ymax, zmin, zmax unit."
690  "\nThis can be used to provide an extent to the scene even if"
691  "\nno other models with extent are available. For example,"
692  "\neven if there is no geometry. In that case, for example:"
693  "\n /vis/open OGL"
694  "\n /vis/scene/create"
695  "\n /vis/scene/add/extent -300 300 -300 300 -300 300 cm"
696  "\n /vis/sceneHandler/attach");
697  G4bool omitable;
698  G4UIparameter* parameter;
699  parameter = new G4UIparameter ("xmin", 'd', omitable = true);
700  parameter -> SetDefaultValue (0.);
701  fpCommand -> SetParameter (parameter);
702  parameter = new G4UIparameter ("xmax", 'd', omitable = true);
703  parameter -> SetDefaultValue (0.);
704  fpCommand -> SetParameter (parameter);
705  parameter = new G4UIparameter ("ymin", 'd', omitable = true);
706  parameter -> SetDefaultValue (0.);
707  fpCommand -> SetParameter (parameter);
708  parameter = new G4UIparameter ("ymax", 'd', omitable = true);
709  parameter -> SetDefaultValue (0.);
710  fpCommand -> SetParameter (parameter);
711  parameter = new G4UIparameter ("zmin", 'd', omitable = true);
712  parameter -> SetDefaultValue (0.);
713  fpCommand -> SetParameter (parameter);
714  parameter = new G4UIparameter ("zmax", 'd', omitable = true);
715  parameter -> SetDefaultValue (0.);
716  fpCommand -> SetParameter (parameter);
717  parameter = new G4UIparameter ("unit", 's', omitable = true);
718  parameter -> SetDefaultValue ("m");
719  fpCommand -> SetParameter (parameter);
720 }
721 
723  delete fpCommand;
724 }
725 
727  return "";
728 }
729 
731 {
733  G4bool warn(verbosity >= G4VisManager::warnings);
734 
735  G4Scene* pScene = fpVisManager->GetCurrentScene();
736  if (!pScene) {
737  if (verbosity >= G4VisManager::errors) {
738  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
739  }
740  return;
741  }
742 
743  G4double xmin, xmax, ymin, ymax, zmin, zmax;
744  G4String unitString;
745  std::istringstream is(newValue);
746  is >> xmin >> xmax >> ymin >> ymax >> zmin >> zmax >> unitString;
747  G4double unit = G4UIcommand::ValueOf(unitString);
748  xmin *= unit; xmax *= unit;
749  ymin *= unit; ymax *= unit;
750  zmin *= unit; zmax *= unit;
751 
752  G4VisExtent visExtent(xmin, xmax, ymin, ymax, zmin, zmax);
753  Extent* extent = new Extent(xmin, xmax, ymin, ymax, zmin, zmax);
754  G4VModel* model =
756  model->SetType("Extent");
757  model->SetGlobalTag("Extent");
758  model->SetGlobalDescription("Extent: " + newValue);
759  model->SetExtent(visExtent);
760  const G4String& currentSceneName = pScene -> GetName ();
761  G4bool successful = pScene -> AddRunDurationModel (model, warn);
762  if (successful) {
763  if (verbosity >= G4VisManager::confirmations) {
764  G4cout << "A benign model with extent "
765  << visExtent
766  << " has been added to scene \""
767  << currentSceneName << "\"."
768  << G4endl;
769  }
770  }
771  else G4VisCommandsSceneAddUnsuccessful(verbosity);
772  UpdateVisManagerScene (currentSceneName);
773 }
774 
776 (G4double xmin, G4double xmax,
777  G4double ymin, G4double ymax,
778  G4double zmin, G4double zmax):
779 fExtent(xmin,xmax,ymin,ymax,zmin,zmax)
780 {}
781 
782 void G4VisCommandSceneAddExtent::Extent::operator()
784 {}
785 
787 
789  fpCommand = new G4UIcommand("/vis/scene/add/frame", this);
790  fpCommand -> SetGuidance ("Adds frame to current scene.");
791  G4bool omitable;
792  G4UIparameter* parameter;
793  parameter = new G4UIparameter ("size", 'd', omitable = true);
794  parameter -> SetGuidance ("Size of frame. 1 = full window.");
795  parameter -> SetParameterRange ("size > 0 && size <=1");
796  parameter -> SetDefaultValue (0.97);
797  fpCommand -> SetParameter (parameter);
798 }
799 
801  delete fpCommand;
802 }
803 
805  return "";
806 }
807 
809 {
811  G4bool warn(verbosity >= G4VisManager::warnings);
812 
813  G4Scene* pScene = fpVisManager->GetCurrentScene();
814  if (!pScene) {
815  if (verbosity >= G4VisManager::errors) {
816  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
817  }
818  return;
819  }
820 
821  G4double size;
822  std::istringstream is(newValue);
823  is >> size;
824 
825  Frame* frame = new Frame(size, fCurrentLineWidth, fCurrentColour);
826  G4VModel* model =
828  model->SetType("Frame");
829  model->SetGlobalTag("Frame");
830  model->SetGlobalDescription("Frame: " + newValue);
831  const G4String& currentSceneName = pScene -> GetName ();
832  G4bool successful = pScene -> AddRunDurationModel (model, warn);
833  if (successful) {
834  if (verbosity >= G4VisManager::confirmations) {
835  G4cout << "Frame has been added to scene \""
836  << currentSceneName << "\"."
837  << G4endl;
838  }
839  }
840  else G4VisCommandsSceneAddUnsuccessful(verbosity);
841  UpdateVisManagerScene (currentSceneName);
842 }
843 
844 void G4VisCommandSceneAddFrame::Frame::operator()
845  (G4VGraphicsScene& sceneHandler, const G4Transform3D&)
846 {
847  G4Polyline frame;
848  frame.push_back(G4Point3D( fSize, fSize, 0.));
849  frame.push_back(G4Point3D(-fSize, fSize, 0.));
850  frame.push_back(G4Point3D(-fSize, -fSize, 0.));
851  frame.push_back(G4Point3D( fSize, -fSize, 0.));
852  frame.push_back(G4Point3D( fSize, fSize, 0.));
853  G4VisAttributes va;
854  va.SetLineWidth(fWidth);
855  va.SetColour(fColour);
856  frame.SetVisAttributes(va);
857  sceneHandler.BeginPrimitives2D();
858  sceneHandler.AddPrimitive(frame);
859  sceneHandler.EndPrimitives2D();
860 }
861 
863 
865  fpCommand = new G4UIcmdWithoutParameter ("/vis/scene/add/hits", this);
866  fpCommand -> SetGuidance ("Adds hits to current scene.");
867  fpCommand -> SetGuidance
868  ("Hits are drawn at end of event when the scene in which"
869  "\nthey are added is current.");
870 }
871 
873  delete fpCommand;
874 }
875 
877  return "";
878 }
879 
881 
883  G4bool warn(verbosity >= G4VisManager::warnings);
884 
885  G4Scene* pScene = fpVisManager->GetCurrentScene();
886  if (!pScene) {
887  if (verbosity >= G4VisManager::errors) {
888  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
889  }
890  return;
891  }
892 
893  G4HitsModel* model = new G4HitsModel;
894  const G4String& currentSceneName = pScene -> GetName ();
895  G4bool successful = pScene -> AddEndOfEventModel (model, warn);
896  if (successful) {
897  if (verbosity >= G4VisManager::confirmations) {
898  G4cout << "Hits, if any, will be drawn at end of run in scene \""
899  << currentSceneName << "\"."
900  << G4endl;
901  }
902  }
903  else G4VisCommandsSceneAddUnsuccessful(verbosity);
904  UpdateVisManagerScene (currentSceneName);
905 }
906 
908 
910  fpCommand = new G4UIcommand("/vis/scene/add/line", this);
911  fpCommand -> SetGuidance ("Adds line to current scene.");
912  G4bool omitable;
913  G4UIparameter* parameter;
914  parameter = new G4UIparameter ("x1", 'd', omitable = false);
915  fpCommand -> SetParameter (parameter);
916  parameter = new G4UIparameter ("y1", 'd', omitable = false);
917  fpCommand -> SetParameter (parameter);
918  parameter = new G4UIparameter ("z1", 'd', omitable = false);
919  fpCommand -> SetParameter (parameter);
920  parameter = new G4UIparameter ("x2", 'd', omitable = false);
921  fpCommand -> SetParameter (parameter);
922  parameter = new G4UIparameter ("y2", 'd', omitable = false);
923  fpCommand -> SetParameter (parameter);
924  parameter = new G4UIparameter ("z2", 'd', omitable = false);
925  fpCommand -> SetParameter (parameter);
926  parameter = new G4UIparameter ("unit", 's', omitable = true);
927  parameter->SetDefaultValue ("m");
928  fpCommand->SetParameter (parameter);
929 }
930 
932  delete fpCommand;
933 }
934 
936  return "";
937 }
938 
940 {
942  G4bool warn(verbosity >= G4VisManager::warnings);
943 
944  G4Scene* pScene = fpVisManager->GetCurrentScene();
945  if (!pScene) {
946  if (verbosity >= G4VisManager::errors) {
947  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
948  }
949  return;
950  }
951 
952  G4String unitString;
953  G4double x1, y1, z1, x2, y2, z2;
954  std::istringstream is(newValue);
955  is >> x1 >> y1 >> z1 >> x2 >> y2 >> z2 >> unitString;
956  G4double unit = G4UIcommand::ValueOf(unitString);
957  x1 *= unit; y1 *= unit; z1 *= unit;
958  x2 *= unit; y2 *= unit; z2 *= unit;
959 
960  Line* line = new Line(x1, y1, z1, x2, y2, z2,
962  G4VModel* model =
964  model->SetType("Line");
965  model->SetGlobalTag("Line");
966  model->SetGlobalDescription("Line: " + newValue);
967  const G4String& currentSceneName = pScene -> GetName ();
968  G4bool successful = pScene -> AddRunDurationModel (model, warn);
969  if (successful) {
970  if (verbosity >= G4VisManager::confirmations) {
971  G4cout << "Line has been added to scene \""
972  << currentSceneName << "\"."
973  << G4endl;
974  }
975  }
976  else G4VisCommandsSceneAddUnsuccessful(verbosity);
977  UpdateVisManagerScene (currentSceneName);
978 }
979 
982  G4double x2, G4double y2, G4double z2,
983  G4double width, const G4Colour& colour):
984  fWidth(width), fColour(colour)
985 {
986  fPolyline.push_back(G4Point3D(x1,y1,z1));
987  fPolyline.push_back(G4Point3D(x2,y2,z2));
988  G4VisAttributes va;
989  va.SetLineWidth(fWidth);
990  va.SetColour(fColour);
991  fPolyline.SetVisAttributes(va);
992 }
993 
994 void G4VisCommandSceneAddLine::Line::operator()
995  (G4VGraphicsScene& sceneHandler, const G4Transform3D&)
996 {
997  sceneHandler.BeginPrimitives();
998  sceneHandler.AddPrimitive(fPolyline);
999  sceneHandler.EndPrimitives();
1000 }
1001 
1003 
1005  fpCommand = new G4UIcommand("/vis/scene/add/line2D", this);
1006  fpCommand -> SetGuidance ("Adds 2D line to current scene.");
1007  G4bool omitable;
1008  G4UIparameter* parameter;
1009  parameter = new G4UIparameter ("x1", 'd', omitable = false);
1010  fpCommand -> SetParameter (parameter);
1011  parameter = new G4UIparameter ("y1", 'd', omitable = false);
1012  fpCommand -> SetParameter (parameter);
1013  parameter = new G4UIparameter ("x2", 'd', omitable = false);
1014  fpCommand -> SetParameter (parameter);
1015  parameter = new G4UIparameter ("y2", 'd', omitable = false);
1016  fpCommand -> SetParameter (parameter);
1017 }
1018 
1020  delete fpCommand;
1021 }
1022 
1024  return "";
1025 }
1026 
1028 {
1030  G4bool warn(verbosity >= G4VisManager::warnings);
1031 
1032  G4Scene* pScene = fpVisManager->GetCurrentScene();
1033  if (!pScene) {
1034  if (verbosity >= G4VisManager::errors) {
1035  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
1036  }
1037  return;
1038  }
1039 
1040  G4double x1, y1, x2, y2;
1041  std::istringstream is(newValue);
1042  is >> x1 >> y1 >> x2 >> y2;
1043 
1044  Line2D* line2D = new Line2D
1045  (x1, y1, x2, y2, fCurrentLineWidth, fCurrentColour);
1046  G4VModel* model =
1048  model->SetType("Line2D");
1049  model->SetGlobalTag("Line2D");
1050  model->SetGlobalDescription("Line2D: " + newValue);
1051  const G4String& currentSceneName = pScene -> GetName ();
1052  G4bool successful = pScene -> AddRunDurationModel (model, warn);
1053  if (successful) {
1054  if (verbosity >= G4VisManager::confirmations) {
1055  G4cout << "A 2D line has been added to scene \""
1056  << currentSceneName << "\"."
1057  << G4endl;
1058  }
1059  }
1060  else G4VisCommandsSceneAddUnsuccessful(verbosity);
1061  UpdateVisManagerScene (currentSceneName);
1062 }
1063 
1066  G4double x2, G4double y2,
1067  G4double width, const G4Colour& colour):
1068  fWidth(width), fColour(colour)
1069 {
1070  fPolyline.push_back(G4Point3D(x1,y1,0));
1071  fPolyline.push_back(G4Point3D(x2,y2,0));
1072  G4VisAttributes va;
1073  va.SetLineWidth(fWidth);
1074  va.SetColour(fColour);
1075  fPolyline.SetVisAttributes(va);
1076 }
1077 
1078 void G4VisCommandSceneAddLine2D::Line2D::operator()
1079  (G4VGraphicsScene& sceneHandler, const G4Transform3D&)
1080 {
1081  sceneHandler.BeginPrimitives2D();
1082  sceneHandler.AddPrimitive(fPolyline);
1083  sceneHandler.EndPrimitives2D();
1084 }
1085 
1087 
1089  G4bool omitable;
1090  fpCommand = new G4UIcommand ("/vis/scene/add/logicalVolume", this);
1091  fpCommand -> SetGuidance ("Adds a logical volume to the current scene,");
1092  fpCommand -> SetGuidance
1093  ("Shows boolean components (if any), voxels (if any), readout geometry"
1094  "\n (if any) and local axes, under control of the appropriate flag."
1095  "\n Note: voxels are not constructed until start of run -"
1096  "\n \"/run/beamOn\". (For voxels without a run, \"/run/beamOn 0\".)");
1097  G4UIparameter* parameter;
1098  parameter = new G4UIparameter ("logical-volume-name", 's', omitable = false);
1099  fpCommand -> SetParameter (parameter);
1100  parameter = new G4UIparameter ("depth-of-descent", 'i', omitable = true);
1101  parameter -> SetGuidance ("Depth of descent of geometry hierarchy.");
1102  parameter -> SetDefaultValue (1);
1103  fpCommand -> SetParameter (parameter);
1104  parameter = new G4UIparameter ("booleans-flag", 'b', omitable = true);
1105  parameter -> SetDefaultValue (true);
1106  fpCommand -> SetParameter (parameter);
1107  parameter = new G4UIparameter ("voxels-flag", 'b', omitable = true);
1108  parameter -> SetDefaultValue (true);
1109  fpCommand -> SetParameter (parameter);
1110  parameter = new G4UIparameter ("readout-flag", 'b', omitable = true);
1111  parameter -> SetDefaultValue (true);
1112  fpCommand -> SetParameter (parameter);
1113  parameter = new G4UIparameter ("axes-flag", 'b', omitable = true);
1114  parameter -> SetDefaultValue (true);
1115  parameter -> SetGuidance ("Set \"false\" to suppress axes.");
1116  fpCommand -> SetParameter (parameter);
1117 }
1118 
1120  delete fpCommand;
1121 }
1122 
1124  return "";
1125 }
1126 
1128  G4String newValue) {
1129 
1131  G4bool warn(verbosity >= G4VisManager::warnings);
1132 
1133  G4Scene* pScene = fpVisManager->GetCurrentScene();
1134  if (!pScene) {
1135  if (verbosity >= G4VisManager::errors) {
1136  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
1137  }
1138  return;
1139  }
1140 
1141  G4String name;
1142  G4int requestedDepthOfDescent;
1143  G4String booleansString, voxelsString, readoutString, axesString;
1144  std::istringstream is (newValue);
1145  is >> name >> requestedDepthOfDescent
1146  >> booleansString >> voxelsString >> readoutString >> axesString;
1147  G4bool booleans = G4UIcommand::ConvertToBool(booleansString);
1148  G4bool voxels = G4UIcommand::ConvertToBool(voxelsString);
1149  G4bool readout = G4UIcommand::ConvertToBool(readoutString);
1150  G4bool axes = G4UIcommand::ConvertToBool(axesString);
1151 
1153  int nLV = pLVStore -> size ();
1154  int iLV;
1155  G4LogicalVolume* pLV = 0;
1156  for (iLV = 0; iLV < nLV; iLV++ ) {
1157  pLV = (*pLVStore) [iLV];
1158  if (pLV -> GetName () == name) break;
1159  }
1160  if (iLV == nLV) {
1161  if (verbosity >= G4VisManager::errors) {
1162  G4cerr << "ERROR: Logical volume " << name
1163  << " not found in logical volume store." << G4endl;
1164  }
1165  return;
1166  }
1167 
1168  const std::vector<G4Scene::Model>& rdModelList =
1169  pScene -> GetRunDurationModelList();
1170  std::vector<G4Scene::Model>::const_iterator i;
1171  for (i = rdModelList.begin(); i != rdModelList.end(); ++i) {
1172  if (i->fpModel->GetGlobalDescription().find("Volume") != std::string::npos) break;
1173  }
1174  if (i != rdModelList.end()) {
1175  if (verbosity >= G4VisManager::errors) {
1176  G4cout << "There is already a volume, \""
1177  << i->fpModel->GetGlobalDescription()
1178  << "\",\n in the run-duration model list of scene \""
1179  << pScene -> GetName()
1180  << "\".\n Your logical volume must be the only volume in the scene."
1181  << "\n Create a new scene and try again:"
1182  << "\n /vis/specify " << name
1183  << "\n or"
1184  << "\n /vis/scene/create"
1185  << "\n /vis/scene/add/logicalVolume " << name
1186  << "\n /vis/sceneHandler/attach"
1187  << "\n (and also, if necessary, /vis/viewer/flush)"
1188  << G4endl;
1189  }
1190  return;
1191  }
1192 
1194  (pLV, requestedDepthOfDescent, booleans, voxels, readout);
1195  const G4String& currentSceneName = pScene -> GetName ();
1196  G4bool successful = pScene -> AddRunDurationModel (model, warn);
1197 
1198  if (successful) {
1199 
1200  G4bool axesSuccessful = false;
1201  if (axes) {
1202  const G4double radius = model->GetExtent().GetExtentRadius();
1203  const G4double axisLengthMax = radius / 2.;
1204  const G4double intLog10Length = std::floor(std::log10(axisLengthMax));
1205  G4double axisLength = std::pow(10,intLog10Length);
1206  if (5.*axisLength < axisLengthMax) axisLength *= 5.;
1207  else if (2.*axisLength < axisLengthMax) axisLength *= 2.;
1208  const G4double axisWidth = axisLength / 20.;
1209  G4VModel* axesModel = new G4AxesModel(0.,0.,0.,axisLength,axisWidth);
1210  axesSuccessful = pScene -> AddRunDurationModel (axesModel, warn);
1211  }
1212 
1213 // if (verbosity >= G4VisManager::warnings) {
1214 // const std::map<G4String,G4AttDef>* attDefs = model->GetAttDefs();
1215 // std::vector<G4AttValue>* attValues = model->CreateCurrentAttValues();
1216 // G4cout << G4AttCheck(attValues, attDefs);
1217 // delete attValues;
1218 // }
1219 
1220  if (verbosity >= G4VisManager::confirmations) {
1221  G4cout << "Logical volume \"" << pLV -> GetName ()
1222  << " with requested depth of descent "
1223  << requestedDepthOfDescent
1224  << ",\n with";
1225  if (!booleans) G4cout << "out";
1226  G4cout << " boolean components, with";
1227  if (!voxels) G4cout << "out";
1228  G4cout << " voxels and with";
1229  if (!readout) G4cout << "out";
1230  G4cout << " readout geometry,"
1231  << "\n has been added to scene \"" << currentSceneName << "\".";
1232  if (axes) {
1233  if (axesSuccessful) {
1234  G4cout <<
1235  "\n Axes have also been added at the origin of local cooordinates.";
1236  } else {
1237  G4cout <<
1238  "\n Axes have not been added for some reason possibly stated above.";
1239  }
1240  }
1241  G4cout << G4endl;
1242  }
1243  }
1244  else {
1246  return;
1247  }
1248 
1249  UpdateVisManagerScene (currentSceneName);
1250 }
1251 
1252 
1254 
1256  G4bool omitable;
1257  fpCommand = new G4UIcommand ("/vis/scene/add/logo", this);
1258  fpCommand -> SetGuidance ("Adds a G4 logo to the current scene.");
1259  fpCommand -> SetGuidance
1260  ("If \"unit\" is \"auto\", height is roughly one tenth of scene extent.");
1261  fpCommand -> SetGuidance
1262  ("\"direction\" is that of outward-facing normal to front face of logo."
1263  "\nIf \"direction\" is \"auto\", logo faces the user in the current viewer.");
1264  fpCommand -> SetGuidance
1265  ("\nIf \"placement\" is \"auto\", logo is placed at bottom right of screen"
1266  "\n when viewed from logo direction.");
1267  G4UIparameter* parameter;
1268  parameter = new G4UIparameter ("height", 'd', omitable = true);
1269  parameter->SetDefaultValue (1.);
1270  fpCommand->SetParameter (parameter);
1271  parameter = new G4UIparameter ("unit", 's', omitable = true);
1272  parameter->SetDefaultValue ("auto");
1273  fpCommand->SetParameter (parameter);
1274  parameter = new G4UIparameter ("direction", 's', omitable = true);
1275  parameter->SetGuidance ("auto|[-]x|[-]y|[-]z");
1276  parameter->SetDefaultValue ("auto");
1277  fpCommand->SetParameter (parameter);
1278  parameter = new G4UIparameter ("red", 'd', omitable = true);
1279  parameter->SetDefaultValue (0.);
1280  fpCommand->SetParameter (parameter);
1281  parameter = new G4UIparameter ("green", 'd', omitable = true);
1282  parameter->SetDefaultValue (1.);
1283  fpCommand->SetParameter (parameter);
1284  parameter = new G4UIparameter ("blue", 'd', omitable = true);
1285  parameter->SetDefaultValue (0.);
1286  fpCommand->SetParameter (parameter);
1287  parameter = new G4UIparameter ("placement", 's', omitable = true);
1288  parameter -> SetParameterCandidates("auto manual");
1289  parameter->SetDefaultValue ("auto");
1290  fpCommand->SetParameter (parameter);
1291  parameter = new G4UIparameter ("xmid", 'd', omitable = true);
1292  parameter->SetDefaultValue (0.);
1293  fpCommand->SetParameter (parameter);
1294  parameter = new G4UIparameter ("ymid", 'd', omitable = true);
1295  parameter->SetDefaultValue (0.);
1296  fpCommand->SetParameter (parameter);
1297  parameter = new G4UIparameter ("zmid", 'd', omitable = true);
1298  parameter->SetDefaultValue (0.);
1299  fpCommand->SetParameter (parameter);
1300  parameter = new G4UIparameter ("unit", 's', omitable = true);
1301  parameter->SetDefaultValue ("m");
1302  fpCommand->SetParameter (parameter);
1303 }
1304 
1306  delete fpCommand;
1307 }
1308 
1310  return "";
1311 }
1312 
1314 
1316  G4bool warn = verbosity >= G4VisManager::warnings;
1317 
1318  G4Scene* pScene = fpVisManager->GetCurrentScene();
1319  if (!pScene) {
1320  if (verbosity >= G4VisManager::errors) {
1321  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
1322  }
1323  return;
1324  } else {
1325  if (pScene->GetExtent().GetExtentRadius() <= 0.) {
1326  if (verbosity >= G4VisManager::errors) {
1327  G4cerr
1328  << "ERROR: Scene has no extent. Add volumes or use \"/vis/scene/add/extent\"."
1329  << G4endl;
1330  }
1331  return;
1332  }
1333  }
1334 
1335  G4VViewer* pViewer = fpVisManager->GetCurrentViewer();
1336  if (!pViewer) {
1337  if (verbosity >= G4VisManager::errors) {
1338  G4cerr <<
1339  "ERROR: G4VisCommandSceneAddLogo::SetNewValue: no viewer."
1340  "\n Auto direction needs a viewer."
1341  << G4endl;
1342  }
1343  return;
1344  }
1345 
1346  G4double userHeight, red, green, blue, xmid, ymid, zmid;
1347  G4String userHeightUnit, direction, auto_manual, positionUnit;
1348  std::istringstream is (newValue);
1349  is >> userHeight >> userHeightUnit >> direction
1350  >> red >> green >> blue
1351  >> auto_manual
1352  >> xmid >> ymid >> zmid >> positionUnit;
1353 
1354  G4double height = userHeight;
1355  const G4VisExtent& sceneExtent = pScene->GetExtent(); // Existing extent.
1356  if (userHeightUnit == "auto") {
1357  height *= 0.2 * sceneExtent.GetExtentRadius();
1358  } else {
1359  height *= G4UIcommand::ValueOf(userHeightUnit);
1360  }
1361 
1362  G4double unit = G4UIcommand::ValueOf(positionUnit);
1363  xmid *= unit; ymid *= unit; zmid *= unit;
1364 
1365  Direction logoDirection = X; // Initialise to keep some compilers happy.
1366  if (direction == "auto") {
1367  // Take cue from viewer
1368  const G4Vector3D& vp =
1370  if (vp.x() > vp.y() && vp.x() > vp.z()) logoDirection = X;
1371  else if (vp.x() < vp.y() && vp.x() < vp.z()) logoDirection = minusX;
1372  else if (vp.y() > vp.x() && vp.y() > vp.z()) logoDirection = Y;
1373  else if (vp.y() < vp.x() && vp.y() < vp.z()) logoDirection = minusY;
1374  else if (vp.z() > vp.x() && vp.z() > vp.y()) logoDirection = Z;
1375  else if (vp.z() < vp.x() && vp.z() < vp.y()) logoDirection = minusZ;
1376  }
1377  else if (direction(0) == 'x') logoDirection = X;
1378  else if (direction(0) == 'y') logoDirection = Y;
1379  else if (direction(0) == 'z') logoDirection = Z;
1380  else if (direction(0) == '-') {
1381  if (direction(1) == 'x') logoDirection = minusX;
1382  else if (direction(1) == 'y') logoDirection = minusY;
1383  else if (direction(1) == 'z') logoDirection = minusZ;
1384  } else {
1385  if (verbosity >= G4VisManager::errors) {
1386  G4cerr << "ERROR: Unrecogniseed direction: \""
1387  << direction << "\"." << G4endl;
1388  return;
1389  }
1390  }
1391 
1392  G4bool autoPlacing = false; if (auto_manual == "auto") autoPlacing = true;
1393  // Parameters read and interpreted.
1394 
1395  // Current scene extent
1396  const G4double xmin = sceneExtent.GetXmin();
1397  const G4double xmax = sceneExtent.GetXmax();
1398  const G4double ymin = sceneExtent.GetYmin();
1399  const G4double ymax = sceneExtent.GetYmax();
1400  const G4double zmin = sceneExtent.GetZmin();
1401  const G4double zmax = sceneExtent.GetZmax();
1402 
1403  // Test existing extent and issue warnings...
1404  G4bool worried = false;
1405  if (sceneExtent.GetExtentRadius() == 0) {
1406  worried = true;
1407  if (verbosity >= G4VisManager::warnings) {
1408  G4cout <<
1409  "WARNING: Existing scene does not yet have any extent."
1410  "\n Maybe you have not yet added any geometrical object."
1411  << G4endl;
1412  }
1413  }
1414 
1415  // Useful constants, etc...
1416  const G4double halfHeight(height / 2.);
1417  const G4double comfort(0.01); // 0.15 seems too big. 0.05 might be better.
1418  const G4double freeHeightFraction (1. + 2. * comfort);
1419 
1420  // Test existing scene for room...
1421  G4bool room = true;
1422  switch (logoDirection) {
1423  case X:
1424  case minusX:
1425  if (freeHeightFraction * (xmax - xmin) < height) room = false;
1426  break;
1427  case Y:
1428  case minusY:
1429  if (freeHeightFraction * (ymax - ymin) < height) room = false;
1430  break;
1431  case Z:
1432  case minusZ:
1433  if (freeHeightFraction * (zmax - zmin) < height) room = false;
1434  break;
1435  }
1436  if (!room) {
1437  worried = true;
1438  if (verbosity >= G4VisManager::warnings) {
1439  G4cout <<
1440  "WARNING: Not enough room in existing scene. Maybe logo is too large."
1441  << G4endl;
1442  }
1443  }
1444  if (worried) {
1445  if (verbosity >= G4VisManager::warnings) {
1446  G4cout <<
1447  "WARNING: The logo you have asked for is bigger than the existing"
1448  "\n scene. Maybe you have added it too soon. It is recommended that"
1449  "\n you add the logo last so that it can be correctly auto-positioned"
1450  "\n so as not to be obscured by any existing object and so that the"
1451  "\n view parameters can be correctly recalculated."
1452  << G4endl;
1453  }
1454  }
1455 
1456  G4double sxmid(xmid), symid(ymid), szmid(zmid);
1457  if (autoPlacing) {
1458  // Aim to place at bottom right of screen when viewed from logoDirection.
1459  // Give some comfort zone.
1460  const G4double xComfort = comfort * (xmax - xmin);
1461  const G4double yComfort = comfort * (ymax - ymin);
1462  const G4double zComfort = comfort * (zmax - zmin);
1463  switch (logoDirection) {
1464  case X: // y-axis up, z-axis to left?
1465  sxmid = xmax + halfHeight + xComfort;
1466  symid = ymin - yComfort;
1467  szmid = zmin - zComfort;
1468  break;
1469  case minusX: // y-axis up, z-axis to right?
1470  sxmid = xmin - halfHeight - xComfort;
1471  symid = ymin - yComfort;
1472  szmid = zmax + zComfort;
1473  break;
1474  case Y: // z-axis up, x-axis to left?
1475  sxmid = xmin - xComfort;
1476  symid = ymax + halfHeight + yComfort;
1477  szmid = zmin - zComfort;
1478  break;
1479  case minusY: // z-axis up, x-axis to right?
1480  sxmid = xmax + xComfort;
1481  symid = ymin - halfHeight - yComfort;
1482  szmid = zmin - zComfort;
1483  break;
1484  case Z: // y-axis up, x-axis to right?
1485  sxmid = xmax + xComfort;
1486  symid = ymin - yComfort;
1487  szmid = zmax + halfHeight + zComfort;
1488  break;
1489  case minusZ: // y-axis up, x-axis to left?
1490  sxmid = xmin - xComfort;
1491  symid = ymin - yComfort;
1492  szmid = zmin - halfHeight - zComfort;
1493  break;
1494  }
1495  }
1496 
1497  G4Transform3D transform;
1498  switch (logoDirection) {
1499  case X: // y-axis up, z-axis to left?
1500  transform = G4RotateY3D(halfpi);
1501  break;
1502  case minusX: // y-axis up, z-axis to right?
1503  transform = G4RotateY3D(-halfpi);
1504  break;
1505  case Y: // z-axis up, x-axis to left?
1506  transform = G4RotateX3D(-halfpi) * G4RotateZ3D(pi);
1507  break;
1508  case minusY: // z-axis up, x-axis to right?
1509  transform = G4RotateX3D(halfpi);
1510  break;
1511  case Z: // y-axis up, x-axis to right?
1512  // No transformation required.
1513  break;
1514  case minusZ: // y-axis up, x-axis to left?
1515  transform = G4RotateY3D(pi);
1516  break;
1517  }
1518  transform = G4Translate3D(sxmid,symid,szmid) * transform;
1519 
1520  G4VisAttributes visAtts(G4Colour(red, green, blue));
1521  visAtts.SetForceSolid(true); // Always solid.
1522 
1523  G4Logo* logo = new G4Logo(height,visAtts);
1524  G4VModel* model =
1526  model->SetType("G4Logo");
1527  model->SetGlobalTag("G4Logo");
1528  model->SetGlobalDescription("G4Logo: " + newValue);
1529  model->SetTransformation(transform);
1530  // Note: it is the responsibility of the model to act upon this, but
1531  // the extent is in local coordinates...
1532  G4double& h = height;
1533  G4double h2 = h/2.;
1534  G4VisExtent extent(-h,h,-h2,h2,-h2,h2);
1535  model->SetExtent(extent);
1536  // This extent gets "added" to existing scene extent in
1537  // AddRunDurationModel below.
1538  const G4String& currentSceneName = pScene -> GetName ();
1539  G4bool successful = pScene -> AddRunDurationModel (model, warn);
1540  if (successful) {
1541  if (verbosity >= G4VisManager::confirmations) {
1542  G4cout << "G4 Logo of height " << userHeight << ' ' << userHeightUnit
1543  << ", " << direction << "-direction, added to scene \""
1544  << currentSceneName << "\"";
1545  if (verbosity >= G4VisManager::parameters) {
1546  G4cout << "\n with extent " << extent
1547  << "\n at " << transform.getRotation()
1548  << transform.getTranslation();
1549  }
1550  G4cout << G4endl;
1551  }
1552  }
1553  else G4VisCommandsSceneAddUnsuccessful(verbosity);
1554  UpdateVisManagerScene (currentSceneName);
1555 }
1556 
1558 (G4double height, const G4VisAttributes& visAtts):
1559  fVisAtts(visAtts)
1560 {
1561  const G4double& h = height;
1562  const G4double h2 = 0.5 * h; // Half height.
1563  const G4double ri = 0.25 * h; // Inner radius.
1564  const G4double ro = 0.5 * h; // Outer radius.
1565  const G4double ro2 = 0.5 * ro; // Half outer radius.
1566  const G4double w = ro - ri; // Width.
1567  const G4double w2 = 0.5 * w; // Half width.
1568  const G4double d2 = 0.2 * h; // Half depth.
1569  const G4double f1 = 0.05 * h; // left edge of stem of "4".
1570  const G4double f2 = -0.3 * h; // bottom edge of cross of "4".
1571  const G4double e = 1.e-4 * h; // epsilon.
1572  const G4double xt = f1, yt = h2; // Top of slope.
1573  const G4double xb = -h2, yb = f2 + w; // Bottom of slope.
1574  const G4double dx = xt - xb, dy = yt - yb;
1575  const G4double angle = std::atan2(dy,dx);
1576  G4RotationMatrix rm;
1577  rm.rotateZ(angle*rad);
1578  const G4double d = std::sqrt(dx * dx + dy * dy);
1579  const G4double ss = h; // Half height of square subtractor
1580  const G4double y8 = ss; // Choose y of subtractor for outer slope.
1581  const G4double x8 = ((-ss * d - dx * (yt - y8)) / dy) + xt;
1582  G4double y9 = ss; // Choose y of subtractor for inner slope.
1583  G4double x9 = ((-(ss - w) * d - dx * (yt - y8)) / dy) + xt;
1584  // But to get inner, we make a triangle translated by...
1585  const G4double xtr = ss - f1, ytr = -ss - f2 -w;
1586  x9 += xtr; y9 += ytr;
1587 
1588  // The idea here is to create a polyhedron for the G and the 4. To do
1589  // this we use Geant4 geometry solids and make boolean operations.
1590  // Note that we do not need to keep the solids. We use local objects,
1591  // which, of course, are deleted on leaving this function. This
1592  // is contrary to the usual requirement for solids that are part of the
1593  // detector for which solids MUST be created on the heap (with "new").
1594  // Finally we invoke CreatePolyhedron, which creates a polyhedron on the heap
1595  // and returns a pointer. It is the user's responsibility to delete,
1596  // which is done in the destructor of this class. Thus the polyhedra,
1597  // created here, remain on the heap for the lifetime of the job.
1598 
1599  // G...
1600  G4Tubs tG("tG",ri,ro,d2,0.15*pi,1.85*pi);
1601  G4Box bG("bG",w2,ro2,d2);
1602  G4UnionSolid logoG("logoG",&tG,&bG,G4Translate3D(ri+w2,-ro2,0.));
1603  fpG = logoG.CreatePolyhedron();
1604  fpG->SetVisAttributes(&fVisAtts);
1605  fpG->Transform(G4Translate3D(-0.55*h,0.,0.));
1606 
1607  // 4...
1608  G4Box b1("b1",h2,h2,d2);
1609  G4Box bS("bS",ss,ss,d2+e); // Subtractor.
1610  G4Box bS2("bS2",ss,ss,d2+2.*e); // 2nd Subtractor.
1611  G4SubtractionSolid s1("s1",&b1,&bS,G4Translate3D(f1-ss,f2-ss,0.));
1612  G4SubtractionSolid s2("s2",&s1,&bS,G4Translate3D(f1+ss+w,f2-ss,0.));
1613  G4SubtractionSolid s3("s3",&s2,&bS,G4Translate3D(f1+ss+w,f2+ss+w,0.));
1615  ("s4",&s3,&bS,G4Transform3D(rm,G4ThreeVector(x8,y8,0.)));
1616  G4SubtractionSolid s5 // Triangular hole.
1617  ("s5",&bS,&bS2,G4Transform3D(rm,G4ThreeVector(x9,y9,0.)));
1618  G4SubtractionSolid logo4("logo4",&s4,&s5,G4Translate3D(-xtr,-ytr,0.));
1619  fp4 = logo4.CreatePolyhedron();
1620  /* Experiment with creating own polyhedron...
1621  int nNodes = 4;
1622  int nFaces = 4;
1623  double xyz[][3] = {{0,0,0},{1*m,0,0},{0,1*m,0},{0,0,1*m}};
1624  int faces[][4] = {{1,3,2,0},{1,2,4,0},{1,4,3,0},{2,3,4,0}};
1625  fp4 = new G4Polyhedron();
1626  fp4->createPolyhedron(nNodes,nFaces,xyz,faces);
1627  */
1628  fp4->SetVisAttributes(&fVisAtts);
1629  fp4->Transform(G4Translate3D(0.55*h,0.,0.));
1630 }
1631 
1633  delete fpG;
1634  delete fp4;
1635 }
1636 
1637 void G4VisCommandSceneAddLogo::G4Logo::operator()
1638  (G4VGraphicsScene& sceneHandler, const G4Transform3D& transform) {
1639  sceneHandler.BeginPrimitives(transform);
1640  sceneHandler.AddPrimitive(*fpG);
1641  sceneHandler.AddPrimitive(*fp4);
1642  sceneHandler.EndPrimitives();
1643 }
1644 
1646 
1648  G4bool omitable;
1649  fpCommand = new G4UIcommand ("/vis/scene/add/logo2D", this);
1650  fpCommand -> SetGuidance ("Adds 2D logo to current scene.");
1651  G4UIparameter* parameter;
1652  parameter = new G4UIparameter ("size", 'i', omitable = true);
1653  parameter -> SetGuidance ("Screen size of text in pixels.");
1654  parameter -> SetDefaultValue (48);
1655  fpCommand -> SetParameter (parameter);
1656  parameter = new G4UIparameter ("x-position", 'd', omitable = true);
1657  parameter -> SetGuidance ("x screen position in range -1 < x < 1.");
1658  parameter -> SetDefaultValue (-0.9);
1659  fpCommand -> SetParameter (parameter);
1660  parameter = new G4UIparameter ("y-position", 'd', omitable = true);
1661  parameter -> SetGuidance ("y screen position in range -1 < y < 1.");
1662  parameter -> SetDefaultValue (-0.9);
1663  fpCommand -> SetParameter (parameter);
1664  parameter = new G4UIparameter ("layout", 's', omitable = true);
1665  parameter -> SetGuidance ("Layout, i.e., adjustment: left|centre|right.");
1666  parameter -> SetDefaultValue ("left");
1667  fpCommand -> SetParameter (parameter);
1668 }
1669 
1671  delete fpCommand;
1672 }
1673 
1675  return "";
1676 }
1677 
1679 {
1681  G4bool warn(verbosity >= G4VisManager::warnings);
1682 
1683  G4Scene* pScene = fpVisManager->GetCurrentScene();
1684  if (!pScene) {
1685  if (verbosity >= G4VisManager::errors) {
1686  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
1687  }
1688  return;
1689  }
1690 
1691  G4int size;
1692  G4double x, y;
1693  G4String layoutString;
1694  std::istringstream is(newValue);
1695  is >> size >> x >> y >> layoutString;
1696  G4Text::Layout layout = G4Text::right;
1697  if (layoutString(0) == 'l') layout = G4Text::left;
1698  else if (layoutString(0) == 'c') layout = G4Text::centre;
1699  else if (layoutString(0) == 'r') layout = G4Text::right;
1700 
1701  Logo2D* logo2D = new Logo2D(fpVisManager, size, x, y, layout);
1702  G4VModel* model =
1704  model->SetType("G4Logo2D");
1705  model->SetGlobalTag("G4Logo2D");
1706  model->SetGlobalDescription("G4Logo2D: " + newValue);
1707  const G4String& currentSceneName = pScene -> GetName ();
1708  G4bool successful = pScene -> AddRunDurationModel (model, warn);
1709  if (successful) {
1710  if (verbosity >= G4VisManager::confirmations) {
1711  G4cout << "2D logo has been added to scene \""
1712  << currentSceneName << "\"."
1713  << G4endl;
1714  }
1715  }
1716  else G4VisCommandsSceneAddUnsuccessful(verbosity);
1717  UpdateVisManagerScene (currentSceneName);
1718 }
1719 
1720 void G4VisCommandSceneAddLogo2D::Logo2D::operator()
1721  (G4VGraphicsScene& sceneHandler, const G4Transform3D&)
1722 {
1723  G4Text text("Geant4", G4Point3D(fX, fY, 0.));
1724  text.SetScreenSize(fSize);
1725  text.SetLayout(fLayout);
1726  G4VisAttributes textAtts(G4Colour::Brown());
1727  text.SetVisAttributes(textAtts);
1728  sceneHandler.BeginPrimitives2D();
1729  sceneHandler.AddPrimitive(text);
1730  sceneHandler.EndPrimitives2D();
1731 }
1732 
1734 
1736  G4bool omitable;
1737  fpCommand = new G4UIcommand ("/vis/scene/add/magneticField", this);
1738  fpCommand -> SetGuidance
1739  ("Adds magnetic field representation to current scene.");
1740  fpCommand -> SetGuidance
1741  ("The first parameter is no. of data points per half scene. So, possibly, at"
1742  "\nmaximum, the number of data points sampled is (2*n+1)^3, which can grow"
1743  "\nlarge--be warned!"
1744  "\nYou might find that your scene is cluttered by thousands of arrows for"
1745  "\nthe default number of data points, so try reducing to 2 or 3, e.g:"
1746  "\n /vis/scene/add/magneticField 3"
1747  "\nor, if only a small part of the scene has a field:"
1748  "\n /vis/scene/add/magneticField 50 # or more");
1749  fpCommand -> SetGuidance
1750  ("In the arrow representation, the length of the arrow is proportional"
1751  "\nto the magnitude of the field and the colour is mapped onto the range"
1752  "\nas a fraction of the maximum magnitude: 0->0.5->1 is blue->green->red.");
1753  G4UIparameter* parameter;
1754  parameter = new G4UIparameter ("nDataPointsPerHalfScene", 'i', omitable = true);
1755  parameter -> SetDefaultValue (10);
1756  fpCommand -> SetParameter (parameter);
1757  parameter = new G4UIparameter ("representation", 's', omitable = true);
1758  parameter -> SetParameterCandidates("fullArrow lightArrow");
1759  parameter -> SetDefaultValue ("fullArrow");
1760  fpCommand -> SetParameter (parameter);
1761 }
1762 
1764  delete fpCommand;
1765 }
1766 
1768  return "";
1769 }
1770 
1772 (G4UIcommand*, G4String newValue) {
1773 
1775  G4bool warn(verbosity >= G4VisManager::warnings);
1776 
1777  G4Scene* pScene = fpVisManager->GetCurrentScene();
1778  if (!pScene) {
1779  if (verbosity >= G4VisManager::errors) {
1780  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
1781  }
1782  return;
1783  }
1784 
1785  G4int nDataPointsPerHalfScene;
1786  G4String representation;
1787  std::istringstream iss(newValue);
1788  iss >> nDataPointsPerHalfScene >> representation;
1790  modelRepresentation = G4MagneticFieldModel::fullArrow;
1791  if (representation == "lightArrow") {
1792  modelRepresentation = G4MagneticFieldModel::lightArrow;
1793  }
1794  G4MagneticFieldModel* model =
1795  new G4MagneticFieldModel(nDataPointsPerHalfScene,modelRepresentation);
1796  const G4String& currentSceneName = pScene -> GetName ();
1797  G4bool successful = pScene -> AddRunDurationModel (model, warn);
1798  if (successful) {
1799  if (verbosity >= G4VisManager::confirmations) {
1800  G4cout << "Magnetic field, if any, will be drawn in scene \""
1801  << currentSceneName
1802  << "\"\n with "
1803  << nDataPointsPerHalfScene
1804  << " data points per half scene and with representation \""
1805  << representation
1806  << '\"'
1807  << G4endl;
1808  }
1809  }
1810  else G4VisCommandsSceneAddUnsuccessful(verbosity);
1811  UpdateVisManagerScene (currentSceneName);
1812 }
1813 
1815 
1817  G4bool omitable;
1818  fpCommand = new G4UIcmdWithAString ("/vis/scene/add/psHits", this);
1819  fpCommand -> SetGuidance
1820  ("Adds Primitive Scorer Hits (PSHits) to current scene.");
1821  fpCommand -> SetGuidance
1822  ("PSHits are drawn at end of run when the scene in which"
1823  "\nthey are added is current.");
1824  fpCommand -> SetGuidance
1825  ("Optional parameter specifies name of scoring map. By default all"
1826  "\nscoring maps registered with the G4ScoringManager are drawn.");
1827  fpCommand -> SetParameterName ("mapname", omitable = true);
1828  fpCommand -> SetDefaultValue ("all");
1829 }
1830 
1832  delete fpCommand;
1833 }
1834 
1836  return "";
1837 }
1838 
1840 (G4UIcommand*, G4String newValue)
1841 {
1843  G4bool warn(verbosity >= G4VisManager::warnings);
1844 
1845  G4Scene* pScene = fpVisManager->GetCurrentScene();
1846  if (!pScene) {
1847  if (verbosity >= G4VisManager::errors) {
1848  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
1849  }
1850  return;
1851  }
1852 
1853  G4PSHitsModel* model = new G4PSHitsModel(newValue);
1854  const G4String& currentSceneName = pScene -> GetName ();
1855  G4bool successful = pScene -> AddEndOfRunModel (model, warn);
1856  if (successful) {
1857  if (verbosity >= G4VisManager::confirmations) {
1858  if (newValue == "all") {
1859  G4cout << "All Primitive Scorer hits";
1860  } else {
1861  G4cout << "Hits of Primitive Scorer \"" << newValue << '"';
1862  }
1863  G4cout << " will be drawn at end of run in scene \""
1864  << currentSceneName << "\"."
1865  << G4endl;
1866  }
1867  }
1868  else G4VisCommandsSceneAddUnsuccessful(verbosity);
1869  UpdateVisManagerScene (currentSceneName);
1870 }
1871 
1873 
1875  G4bool omitable;
1876  fpCommand = new G4UIcommand ("/vis/scene/add/scale", this);
1877  fpCommand -> SetGuidance
1878  ("Adds an annotated scale line to the current scene.");
1879  fpCommand -> SetGuidance
1880  ("If \"unit\" is \"auto\", length is roughly one tenth of the scene extent.");
1881  fpCommand -> SetGuidance
1882  ("If \"direction\" is \"auto\", scale is roughly in the plane of the current view.");
1883  fpCommand -> SetGuidance
1884  ("If \"placement\" is \"auto\", scale is placed at bottom left of current view."
1885  "\n Otherwise placed at (xmid,ymid,zmid).");
1886  fpCommand -> SetGuidance (G4Scale::GetGuidanceString());
1887  G4UIparameter* parameter;
1888  parameter = new G4UIparameter ("length", 'd', omitable = true);
1889  parameter->SetDefaultValue (1.);
1890  fpCommand->SetParameter (parameter);
1891  parameter = new G4UIparameter ("unit", 's', omitable = true);
1892  parameter->SetDefaultValue ("auto");
1893  fpCommand->SetParameter (parameter);
1894  parameter = new G4UIparameter ("direction", 's', omitable = true);
1895  parameter->SetGuidance ("auto|x|y|z");
1896  parameter->SetDefaultValue ("auto");
1897  fpCommand->SetParameter (parameter);
1898  parameter = new G4UIparameter ("red", 'd', omitable = true);
1899  parameter->SetDefaultValue (1.);
1900  fpCommand->SetParameter (parameter);
1901  parameter = new G4UIparameter ("green", 'd', omitable = true);
1902  parameter->SetDefaultValue (0.);
1903  fpCommand->SetParameter (parameter);
1904  parameter = new G4UIparameter ("blue", 'd', omitable = true);
1905  parameter->SetDefaultValue (0.);
1906  fpCommand->SetParameter (parameter);
1907  parameter = new G4UIparameter ("placement", 's', omitable = true);
1908  parameter -> SetParameterCandidates("auto manual");
1909  parameter->SetDefaultValue ("auto");
1910  fpCommand->SetParameter (parameter);
1911  parameter = new G4UIparameter ("xmid", 'd', omitable = true);
1912  parameter->SetDefaultValue (0.);
1913  fpCommand->SetParameter (parameter);
1914  parameter = new G4UIparameter ("ymid", 'd', omitable = true);
1915  parameter->SetDefaultValue (0.);
1916  fpCommand->SetParameter (parameter);
1917  parameter = new G4UIparameter ("zmid", 'd', omitable = true);
1918  parameter->SetDefaultValue (0.);
1919  fpCommand->SetParameter (parameter);
1920  parameter = new G4UIparameter ("unit", 's', omitable = true);
1921  parameter->SetDefaultValue ("m");
1922  fpCommand->SetParameter (parameter);
1923 }
1924 
1926  delete fpCommand;
1927 }
1928 
1930  return "";
1931 }
1932 
1934 
1936  G4bool warn = verbosity >= G4VisManager::warnings;
1937 
1938  G4Scene* pScene = fpVisManager->GetCurrentScene();
1939  if (!pScene) {
1940  if (verbosity >= G4VisManager::errors) {
1941  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
1942  }
1943  return;
1944  } else {
1945  if (pScene->GetExtent().GetExtentRadius() <= 0.) {
1946  if (verbosity >= G4VisManager::errors) {
1947  G4cerr
1948  << "ERROR: Scene has no extent. Add volumes or use \"/vis/scene/add/extent\"."
1949  << G4endl;
1950  }
1951  return;
1952  }
1953  }
1954 
1955  G4double userLength, red, green, blue, xmid, ymid, zmid;
1956  G4String userLengthUnit, direction, auto_manual, positionUnit;
1957  std::istringstream is (newValue);
1958  is >> userLength >> userLengthUnit >> direction
1959  >> red >> green >> blue
1960  >> auto_manual
1961  >> xmid >> ymid >> zmid >> positionUnit;
1962 
1963  G4double length = userLength;
1964  const G4VisExtent& sceneExtent = pScene->GetExtent(); // Existing extent.
1965  if (userLengthUnit == "auto") {
1966  const G4double lengthMax = 0.5 * sceneExtent.GetExtentRadius();
1967  const G4double intLog10Length = std::floor(std::log10(lengthMax));
1968  length = std::pow(10,intLog10Length);
1969  if (5.*length < lengthMax) length *= 5.;
1970  else if (2.*length < lengthMax) length *= 2.;
1971  } else {
1972  length *= G4UIcommand::ValueOf(userLengthUnit);
1973  }
1974  G4String annotation = G4BestUnit(length,"Length");
1975 
1976  G4double unit = G4UIcommand::ValueOf(positionUnit);
1977  xmid *= unit; ymid *= unit; zmid *= unit;
1978 
1979  G4Scale::Direction scaleDirection (G4Scale::x);
1980  if (direction(0) == 'y') scaleDirection = G4Scale::y;
1981  if (direction(0) == 'z') scaleDirection = G4Scale::z;
1982 
1983  G4VViewer* pViewer = fpVisManager->GetCurrentViewer();
1984  if (!pViewer) {
1985  if (verbosity >= G4VisManager::errors) {
1986  G4cerr <<
1987  "ERROR: G4VisCommandSceneAddScale::SetNewValue: no viewer."
1988  "\n Auto direction needs a viewer."
1989  << G4endl;
1990  }
1991  return;
1992  }
1993 
1994  const G4Vector3D& vp =
1996  const G4Vector3D& up =
1997  pViewer->GetViewParameters().GetUpVector();
1998 
1999  if (direction == "auto") { // Takes cue from viewer.
2000  if (std::abs(vp.x()) > std::abs(vp.y()) &&
2001  std::abs(vp.x()) > std::abs(vp.z())) { // x viewpoint
2002  if (std::abs(up.y()) > std::abs(up.z())) scaleDirection = G4Scale::z;
2003  else scaleDirection = G4Scale::y;
2004  }
2005  else if (std::abs(vp.y()) > std::abs(vp.x()) &&
2006  std::abs(vp.y()) > std::abs(vp.z())) { // y viewpoint
2007  if (std::abs(up.x()) > std::abs(up.z())) scaleDirection = G4Scale::z;
2008  else scaleDirection = G4Scale::x;
2009  }
2010  else if (std::abs(vp.z()) > std::abs(vp.x()) &&
2011  std::abs(vp.z()) > std::abs(vp.y())) { // z viewpoint
2012  if (std::abs(up.y()) > std::abs(up.x())) scaleDirection = G4Scale::x;
2013  else scaleDirection = G4Scale::y;
2014  }
2015  }
2016 
2017  G4bool autoPlacing = false; if (auto_manual == "auto") autoPlacing = true;
2018  // Parameters read and interpreted.
2019 
2020  // Useful constants, etc...
2021  const G4double halfLength(length / 2.);
2022  const G4double comfort(0.01); // 0.15 seems too big. 0.05 might be better.
2023  const G4double freeLengthFraction (1. + 2. * comfort);
2024 
2025  const G4double xmin = sceneExtent.GetXmin();
2026  const G4double xmax = sceneExtent.GetXmax();
2027  const G4double ymin = sceneExtent.GetYmin();
2028  const G4double ymax = sceneExtent.GetYmax();
2029  const G4double zmin = sceneExtent.GetZmin();
2030  const G4double zmax = sceneExtent.GetZmax();
2031 
2032  // Test existing extent and issue warnings...
2033  G4bool worried = false;
2034  if (sceneExtent.GetExtentRadius() == 0) {
2035  worried = true;
2036  if (verbosity >= G4VisManager::warnings) {
2037  G4cout <<
2038  "WARNING: Existing scene does not yet have any extent."
2039  "\n Maybe you have not yet added any geometrical object."
2040  << G4endl;
2041  }
2042  }
2043  // Test existing scene for room...
2044  G4bool room = true;
2045  switch (scaleDirection) {
2046  case G4Scale::x:
2047  if (freeLengthFraction * (xmax - xmin) < length) room = false;
2048  break;
2049  case G4Scale::y:
2050  if (freeLengthFraction * (ymax - ymin) < length) room = false;
2051  break;
2052  case G4Scale::z:
2053  if (freeLengthFraction * (zmax - zmin) < length) room = false;
2054  break;
2055  }
2056  if (!room) {
2057  worried = true;
2058  if (verbosity >= G4VisManager::warnings) {
2059  G4cout <<
2060  "WARNING: Not enough room in existing scene. Maybe scale is too long."
2061  << G4endl;
2062  }
2063  }
2064  if (worried) {
2065  if (verbosity >= G4VisManager::warnings) {
2066  G4cout <<
2067  "WARNING: The scale you have asked for is bigger than the existing"
2068  "\n scene. Maybe you have added it too soon. It is recommended that"
2069  "\n you add the scale last so that it can be correctly auto-positioned"
2070  "\n so as not to be obscured by any existing object and so that the"
2071  "\n view parameters can be correctly recalculated."
2072  << G4endl;
2073  }
2074  }
2075 
2076  // Let's go ahead a construct a scale and a scale model. Since the
2077  // placing is done here, this G4Scale is *not* auto-placed...
2078  G4Scale scale(length, annotation, scaleDirection,
2079  false, xmid, ymid, zmid,
2081  G4VisAttributes visAttr(G4Colour(red, green, blue));
2082  scale.SetVisAttributes(visAttr);
2083  G4VModel* model = new G4ScaleModel(scale);
2084  G4String globalDescription = model->GetGlobalDescription();
2085  globalDescription += " (" + newValue + ")";
2086  model->SetGlobalDescription(globalDescription);
2087 
2088  // Now figure out the extent...
2089  //
2090  // From the G4Scale.hh:
2091  //
2092  // This creates a representation of annotated line in the specified
2093  // direction with tick marks at the end. If autoPlacing is true it
2094  // is required to be centred at the front, right, bottom corner of
2095  // the world space, comfortably outside the existing bounding
2096  // box/sphere so that existing objects do not obscure it. Otherwise
2097  // it is required to be drawn with mid-point at (xmid, ymid, zmid).
2098  //
2099  // The auto placing algorithm might be:
2100  // x = xmin + (1 + comfort) * (xmax - xmin)
2101  // y = ymin - comfort * (ymax - ymin)
2102  // z = zmin + (1 + comfort) * (zmax - zmin)
2103  // if direction == x then (x - length,y,z) to (x,y,z)
2104  // if direction == y then (x,y,z) to (x,y + length,z)
2105  // if direction == z then (x,y,z - length) to (x,y,z)
2106  //
2107  // End of clip from G4Scale.hh:
2108  //
2109  // Implement this in two parts. Here, use the scale's extent to
2110  // "expand" the scene's extent. Then rendering - in
2111  // G4VSceneHandler::AddPrimitive(const G4Scale&) - simply has to
2112  // ensure it's within the new extent.
2113  //
2114 
2115  G4double sxmid(xmid), symid(ymid), szmid(zmid);
2116  if (autoPlacing) {
2117  // Aim to place at bottom right of screen in current view.
2118  // Give some comfort zone.
2119  const G4double xComfort = comfort * (xmax - xmin);
2120  const G4double yComfort = comfort * (ymax - ymin);
2121  const G4double zComfort = comfort * (zmax - zmin);
2122  switch (scaleDirection) {
2123  case G4Scale::x:
2124  if (vp.z() > 0.) {
2125  sxmid = xmax + xComfort;
2126  symid = ymin - yComfort;
2127  szmid = zmin - zComfort;
2128  } else {
2129  sxmid = xmin - xComfort;
2130  symid = ymin - yComfort;
2131  szmid = zmax + zComfort;
2132  }
2133  break;
2134  case G4Scale::y:
2135  if (vp.x() > 0.) {
2136  sxmid = xmin - xComfort;
2137  symid = ymax + yComfort;
2138  szmid = zmin - zComfort;
2139  } else {
2140  sxmid = xmax + xComfort;
2141  symid = ymin - yComfort;
2142  szmid = zmin - zComfort;
2143  }
2144  break;
2145  case G4Scale::z:
2146  if (vp.x() > 0.) {
2147  sxmid = xmax + xComfort;
2148  symid = ymin - yComfort;
2149  szmid = zmax + zComfort;
2150  } else {
2151  sxmid = xmin - xComfort;
2152  symid = ymin - yComfort;
2153  szmid = zmax + zComfort;
2154  }
2155  break;
2156  }
2157  }
2158 
2159  /* Old code - kept for future reference.
2160  G4double sxmid(xmid), symid(ymid), szmid(zmid);
2161  if (autoPlacing) {
2162  sxmid = xmin + onePlusComfort * (xmax - xmin);
2163  symid = ymin - comfort * (ymax - ymin);
2164  szmid = zmin + onePlusComfort * (zmax - zmin);
2165  switch (scaleDirection) {
2166  case G4Scale::x:
2167  sxmid -= halfLength;
2168  break;
2169  case G4Scale::y:
2170  symid += halfLength;
2171  break;
2172  case G4Scale::z:
2173  szmid -= halfLength;
2174  break;
2175  }
2176  }
2177  */
2178 
2179  /* sxmin, etc., not actually used. Comment out to prevent compiler
2180  warnings but keep in case need in future. Extract transform and
2181  scaleExtent into reduced code below.
2182  G4double sxmin(sxmid), sxmax(sxmid);
2183  G4double symin(symid), symax(symid);
2184  G4double szmin(szmid), szmax(szmid);
2185  G4Transform3D transform;
2186  G4VisExtent scaleExtent;
2187  switch (scaleDirection) {
2188  case G4Scale::x:
2189  sxmin = sxmid - halfLength;
2190  sxmax = sxmid + halfLength;
2191  scaleExtent = G4VisExtent(-halfLength,halfLength,0,0,0,0);
2192  break;
2193  case G4Scale::y:
2194  symin = symid - halfLength;
2195  symax = symid + halfLength;
2196  transform = G4RotateZ3D(halfpi);
2197  scaleExtent = G4VisExtent(0,0,-halfLength,halfLength,0,0);
2198  break;
2199  case G4Scale::z:
2200  szmin = szmid - halfLength;
2201  szmax = szmid + halfLength;
2202  transform = G4RotateY3D(halfpi);
2203  scaleExtent = G4VisExtent(0,0,0,0,-halfLength,halfLength);
2204  break;
2205  }
2206  */
2207  G4Transform3D transform;
2208  G4VisExtent scaleExtent;
2209  switch (scaleDirection) {
2210  case G4Scale::x:
2211  scaleExtent = G4VisExtent(-halfLength,halfLength,0,0,0,0);
2212  break;
2213  case G4Scale::y:
2214  transform = G4RotateZ3D(halfpi);
2215  scaleExtent = G4VisExtent(0,0,-halfLength,halfLength,0,0);
2216  break;
2217  case G4Scale::z:
2218  transform = G4RotateY3D(halfpi);
2219  scaleExtent = G4VisExtent(0,0,0,0,-halfLength,halfLength);
2220  break;
2221  }
2222  transform = G4Translate3D(sxmid,symid,szmid) * transform;
2224 
2225 
2226  model->SetTransformation(transform);
2227  // Note: it is the responsibility of the model to act upon this, but
2228  // the extent is in local coordinates...
2229  model->SetExtent(scaleExtent);
2230  // This extent gets "added" to existing scene extent in
2231  // AddRunDurationModel below.
2232 
2233  const G4String& currentSceneName = pScene -> GetName ();
2234  G4bool successful = pScene -> AddRunDurationModel (model, warn);
2235  if (successful) {
2236  if (verbosity >= G4VisManager::confirmations) {
2237  G4cout << "Scale of " << annotation
2238  << " added to scene \"" << currentSceneName << "\".";
2239  if (verbosity >= G4VisManager::parameters) {
2240  G4cout << "\n with extent " << scaleExtent
2241  << "\n at " << transform.getRotation()
2242  << transform.getTranslation();
2243  }
2244  G4cout << G4endl;
2245  }
2246  }
2247  else G4VisCommandsSceneAddUnsuccessful(verbosity);
2248  UpdateVisManagerScene (currentSceneName);
2249 }
2250 
2251 
2253 
2255  G4bool omitable;
2256  fpCommand = new G4UIcommand ("/vis/scene/add/text", this);
2257  fpCommand -> SetGuidance ("Adds text to current scene.");
2258  fpCommand -> SetGuidance
2259  ("Use \"/vis/set/textColour\" to set colour.");
2260  fpCommand -> SetGuidance
2261  ("Use \"/vis/set/textLayout\" to set layout:");
2262  G4UIparameter* parameter;
2263  parameter = new G4UIparameter ("x", 'd', omitable = true);
2264  parameter->SetDefaultValue (0);
2265  fpCommand->SetParameter (parameter);
2266  parameter = new G4UIparameter ("y", 'd', omitable = true);
2267  parameter->SetDefaultValue (0);
2268  fpCommand->SetParameter (parameter);
2269  parameter = new G4UIparameter ("z", 'd', omitable = true);
2270  parameter->SetDefaultValue (0);
2271  fpCommand->SetParameter (parameter);
2272  parameter = new G4UIparameter ("unit", 's', omitable = true);
2273  parameter->SetDefaultValue ("m");
2274  fpCommand->SetParameter (parameter);
2275  parameter = new G4UIparameter ("font_size", 'd', omitable = true);
2276  parameter->SetDefaultValue (12);
2277  parameter->SetGuidance ("pixels");
2278  fpCommand->SetParameter (parameter);
2279  parameter = new G4UIparameter ("x_offset", 'd', omitable = true);
2280  parameter->SetDefaultValue (0);
2281  parameter->SetGuidance ("pixels");
2282  fpCommand->SetParameter (parameter);
2283  parameter = new G4UIparameter ("y_offset", 'd', omitable = true);
2284  parameter->SetDefaultValue (0);
2285  parameter->SetGuidance ("pixels");
2286  fpCommand->SetParameter (parameter);
2287  parameter = new G4UIparameter ("text", 's', omitable = true);
2288  parameter->SetGuidance ("The rest of the line is text.");
2289  parameter->SetDefaultValue ("Hello G4");
2290  fpCommand->SetParameter (parameter);
2291 }
2292 
2294  delete fpCommand;
2295 }
2296 
2298  return "";
2299 }
2300 
2302 
2304  G4bool warn = verbosity >= G4VisManager::warnings;
2305 
2306  G4Scene* pScene = fpVisManager->GetCurrentScene();
2307  if (!pScene) {
2308  if (verbosity >= G4VisManager::errors) {
2309  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
2310  }
2311  return;
2312  }
2313 
2314  G4Tokenizer next(newValue);
2315  G4double x = StoD(next());
2316  G4double y = StoD(next());
2317  G4double z = StoD(next());
2318  G4String unitString = next();
2319  G4double font_size = StoD(next());
2320  G4double x_offset = StoD(next());
2321  G4double y_offset = StoD(next());
2322  G4String text = next("\n");
2323 
2324  G4double unit = G4UIcommand::ValueOf(unitString);
2325  x *= unit; y *= unit; z *= unit;
2326 
2327  G4Text g4text(text, G4Point3D(x,y,z));
2329  g4text.SetVisAttributes(visAtts);
2330  g4text.SetLayout(fCurrentTextLayout);
2331  g4text.SetScreenSize(font_size);
2332  g4text.SetOffset(x_offset,y_offset);
2333  G4VModel* model = new G4TextModel(g4text);
2334  const G4String& currentSceneName = pScene -> GetName ();
2335  G4bool successful = pScene -> AddRunDurationModel (model, warn);
2336  if (successful) {
2337  if (verbosity >= G4VisManager::confirmations) {
2338  G4cout << "Text \"" << text
2339  << "\" has been added to scene \"" << currentSceneName << "\"."
2340  << G4endl;
2341  }
2342  }
2343  else G4VisCommandsSceneAddUnsuccessful(verbosity);
2344  UpdateVisManagerScene (currentSceneName);
2345 }
2346 
2347 
2349 
2351  G4bool omitable;
2352  fpCommand = new G4UIcommand ("/vis/scene/add/text2D", this);
2353  fpCommand -> SetGuidance ("Adds 2D text to current scene.");
2354  fpCommand -> SetGuidance
2355  ("Use \"/vis/set/textColour\" to set colour.");
2356  fpCommand -> SetGuidance
2357  ("Use \"/vis/set/textLayout\" to set layout:");
2358  G4UIparameter* parameter;
2359  parameter = new G4UIparameter ("x", 'd', omitable = true);
2360  parameter->SetDefaultValue (0);
2361  fpCommand->SetParameter (parameter);
2362  parameter = new G4UIparameter ("y", 'd', omitable = true);
2363  parameter->SetDefaultValue (0);
2364  fpCommand->SetParameter (parameter);
2365  parameter = new G4UIparameter ("font_size", 'd', omitable = true);
2366  parameter->SetDefaultValue (12);
2367  parameter->SetGuidance ("pixels");
2368  fpCommand->SetParameter (parameter);
2369  parameter = new G4UIparameter ("x_offset", 'd', omitable = true);
2370  parameter->SetDefaultValue (0);
2371  parameter->SetGuidance ("pixels");
2372  fpCommand->SetParameter (parameter);
2373  parameter = new G4UIparameter ("y_offset", 'd', omitable = true);
2374  parameter->SetDefaultValue (0);
2375  parameter->SetGuidance ("pixels");
2376  fpCommand->SetParameter (parameter);
2377  parameter = new G4UIparameter ("text", 's', omitable = true);
2378  parameter->SetGuidance ("The rest of the line is text.");
2379  parameter->SetDefaultValue ("Hello G4");
2380  fpCommand->SetParameter (parameter);
2381 }
2382 
2384  delete fpCommand;
2385 }
2386 
2388  return "";
2389 }
2390 
2392 
2394  G4bool warn = verbosity >= G4VisManager::warnings;
2395 
2396  G4Scene* pScene = fpVisManager->GetCurrentScene();
2397  if (!pScene) {
2398  if (verbosity >= G4VisManager::errors) {
2399  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
2400  }
2401  return;
2402  }
2403 
2404  G4Tokenizer next(newValue);
2405  G4double x = StoD(next());
2406  G4double y = StoD(next());
2407  G4double font_size = StoD(next());
2408  G4double x_offset = StoD(next());
2409  G4double y_offset = StoD(next());
2410  G4String text = next("\n");
2411 
2412  G4Text g4text(text, G4Point3D(x,y,0.));
2414  g4text.SetVisAttributes(visAtts);
2415  g4text.SetLayout(fCurrentTextLayout);
2416  g4text.SetScreenSize(font_size);
2417  g4text.SetOffset(x_offset,y_offset);
2418  G4Text2D* g4text2D = new G4Text2D(g4text);
2419  G4VModel* model =
2421  model->SetType("Text2D");
2422  model->SetGlobalTag("Text2D");
2423  model->SetGlobalDescription("Text2D: " + newValue);
2424  const G4String& currentSceneName = pScene -> GetName ();
2425  G4bool successful = pScene -> AddRunDurationModel (model, warn);
2426  if (successful) {
2427  if (verbosity >= G4VisManager::confirmations) {
2428  G4cout << "2D text \"" << text
2429  << "\" has been added to scene \"" << currentSceneName << "\"."
2430  << G4endl;
2431  }
2432  }
2433  else G4VisCommandsSceneAddUnsuccessful(verbosity);
2434  UpdateVisManagerScene (currentSceneName);
2435 }
2436 
2438  fText(text)
2439 {}
2440 
2441 void G4VisCommandSceneAddText2D::G4Text2D::operator()
2442  (G4VGraphicsScene& sceneHandler, const G4Transform3D& transform) {
2443  sceneHandler.BeginPrimitives2D(transform);
2444  sceneHandler.AddPrimitive(fText);
2445  sceneHandler.EndPrimitives2D();
2446 }
2447 
2448 
2450 
2452  G4bool omitable;
2454  ("/vis/scene/add/trajectories", this);
2455  fpCommand -> SetGuidance
2456  ("Adds trajectories to current scene.");
2457  fpCommand -> SetGuidance
2458  ("Causes trajectories, if any, to be drawn at the end of processing an"
2459  "\nevent. Switches on trajectory storing and sets the"
2460  "\ndefault trajectory type.");
2461  fpCommand -> SetGuidance
2462  ("The command line parameter list determines the default trajectory type."
2463  "\nIf it contains the string \"smooth\", auxiliary inter-step points will"
2464  "\nbe inserted to improve the smoothness of the drawing of a curved"
2465  "\ntrajectory."
2466  "\nIf it contains the string \"rich\", significant extra information will"
2467  "\nbe stored in the trajectory (G4RichTrajectory) amenable to modeling"
2468  "\nand filtering with \"/vis/modeling/trajectories/create/drawByAttribute\""
2469  "\nand \"/vis/filtering/trajectories/create/attributeFilter\" commands."
2470  "\nIt may contain both strings in any order.");
2471  fpCommand -> SetGuidance
2472  ("\nTo switch off trajectory storing: \"/tracking/storeTrajectory 0\"."
2473  "\nSee also \"/vis/scene/endOfEventAction\".");
2474  fpCommand -> SetGuidance
2475  ("Note: This only sets the default. Independently of the result of this"
2476  "\ncommand, a user may instantiate a trajectory that overrides this default"
2477  "\nin PreUserTrackingAction.");
2478  fpCommand -> SetParameterName ("default-trajectory-type", omitable = true);
2479  fpCommand -> SetDefaultValue ("");
2480 }
2481 
2483  delete fpCommand;
2484 }
2485 
2487  return "";
2488 }
2489 
2491  G4String newValue) {
2492 
2494  G4bool warn = verbosity >= G4VisManager::warnings;
2495 
2496  G4Scene* pScene = fpVisManager->GetCurrentScene();
2497  if (!pScene) {
2498  if (verbosity >= G4VisManager::errors) {
2499  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
2500  }
2501  return;
2502  }
2503 
2504  G4bool smooth = false;
2505  G4bool rich = false;
2506  if (newValue.find("smooth") != std::string::npos) smooth = true;
2507  if (newValue.find("rich") != std::string::npos) rich = true;
2508  if (newValue.size() && !(rich || smooth)) {
2509  if (verbosity >= G4VisManager::errors) {
2510  G4cerr << "ERROR: Unrecognised parameter \"" << newValue << "\""
2511  "\n No action taken."
2512  << G4endl;
2513  }
2514  return;
2515  }
2516 
2517  G4UImanager* UImanager = G4UImanager::GetUIpointer();
2518  G4int keepVerbose = UImanager->GetVerboseLevel();
2519  G4int newVerbose = 2;
2520  UImanager->SetVerboseLevel(newVerbose);
2521  G4String defaultTrajectoryType;
2522  if (smooth && rich) {
2523  UImanager->ApplyCommand("/tracking/storeTrajectory 4");
2524  defaultTrajectoryType = "G4RichTrajectory configured for smooth steps";
2525  } else if (smooth) {
2526  UImanager->ApplyCommand("/tracking/storeTrajectory 2");
2527  defaultTrajectoryType = "G4SmoothTrajectory";
2528  } else if (rich) {
2529  UImanager->ApplyCommand("/tracking/storeTrajectory 3");
2530  defaultTrajectoryType = "G4RichTrajectory";
2531  } else {
2532  UImanager->ApplyCommand("/tracking/storeTrajectory 1");
2533  defaultTrajectoryType = "G4Trajectory";
2534  }
2535  UImanager->SetVerboseLevel(keepVerbose);
2536 
2537  if (verbosity >= G4VisManager::errors) {
2538  G4cout <<
2539  "Attributes available for modeling and filtering with"
2540  "\n \"/vis/modeling/trajectories/create/drawByAttribute\" and"
2541  "\n \"/vis/filtering/trajectories/create/attributeFilter\" commands:"
2542  << G4endl;
2544  if (rich) {
2547  } else if (smooth) {
2550  } else {
2552  << *G4TrajectoryPoint().GetAttDefs();
2553  }
2554  }
2555 
2557  const G4String& currentSceneName = pScene -> GetName ();
2558  pScene -> AddEndOfEventModel (model, warn);
2559 
2560  if (verbosity >= G4VisManager::confirmations) {
2561  G4cout << "Default trajectory type " << defaultTrajectoryType
2562  << "\n will be used to store trajectories for scene \""
2563  << currentSceneName << "\"."
2564  << G4endl;
2565  }
2566 
2567  if (verbosity >= G4VisManager::warnings) {
2568  G4cout <<
2569  "WARNING: Trajectory storing has been requested. This action may be"
2570  "\n reversed with \"/tracking/storeTrajectory 0\"."
2571  << G4endl;
2572  }
2573  UpdateVisManagerScene (currentSceneName);
2574 }
2575 
2577 
2579  G4bool omitable;
2580  fpCommand = new G4UIcmdWithAString("/vis/scene/add/userAction",this);
2581  fpCommand -> SetGuidance
2582  ("Add named Vis User Action to current scene.");
2583  fpCommand -> SetGuidance
2584  ("Attempts to match search string to name of action - use unique sub-string.");
2585  fpCommand -> SetGuidance
2586  ("(Use /vis/list to see names of registered actions.)");
2587  fpCommand -> SetGuidance
2588  ("If name == \"all\" (default), all actions are added.");
2589  fpCommand -> SetParameterName("action-name", omitable = true);
2590  fpCommand -> SetDefaultValue("all");
2591 }
2592 
2594  delete fpCommand;
2595 }
2596 
2598  return "";
2599 }
2600 
2602 (G4UIcommand*, G4String newValue) {
2603 
2605 
2606  G4Scene* pScene = fpVisManager->GetCurrentScene();
2607  if (!pScene) {
2608  if (verbosity >= G4VisManager::errors) {
2609  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
2610  }
2611  return;
2612  }
2613 
2614  G4bool any = false;
2615 
2616  const std::vector<G4VisManager::UserVisAction>& runDurationUserVisActions =
2618  for (size_t i = 0; i < runDurationUserVisActions.size(); i++) {
2619  const G4String& name = runDurationUserVisActions[i].fName;
2620  G4VUserVisAction* visAction = runDurationUserVisActions[i].fpUserVisAction;
2621  if (newValue == "all" || name.find(newValue) != std::string::npos) {
2622  any = true;
2623  AddVisAction(name,visAction,pScene,runDuration,verbosity);
2624  }
2625  }
2626 
2627  const std::vector<G4VisManager::UserVisAction>& endOfEventUserVisActions =
2629  for (size_t i = 0; i < endOfEventUserVisActions.size(); i++) {
2630  const G4String& name = endOfEventUserVisActions[i].fName;
2631  G4VUserVisAction* visAction = endOfEventUserVisActions[i].fpUserVisAction;
2632  if (newValue == "all" || name.find(newValue) != std::string::npos) {
2633  any = true;
2634  AddVisAction(name,visAction,pScene,endOfEvent,verbosity);
2635  }
2636  }
2637 
2638  const std::vector<G4VisManager::UserVisAction>& endOfRunUserVisActions =
2640  for (size_t i = 0; i < endOfRunUserVisActions.size(); i++) {
2641  const G4String& name = endOfRunUserVisActions[i].fName;
2642  G4VUserVisAction* visAction = endOfRunUserVisActions[i].fpUserVisAction;
2643  if (newValue == "all" || name.find(newValue) != std::string::npos) {
2644  any = true;
2645  AddVisAction(name,visAction,pScene,endOfRun,verbosity);
2646  }
2647  }
2648 
2649  if (!any) {
2650  if (verbosity >= G4VisManager::warnings) {
2651  G4cout << "WARNING: No User Vis Action registered." << G4endl;
2652  }
2653  return;
2654  }
2655 
2656  const G4String& currentSceneName = pScene -> GetName ();
2657  UpdateVisManagerScene (currentSceneName);
2658 }
2659 
2661 (const G4String& name,
2662  G4VUserVisAction* visAction,
2663  G4Scene* pScene,
2665  G4VisManager::Verbosity verbosity)
2666 {
2667  G4bool warn = verbosity >= G4VisManager::warnings;
2668 
2669  const std::map<G4VUserVisAction*,G4VisExtent>& visExtentMap =
2671  G4VisExtent extent;
2672  std::map<G4VUserVisAction*,G4VisExtent>::const_iterator i =
2673  visExtentMap.find(visAction);
2674  if (i != visExtentMap.end()) extent = i->second;
2675  if (warn) {
2676  if (extent.GetExtentRadius() <= 0.) {
2677  G4cout << "WARNING: User Vis Action extent is null." << G4endl;
2678  }
2679  }
2680 
2681  G4VModel* model = new G4CallbackModel<G4VUserVisAction>(visAction);
2682  model->SetType("User Vis Action");
2683  model->SetGlobalTag(name);
2684  model->SetGlobalDescription(name);
2685  model->SetExtent(extent);
2686  G4bool successful = false;;
2687  switch (type) {
2688  case runDuration:
2689  successful = pScene -> AddRunDurationModel (model, warn);
2690  break;
2691  case endOfEvent:
2692  successful = pScene -> AddEndOfEventModel (model, warn);
2693  break;
2694  case endOfRun:
2695  successful = pScene -> AddEndOfRunModel (model, warn);
2696  break;
2697  }
2698  if (successful && verbosity >= G4VisManager::confirmations) {
2699  const G4String& currentSceneName = pScene -> GetName ();
2700  G4cout << "User Vis Action added to scene \""
2701  << currentSceneName << "\"";
2702  if (verbosity >= G4VisManager::parameters) {
2703  G4cout << "\n with extent " << extent;
2704  }
2705  G4cout << G4endl;
2706  }
2707  else G4VisCommandsSceneAddUnsuccessful(verbosity);
2708 }
2709 
2711 
2713  G4bool omitable;
2714  fpCommand = new G4UIcommand ("/vis/scene/add/volume", this);
2715  fpCommand -> SetGuidance
2716  ("Adds a physical volume to current scene, with optional clipping volume.");
2717  fpCommand -> SetGuidance
2718  ("If physical-volume-name is \"world\" (the default), the top of the"
2719  "\nmain geometry tree (material world) is added. If \"worlds\", the"
2720  "\ntop of all worlds - material world and parallel worlds, if any - are"
2721  "\nadded. Otherwise a search of all worlds is made, taking the first"
2722  "\nmatching occurence only. To see a representation of the geometry"
2723  "\nhierarchy of the worlds, try \"/vis/drawTree [worlds]\" or one of the"
2724  "\ndriver/browser combinations that have the required functionality, e.g., HepRep.");
2725  fpCommand -> SetGuidance
2726  ("If clip-volume-type is specified, the subsequent parameters are used to"
2727  "\nto define a clipping volume. For example,"
2728  "\n\"/vis/scene/add/volume ! ! ! -box km 0 1 0 1 0 1\" will draw the world"
2729  "\nwith the positive octant cut away. (If the Boolean Processor issues"
2730  "\nwarnings try replacing 0 by 0.000000001 or something.)");
2731  fpCommand -> SetGuidance
2732  ("If clip-volume-type is prepended with '-', the clip-volume is subtracted"
2733  "\n(cutaway). (This is the default if there is no prepended character.)"
2734  "\nIf '*' is prepended, the intersection of the physical-volume and the"
2735  "\nclip-volume is made. (You can make a section/DCUT with a thin box, for"
2736  "\nexample).");
2737  fpCommand -> SetGuidance
2738  ("For \"box\", the parameters are xmin,xmax,ymin,ymax,zmin,zmax."
2739  "\nOnly \"box\" is programmed at present.");
2740  G4UIparameter* parameter;
2741  parameter = new G4UIparameter ("physical-volume-name", 's', omitable = true);
2742  parameter -> SetDefaultValue ("world");
2743  fpCommand -> SetParameter (parameter);
2744  parameter = new G4UIparameter ("copy-no", 'i', omitable = true);
2745  parameter -> SetGuidance
2746  ("If negative, matches any copy no. First name match is taken.");
2747  parameter -> SetDefaultValue (-1);
2748  fpCommand -> SetParameter (parameter);
2749  parameter = new G4UIparameter ("depth-of-descent", 'i', omitable = true);
2750  parameter -> SetGuidance
2751  ("Depth of descent of geometry hierarchy. Default = unlimited depth.");
2752  parameter -> SetDefaultValue (G4Scene::UNLIMITED);
2753  fpCommand -> SetParameter (parameter);
2754  parameter = new G4UIparameter ("clip-volume-type", 's', omitable = true);
2755  parameter -> SetParameterCandidates("none box -box *box");
2756  parameter -> SetDefaultValue ("none");
2757  parameter -> SetGuidance("[-|*]type. See general guidance.");
2758  fpCommand -> SetParameter (parameter);
2759  parameter = new G4UIparameter ("parameter-unit", 's', omitable = true);
2760  parameter -> SetDefaultValue ("m");
2761  fpCommand -> SetParameter (parameter);
2762  parameter = new G4UIparameter ("parameter-1", 'd', omitable = true);
2763  parameter -> SetDefaultValue (0.);
2764  fpCommand -> SetParameter (parameter);
2765  parameter = new G4UIparameter ("parameter-2", 'd', omitable = true);
2766  parameter -> SetDefaultValue (0.);
2767  fpCommand -> SetParameter (parameter);
2768  parameter = new G4UIparameter ("parameter-3", 'd', omitable = true);
2769  parameter -> SetDefaultValue (0.);
2770  fpCommand -> SetParameter (parameter);
2771  parameter = new G4UIparameter ("parameter-4", 'd', omitable = true);
2772  parameter -> SetDefaultValue (0.);
2773  fpCommand -> SetParameter (parameter);
2774  parameter = new G4UIparameter ("parameter-5", 'd', omitable = true);
2775  parameter -> SetDefaultValue (0.);
2776  fpCommand -> SetParameter (parameter);
2777  parameter = new G4UIparameter ("parameter-6", 'd', omitable = true);
2778  parameter -> SetDefaultValue (0.);
2779  fpCommand -> SetParameter (parameter);
2780 }
2781 
2783  delete fpCommand;
2784 }
2785 
2787  return "world 0 -1";
2788 }
2789 
2791  G4String newValue) {
2792 
2794  G4bool warn = verbosity >= G4VisManager::warnings;
2795 
2796  G4Scene* pScene = fpVisManager->GetCurrentScene();
2797  if (!pScene) {
2798  if (verbosity >= G4VisManager::errors) {
2799  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
2800  }
2801  return;
2802  }
2803 
2804  G4String name, clipVolumeType, parameterUnit;
2805  G4int copyNo, requestedDepthOfDescent;
2806  G4double param1, param2, param3, param4, param5, param6;
2807  std::istringstream is (newValue);
2808  is >> name >> copyNo >> requestedDepthOfDescent
2809  >> clipVolumeType >> parameterUnit
2810  >> param1 >> param2 >> param3 >> param4 >> param5 >> param6;
2812  G4PhysicalVolumeModel::subtraction; // Default subtraction mode.
2813  if (clipVolumeType[size_t(0)] == '-') {
2814  clipVolumeType = clipVolumeType.substr(1); // Remove first character.
2815  } else if (clipVolumeType[size_t(0)] == '*') {
2816  clippingMode = G4PhysicalVolumeModel::intersection;
2817  clipVolumeType = clipVolumeType.substr(1);
2818  }
2819  G4double unit = G4UIcommand::ValueOf(parameterUnit);
2820  param1 *= unit; param2 *= unit; param3 *= unit;
2821  param4 *= unit; param5 *= unit; param6 *= unit;
2822 
2823  G4TransportationManager* transportationManager =
2825 
2826  size_t nWorlds = transportationManager->GetNoWorlds();
2827  if (nWorlds > 1) { // Parallel worlds in operation...
2828  if (verbosity >= G4VisManager::warnings) {
2829  static G4bool warned = false;
2830  if (!warned && name != "worlds") {
2831  G4cout <<
2832  "WARNING: Parallel worlds in operation. To visualise, specify"
2833  "\n \"worlds\" or the parallel world volume or sub-volume name"
2834  "\n and control visibility with /vis/geometry."
2835  << G4endl;
2836  std::vector<G4VPhysicalVolume*>::iterator iterWorld =
2837  transportationManager->GetWorldsIterator();
2838  for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
2839  G4cout << " World " << i << ": " << (*iterWorld)->GetName()
2840  << G4endl;
2841  warned = true;
2842  }
2843  }
2844  }
2845  }
2846 
2847  // Get the world (the initial value of the iterator points to the mass world).
2848  G4VPhysicalVolume* world = *(transportationManager->GetWorldsIterator());
2849 
2850  if (!world) {
2851  if (verbosity >= G4VisManager::errors) {
2852  G4cerr <<
2853  "ERROR: G4VisCommandSceneAddVolume::SetNewValue:"
2854  "\n No world. Maybe the geometry has not yet been defined."
2855  "\n Try \"/run/initialize\""
2856  << G4endl;
2857  }
2858  return;
2859  }
2860 
2861  std::vector<G4PhysicalVolumeModel*> models;
2862  std::vector<G4VPhysicalVolume*> foundVolumes;
2863  G4VPhysicalVolume* foundWorld = 0;
2865  typedef std::vector<PVNodeID> PVPath;
2866  PVPath foundFullPVPath;
2867  std::vector<G4int> foundDepths;
2868  std::vector<G4Transform3D> transformations;
2869 
2870  if (name == "world") {
2871 
2872  models.push_back
2873  (new G4PhysicalVolumeModel (world, requestedDepthOfDescent));
2874  foundVolumes.push_back(world);
2875  foundDepths.push_back(0);
2876  transformations.push_back(G4Transform3D());
2877 
2878  } else if (name == "worlds") {
2879 
2880  if (nWorlds == 0) {
2881  if (verbosity >= G4VisManager::warnings) {
2882  G4cout <<
2883  "WARNING: G4VisCommandSceneAddVolume::SetNewValue:"
2884  "\n Parallel worlds requested but none exist."
2885  "\n Just adding material world."
2886  << G4endl;
2887  }
2888  }
2889  std::vector<G4VPhysicalVolume*>::iterator iterWorld =
2890  transportationManager->GetWorldsIterator();
2891  for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
2892  models.push_back
2893  (new G4PhysicalVolumeModel (*iterWorld, requestedDepthOfDescent));
2894  foundVolumes.push_back(*iterWorld);
2895  foundDepths.push_back(0);
2896  transformations.push_back(G4Transform3D());
2897  }
2898 
2899  } else { // Search all worlds...
2900 
2901  std::vector<G4VPhysicalVolume*>::iterator iterWorld =
2902  transportationManager->GetWorldsIterator();
2903  for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
2904  G4PhysicalVolumeModel searchModel (*iterWorld); // Unlimited depth.
2905  G4ModelingParameters mp; // Default - no culling.
2906  searchModel.SetModelingParameters (&mp);
2907  G4PhysicalVolumeSearchScene searchScene (&searchModel, name, copyNo);
2908  searchModel.DescribeYourselfTo (searchScene); // Initiate search.
2909  G4VPhysicalVolume* foundVolume = searchScene.GetFoundVolume ();
2910  if (foundVolume) {
2911  foundWorld = *iterWorld;
2912  foundVolumes.push_back(foundVolume);
2913  foundFullPVPath = searchScene.GetFoundFullPVPath();
2914  foundDepths.push_back(searchScene.GetFoundDepth());
2915  transformations.push_back(searchScene.GetFoundTransformation());
2916  break;
2917  }
2918  }
2919 
2920  if (foundVolumes.size()) {
2921  for (size_t i = 0; i < foundVolumes.size(); ++i) {
2922  G4PhysicalVolumeModel* foundPVModel = new G4PhysicalVolumeModel
2923  (foundVolumes[i], requestedDepthOfDescent, transformations[i]);
2924  foundFullPVPath.pop_back(); // "Base" is "Found - 1".
2925  foundPVModel->SetBaseFullPVPath(foundFullPVPath);
2926  models.push_back(foundPVModel);
2927  }
2928  } else {
2929  if (verbosity >= G4VisManager::errors) {
2930  G4cerr << "ERROR: Volume \"" << name << "\"";
2931  if (copyNo >= 0) {
2932  G4cerr << ", copy no. " << copyNo << ",";
2933  }
2934  G4cerr << " not found." << G4endl;
2935  }
2936  return;
2937  }
2938  }
2939 
2940  if (clipVolumeType == "box") {
2941  const G4double dX = (param2 - param1) / 2.;
2942  const G4double dY = (param4 - param3) / 2.;
2943  const G4double dZ = (param6 - param5) / 2.;
2944  const G4double x0 = (param2 + param1) / 2.;
2945  const G4double y0 = (param4 + param3) / 2.;
2946  const G4double z0 = (param6 + param5) / 2.;
2947  G4VSolid* clippingSolid =
2948  new G4DisplacedSolid
2949  ("_displaced_clipping_box",
2950  new G4Box("_clipping_box",dX,dY,dZ),
2951  G4Translate3D(x0,y0,z0));
2952  for (size_t i = 0; i < foundVolumes.size(); ++i) {
2953  models[i]->SetClippingSolid(clippingSolid);
2954  models[i]->SetClippingMode(clippingMode);
2955  }
2956  } // If any other shape consider NumberOfRotationSides!!!!!!!!!!!
2957 
2958  const G4String& currentSceneName = pScene -> GetName ();
2959  G4bool failure = true;
2960  for (size_t i = 0; i < foundVolumes.size(); ++i) {
2961  G4bool successful = pScene -> AddRunDurationModel (models[i], warn);
2962  if (successful) {
2963  failure = false;
2964  if (verbosity >= G4VisManager::confirmations) {
2965  G4cout << "First occurrence of \""
2966  << foundVolumes[i] -> GetName ()
2967  << "\"";
2968  if (copyNo >= 0) {
2969  G4cout << ", copy no. " << copyNo << ",";
2970  }
2971  G4cout << "\n found ";
2972  if (foundWorld)
2973  G4cout << "in world \"" << foundWorld->GetName() << "\" ";
2974  G4cout << "at depth " << foundDepths[i]
2975  << ",\n with a requested depth of further descent of ";
2976  if (requestedDepthOfDescent < 0) {
2977  G4cout << "<0 (unlimited)";
2978  }
2979  else {
2980  G4cout << requestedDepthOfDescent;
2981  }
2982  G4cout << ",\n has been added to scene \"" << currentSceneName << "\"."
2983  << G4endl;
2984  }
2985  }
2986  }
2987 
2988  if (failure) {
2990  return;
2991  }
2992 
2993  UpdateVisManagerScene (currentSceneName);
2994 }
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:152
G4String GetCurrentValue(G4UIcommand *command)
void SetColour(const G4Colour &)
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
G4Logo(G4double height, const G4VisAttributes &)
void SetGlobalTag(const G4String &)
void SetNewValue(G4UIcommand *command, G4String newValue)
HepGeom::RotateX3D G4RotateX3D
Definition: G4Text.hh:73
G4String GetCurrentValue(G4UIcommand *command)
HepGeom::RotateY3D G4RotateY3D
Definition: test07.cc:36
G4double GetXmin() const
Definition: G4VisExtent.hh:89
CLHEP::Hep3Vector G4ThreeVector
CLHEP::HepRotation G4RotationMatrix
static G4Colour fCurrentColour
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
std::vector< G4VPhysicalVolume * >::iterator GetWorldsIterator()
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetLayout(Layout)
G4String GetCurrentValue(G4UIcommand *command)
Definition: G4Box.hh:64
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValue)
void UpdateVisManagerScene(const G4String &sceneName="")
G4String GetCurrentValue(G4UIcommand *command)
static const G4double d2
void SetLineWidth(G4double)
Definition: G4Tubs.hh:85
static G4Text::Layout fCurrentTextLayout
Line(G4double x1, G4double y1, G4double z1, G4double x2, G4double y2, G4double z2, G4double width, const G4Colour &colour)
const G4ViewParameters & GetViewParameters() const
G4double GetXmax() const
Definition: G4VisExtent.hh:90
const G4ModelingParameters * GetModelingParameters() const
static G4double angle[DIM]
void SetDefaultValue(const char *theDefaultValue)
virtual void BeginPrimitives(const G4Transform3D &objectTransformation=G4Transform3D())=0
#define width
const std::vector< const G4Event * > * GetEventVector() const
Definition: G4Run.hh:115
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetNewValue(G4UIcommand *command, G4String newValue)
HepGeom::Point3D< G4double > G4Point3D
Definition: G4Point3D.hh:35
HepGeom::Vector3D< G4double > G4Vector3D
Definition: G4Vector3D.hh:35
const char * name(G4int ptype)
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
static G4Colour Brown()
Definition: G4Colour.hh:147
static constexpr double rad
Definition: G4SIunits.hh:149
Direction
Definition: G4Scale.hh:42
void SetExtent(const G4VisExtent &)
const G4VisExtent & GetExtent() const
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
G4int GetVerboseLevel() const
Definition: G4UImanager.hh:227
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValue)
static G4double fCurrentTextSize
Definition: test07.cc:36
int G4int
Definition: G4Types.hh:78
void SetModelingParameters(const G4ModelingParameters *)
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
HepGeom::RotateZ3D G4RotateZ3D
const G4Run * GetCurrentRun() const
void SetVerboseLevel(G4int val)
Definition: G4UImanager.hh:225
void SetForceSolid(G4bool=true)
void SetTransformation(const G4Transform3D &)
static void G4VisCommandsSceneAddUnsuccessful(G4VisManager::Verbosity verbosity)
virtual void AddPrimitive(const G4Polyline &)=0
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
G4int GetEventID() const
Definition: G4Event.hh:151
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
G4String GetCurrentValue(G4UIcommand *command)
G4String GetCurrentValue(G4UIcommand *command)
Line2D(G4double x1, G4double y1, G4double x2, G4double y2, G4double width, const G4Colour &colour)
G4String GetCurrentValue(G4UIcommand *command)
static G4StateManager * GetStateManager()
void AddVisAction(const G4String &name, G4VUserVisAction *, G4Scene *, ActionType, G4VisManager::Verbosity)
G4double GetExtentRadius() const
Definition: G4VisExtent.cc:73
const G4Vector3D & GetViewpointDirection() const
void SetNewValue(G4UIcommand *command, G4String newValue)
G4GLOB_DLL std::ostream G4cout
const G4Event * GetEvent() const
void SetNewValue(G4UIcommand *command, G4String newValue)
const G4VisExtent & GetExtent() const
const G4String & GetGlobalDescription() const
const G4String & GetName() const
void SetNewValue(G4UIcommand *command, G4String newValue)
static G4bool ConvertToBool(const char *st)
Definition: G4UIcommand.cc:425
void SetNewValue(G4UIcommand *command, G4String newValue)
G4double GetYmax() const
Definition: G4VisExtent.hh:92
bool G4bool
Definition: G4Types.hh:79
G4String GetCurrentValue(G4UIcommand *command)
G4PhysicalVolumeModel::G4PhysicalVolumeNodeID PVNodeID
G4Polyhedron * CreatePolyhedron() const
Extent(G4double xmin, G4double xmax, G4double ymin, G4double ymax, G4double zmin, G4double zmax)
G4String GetCurrentValue(G4UIcommand *command)
static G4MTRunManager * GetMasterRunManager()
void SetType(const G4String &)
G4int GetRunID() const
Definition: G4Run.hh:76
Definition: G4Run.hh:46
static const G4String & GetGuidanceString()
Definition: G4Scale.cc:66
static G4LogicalVolumeStore * GetInstance()
const std::vector< UserVisAction > & GetEndOfEventUserVisActions() const
HepGeom::Transform3D G4Transform3D
std::vector< PVNodeID > PVPath
G4double GetZmax() const
Definition: G4VisExtent.hh:94
G4ApplicationState GetCurrentState() const
const std::map< G4VUserVisAction *, G4VisExtent > & GetUserVisActionExtents() const
void SetBaseFullPVPath(const std::vector< G4PhysicalVolumeNodeID > &baseFullPVPath)
void SetNewValue(G4UIcommand *command, G4String newValue)
G4bool IsMultithreadedApplication()
Definition: G4Threading.cc:152
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
void SetVisAttributes(const G4VisAttributes *)
Definition: G4Visible.cc:80
const std::vector< UserVisAction > & GetRunDurationUserVisActions() const
static G4TransportationManager * GetTransportationManager()
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValue)
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
const std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > & GetFoundFullPVPath() const
virtual void EndPrimitives2D()=0
G4String GetCurrentValue(G4UIcommand *command)
void SetOffset(double dx, double dy)
void SetNewValue(G4UIcommand *command, G4String newValue)
virtual void BeginPrimitives2D(const G4Transform3D &objectTransformation=G4Transform3D())=0
G4double StoD(G4String s)
static G4double ValueOf(const char *unitName)
Definition: G4UIcommand.cc:308
Layout
Definition: G4Text.hh:77
G4VPhysicalVolume * GetFoundVolume() const
const std::map< G4String, G4AttDef > * GetAttDefs() const
G4String GetCurrentValue(G4UIcommand *command)
static G4double fCurrentLineWidth
G4double GetZmin() const
Definition: G4VisExtent.hh:93
static G4Colour fCurrentTextColour
static Verbosity GetVerbosity()
HepGeom::Translate3D G4Translate3D
G4double GetYmin() const
Definition: G4VisExtent.hh:91
G4UIcmdWithoutParameter * fpCommand
G4int GetNumberOfEventToBeProcessed() const
Definition: G4Run.hh:83
size_t GetNoWorlds() const
G4String GetCurrentValue(G4UIcommand *command)
#define G4endl
Definition: G4ios.hh:61
void SetNewValue(G4UIcommand *command, G4String newValue)
G4UIcmdWithoutParameter * fpCommand
void SetNewValue(G4UIcommand *command, G4String newValue)
static constexpr double pi
Definition: G4SIunits.hh:75
G4VViewer * GetCurrentViewer() const
virtual void EndPrimitives()=0
const G4Transform3D & GetFoundTransformation() const
static constexpr double halfpi
Definition: G4SIunits.hh:77
const std::vector< UserVisAction > & GetEndOfRunUserVisActions() const
G4String GetCurrentValue(G4UIcommand *command)
G4String GetCurrentValue(G4UIcommand *command)
double G4double
Definition: G4Types.hh:76
static constexpr double deg
Definition: G4SIunits.hh:152
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetGuidance(const char *theGuidance)
const G4Vector3D & GetUpVector() const
G4String GetCurrentValue(G4UIcommand *command)
Arrow2D(G4double x1, G4double y1, G4double x2, G4double y2, G4double width, const G4Colour &colour)
G4ApplicationState
void SetGlobalDescription(const G4String &)
G4int G4GetThreadId()
Definition: G4Threading.cc:144
G4String GetCurrentValue(G4UIcommand *command)
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:446
G4Scene * GetCurrentScene() const
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
void SetNewValue(G4UIcommand *command, G4String newValue)
G4GLOB_DLL std::ostream G4cerr
void SetScreenSize(G4double)
void DescribeYourselfTo(G4VGraphicsScene &)
static G4VisManager * fpVisManager
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const