Geant4  10.02.p02
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 97702 2016-06-07 10:39:30Z 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 \"unitcolour\" is \"auto\", x, y and z will be red, green and blue"
273  "\n respectively. Otherwise choose from 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 ("unitcolour", '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) and readout geometry"
1094  "\n(if any). Note: voxels are not constructed until start of run -"
1095  "\n \"/run/beamOn\". (For voxels without a run, \"/run/beamOn 0\".)");
1096  G4UIparameter* parameter;
1097  parameter = new G4UIparameter ("logical-volume-name", 's', omitable = false);
1098  fpCommand -> SetParameter (parameter);
1099  parameter = new G4UIparameter ("depth-of-descent", 'i', omitable = true);
1100  parameter -> SetGuidance ("Depth of descent of geometry hierarchy.");
1101  parameter -> SetDefaultValue (1);
1102  fpCommand -> SetParameter (parameter);
1103  parameter = new G4UIparameter ("booleans-flag", 'b', omitable = true);
1104  parameter -> SetDefaultValue (true);
1105  fpCommand -> SetParameter (parameter);
1106  parameter = new G4UIparameter ("voxels-flag", 'b', omitable = true);
1107  parameter -> SetDefaultValue (true);
1108  fpCommand -> SetParameter (parameter);
1109  parameter = new G4UIparameter ("readout-flag", 'b', omitable = true);
1110  parameter -> SetDefaultValue (true);
1111  fpCommand -> SetParameter (parameter);
1112  parameter = new G4UIparameter ("axes-flag", 'b', omitable = true);
1113  parameter -> SetDefaultValue (true);
1114  parameter -> SetGuidance ("Set \"false\" to suppress axes.");
1115  fpCommand -> SetParameter (parameter);
1116 }
1117 
1119  delete fpCommand;
1120 }
1121 
1123  return "";
1124 }
1125 
1127  G4String newValue) {
1128 
1130  G4bool warn(verbosity >= G4VisManager::warnings);
1131 
1132  G4Scene* pScene = fpVisManager->GetCurrentScene();
1133  if (!pScene) {
1134  if (verbosity >= G4VisManager::errors) {
1135  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
1136  }
1137  return;
1138  }
1139 
1140  G4String name;
1141  G4int requestedDepthOfDescent;
1142  G4String booleansString, voxelsString, readoutString, axesString;
1143  std::istringstream is (newValue);
1144  is >> name >> requestedDepthOfDescent
1145  >> booleansString >> voxelsString >> readoutString >> axesString;
1146  G4bool booleans = G4UIcommand::ConvertToBool(booleansString);
1147  G4bool voxels = G4UIcommand::ConvertToBool(voxelsString);
1148  G4bool readout = G4UIcommand::ConvertToBool(readoutString);
1149  G4bool axes = G4UIcommand::ConvertToBool(axesString);
1150 
1152  int nLV = pLVStore -> size ();
1153  int iLV;
1154  G4LogicalVolume* pLV = 0;
1155  for (iLV = 0; iLV < nLV; iLV++ ) {
1156  pLV = (*pLVStore) [iLV];
1157  if (pLV -> GetName () == name) break;
1158  }
1159  if (iLV == nLV) {
1160  if (verbosity >= G4VisManager::errors) {
1161  G4cerr << "ERROR: Logical volume " << name
1162  << " not found in logical volume store." << G4endl;
1163  }
1164  return;
1165  }
1166 
1167  const std::vector<G4Scene::Model>& rdModelList =
1168  pScene -> GetRunDurationModelList();
1169  std::vector<G4Scene::Model>::const_iterator i;
1170  for (i = rdModelList.begin(); i != rdModelList.end(); ++i) {
1171  if (i->fpModel->GetGlobalDescription().find("Volume") != std::string::npos) break;
1172  }
1173  if (i != rdModelList.end()) {
1174  if (verbosity >= G4VisManager::errors) {
1175  G4cout << "There is already a volume, \""
1176  << i->fpModel->GetGlobalDescription()
1177  << "\",\n in the run-duration model list of scene \""
1178  << pScene -> GetName()
1179  << "\".\n Your logical volume must be the only volume in the scene."
1180  << "\n Create a new scene and try again:"
1181  << "\n /vis/specify " << name
1182  << "\n or"
1183  << "\n /vis/scene/create"
1184  << "\n /vis/scene/add/logicalVolume " << name
1185  << "\n /vis/sceneHandler/attach"
1186  << "\n (and also, if necessary, /vis/viewer/flush)"
1187  << G4endl;
1188  }
1189  return;
1190  }
1191 
1193  (pLV, requestedDepthOfDescent, booleans, voxels, readout);
1194  const G4String& currentSceneName = pScene -> GetName ();
1195  G4bool successful = pScene -> AddRunDurationModel (model, warn);
1196 
1197  if (successful) {
1198 
1199  G4bool axesSuccessful = false;
1200  if (axes) {
1201  const G4double radius = model->GetExtent().GetExtentRadius();
1202  const G4double axisLengthMax = radius / 2.;
1203  const G4double intLog10Length = std::floor(std::log10(axisLengthMax));
1204  G4double axisLength = std::pow(10,intLog10Length);
1205  if (5.*axisLength < axisLengthMax) axisLength *= 5.;
1206  else if (2.*axisLength < axisLengthMax) axisLength *= 2.;
1207  const G4double axisWidth = axisLength / 20.;
1208  G4VModel* axesModel = new G4AxesModel(0.,0.,0.,axisLength,axisWidth);
1209  axesSuccessful = pScene -> AddRunDurationModel (axesModel, warn);
1210  }
1211 
1212 // if (verbosity >= G4VisManager::warnings) {
1213 // const std::map<G4String,G4AttDef>* attDefs = model->GetAttDefs();
1214 // std::vector<G4AttValue>* attValues = model->CreateCurrentAttValues();
1215 // G4cout << G4AttCheck(attValues, attDefs);
1216 // delete attValues;
1217 // }
1218 
1219  if (verbosity >= G4VisManager::confirmations) {
1220  G4cout << "Logical volume \"" << pLV -> GetName ()
1221  << " with requested depth of descent "
1222  << requestedDepthOfDescent
1223  << ",\n with";
1224  if (!booleans) G4cout << "out";
1225  G4cout << " boolean components, with";
1226  if (!voxels) G4cout << "out";
1227  G4cout << " voxels and with";
1228  if (!readout) G4cout << "out";
1229  G4cout << " readout geometry,"
1230  << "\n has been added to scene \"" << currentSceneName << "\".";
1231  if (axes) {
1232  if (axesSuccessful) {
1233  G4cout <<
1234  "\n Axes have also been added at the origin of local cooordinates.";
1235  } else {
1236  G4cout <<
1237  "\n Axes have not been added for some reason possibly stated above.";
1238  }
1239  }
1240  G4cout << G4endl;
1241  }
1242  }
1243  else {
1245  return;
1246  }
1247 
1248  UpdateVisManagerScene (currentSceneName);
1249 }
1250 
1251 
1253 
1255  G4bool omitable;
1256  fpCommand = new G4UIcommand ("/vis/scene/add/logo", this);
1257  fpCommand -> SetGuidance ("Adds a G4 logo to the current scene.");
1258  fpCommand -> SetGuidance
1259  ("If \"unit\" is \"auto\", height is roughly one tenth of scene extent.");
1260  fpCommand -> SetGuidance
1261  ("\"direction\" is that of outward-facing normal to front face of logo."
1262  "\nIf \"direction\" is \"auto\", logo faces the user in the current viewer.");
1263  fpCommand -> SetGuidance
1264  ("\nIf \"placement\" is \"auto\", logo is placed at bottom right of screen"
1265  "\n when viewed from logo direction.");
1266  G4UIparameter* parameter;
1267  parameter = new G4UIparameter ("height", 'd', omitable = true);
1268  parameter->SetDefaultValue (1.);
1269  fpCommand->SetParameter (parameter);
1270  parameter = new G4UIparameter ("unit", 's', omitable = true);
1271  parameter->SetDefaultValue ("auto");
1272  fpCommand->SetParameter (parameter);
1273  parameter = new G4UIparameter ("direction", 's', omitable = true);
1274  parameter->SetGuidance ("auto|[-]x|[-]y|[-]z");
1275  parameter->SetDefaultValue ("auto");
1276  fpCommand->SetParameter (parameter);
1277  parameter = new G4UIparameter ("red", 'd', omitable = true);
1278  parameter->SetDefaultValue (0.);
1279  fpCommand->SetParameter (parameter);
1280  parameter = new G4UIparameter ("green", 'd', omitable = true);
1281  parameter->SetDefaultValue (1.);
1282  fpCommand->SetParameter (parameter);
1283  parameter = new G4UIparameter ("blue", 'd', omitable = true);
1284  parameter->SetDefaultValue (0.);
1285  fpCommand->SetParameter (parameter);
1286  parameter = new G4UIparameter ("placement", 's', omitable = true);
1287  parameter -> SetParameterCandidates("auto manual");
1288  parameter->SetDefaultValue ("auto");
1289  fpCommand->SetParameter (parameter);
1290  parameter = new G4UIparameter ("xmid", 'd', omitable = true);
1291  parameter->SetDefaultValue (0.);
1292  fpCommand->SetParameter (parameter);
1293  parameter = new G4UIparameter ("ymid", 'd', omitable = true);
1294  parameter->SetDefaultValue (0.);
1295  fpCommand->SetParameter (parameter);
1296  parameter = new G4UIparameter ("zmid", 'd', omitable = true);
1297  parameter->SetDefaultValue (0.);
1298  fpCommand->SetParameter (parameter);
1299  parameter = new G4UIparameter ("unit", 's', omitable = true);
1300  parameter->SetDefaultValue ("m");
1301  fpCommand->SetParameter (parameter);
1302 }
1303 
1305  delete fpCommand;
1306 }
1307 
1309  return "";
1310 }
1311 
1313 
1315  G4bool warn = verbosity >= G4VisManager::warnings;
1316 
1317  G4Scene* pScene = fpVisManager->GetCurrentScene();
1318  if (!pScene) {
1319  if (verbosity >= G4VisManager::errors) {
1320  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
1321  }
1322  return;
1323  } else {
1324  if (pScene->GetExtent().GetExtentRadius() <= 0.) {
1325  if (verbosity >= G4VisManager::errors) {
1326  G4cerr
1327  << "ERROR: Scene has no extent. Add volumes or use \"/vis/scene/add/extent\"."
1328  << G4endl;
1329  }
1330  return;
1331  }
1332  }
1333 
1334  G4VViewer* pViewer = fpVisManager->GetCurrentViewer();
1335  if (!pViewer) {
1336  if (verbosity >= G4VisManager::errors) {
1337  G4cerr <<
1338  "ERROR: G4VisCommandSceneAddLogo::SetNewValue: no viewer."
1339  "\n Auto direction needs a viewer."
1340  << G4endl;
1341  }
1342  return;
1343  }
1344 
1345  G4double userHeight, red, green, blue, xmid, ymid, zmid;
1346  G4String userHeightUnit, direction, auto_manual, positionUnit;
1347  std::istringstream is (newValue);
1348  is >> userHeight >> userHeightUnit >> direction
1349  >> red >> green >> blue
1350  >> auto_manual
1351  >> xmid >> ymid >> zmid >> positionUnit;
1352 
1353  G4double height = userHeight;
1354  const G4VisExtent& sceneExtent = pScene->GetExtent(); // Existing extent.
1355  if (userHeightUnit == "auto") {
1356  height *= 0.2 * sceneExtent.GetExtentRadius();
1357  } else {
1358  height *= G4UIcommand::ValueOf(userHeightUnit);
1359  }
1360 
1361  G4double unit = G4UIcommand::ValueOf(positionUnit);
1362  xmid *= unit; ymid *= unit; zmid *= unit;
1363 
1364  Direction logoDirection = X; // Initialise to keep some compilers happy.
1365  if (direction == "auto") {
1366  // Take cue from viewer
1367  const G4Vector3D& vp =
1369  if (vp.x() > vp.y() && vp.x() > vp.z()) logoDirection = X;
1370  else if (vp.x() < vp.y() && vp.x() < vp.z()) logoDirection = minusX;
1371  else if (vp.y() > vp.x() && vp.y() > vp.z()) logoDirection = Y;
1372  else if (vp.y() < vp.x() && vp.y() < vp.z()) logoDirection = minusY;
1373  else if (vp.z() > vp.x() && vp.z() > vp.y()) logoDirection = Z;
1374  else if (vp.z() < vp.x() && vp.z() < vp.y()) logoDirection = minusZ;
1375  }
1376  else if (direction(0) == 'x') logoDirection = X;
1377  else if (direction(0) == 'y') logoDirection = Y;
1378  else if (direction(0) == 'z') logoDirection = Z;
1379  else if (direction(0) == '-') {
1380  if (direction(1) == 'x') logoDirection = minusX;
1381  else if (direction(1) == 'y') logoDirection = minusY;
1382  else if (direction(1) == 'z') logoDirection = minusZ;
1383  } else {
1384  if (verbosity >= G4VisManager::errors) {
1385  G4cerr << "ERROR: Unrecogniseed direction: \""
1386  << direction << "\"." << G4endl;
1387  return;
1388  }
1389  }
1390 
1391  G4bool autoPlacing = false; if (auto_manual == "auto") autoPlacing = true;
1392  // Parameters read and interpreted.
1393 
1394  // Current scene extent
1395  const G4double xmin = sceneExtent.GetXmin();
1396  const G4double xmax = sceneExtent.GetXmax();
1397  const G4double ymin = sceneExtent.GetYmin();
1398  const G4double ymax = sceneExtent.GetYmax();
1399  const G4double zmin = sceneExtent.GetZmin();
1400  const G4double zmax = sceneExtent.GetZmax();
1401 
1402  // Test existing extent and issue warnings...
1403  G4bool worried = false;
1404  if (sceneExtent.GetExtentRadius() == 0) {
1405  worried = true;
1406  if (verbosity >= G4VisManager::warnings) {
1407  G4cout <<
1408  "WARNING: Existing scene does not yet have any extent."
1409  "\n Maybe you have not yet added any geometrical object."
1410  << G4endl;
1411  }
1412  }
1413 
1414  // Useful constants, etc...
1415  const G4double halfHeight(height / 2.);
1416  const G4double comfort(0.01); // 0.15 seems too big. 0.05 might be better.
1417  const G4double freeHeightFraction (1. + 2. * comfort);
1418 
1419  // Test existing scene for room...
1420  G4bool room = true;
1421  switch (logoDirection) {
1422  case X:
1423  case minusX:
1424  if (freeHeightFraction * (xmax - xmin) < height) room = false;
1425  break;
1426  case Y:
1427  case minusY:
1428  if (freeHeightFraction * (ymax - ymin) < height) room = false;
1429  break;
1430  case Z:
1431  case minusZ:
1432  if (freeHeightFraction * (zmax - zmin) < height) room = false;
1433  break;
1434  }
1435  if (!room) {
1436  worried = true;
1437  if (verbosity >= G4VisManager::warnings) {
1438  G4cout <<
1439  "WARNING: Not enough room in existing scene. Maybe logo is too large."
1440  << G4endl;
1441  }
1442  }
1443  if (worried) {
1444  if (verbosity >= G4VisManager::warnings) {
1445  G4cout <<
1446  "WARNING: The logo you have asked for is bigger than the existing"
1447  "\n scene. Maybe you have added it too soon. It is recommended that"
1448  "\n you add the logo last so that it can be correctly auto-positioned"
1449  "\n so as not to be obscured by any existing object and so that the"
1450  "\n view parameters can be correctly recalculated."
1451  << G4endl;
1452  }
1453  }
1454 
1455  G4double sxmid(xmid), symid(ymid), szmid(zmid);
1456  if (autoPlacing) {
1457  // Aim to place at bottom right of screen when viewed from logoDirection.
1458  // Give some comfort zone.
1459  const G4double xComfort = comfort * (xmax - xmin);
1460  const G4double yComfort = comfort * (ymax - ymin);
1461  const G4double zComfort = comfort * (zmax - zmin);
1462  switch (logoDirection) {
1463  case X: // y-axis up, z-axis to left?
1464  sxmid = xmax + halfHeight + xComfort;
1465  symid = ymin - yComfort;
1466  szmid = zmin - zComfort;
1467  break;
1468  case minusX: // y-axis up, z-axis to right?
1469  sxmid = xmin - halfHeight - xComfort;
1470  symid = ymin - yComfort;
1471  szmid = zmax + zComfort;
1472  break;
1473  case Y: // z-axis up, x-axis to left?
1474  sxmid = xmin - xComfort;
1475  symid = ymax + halfHeight + yComfort;
1476  szmid = zmin - zComfort;
1477  break;
1478  case minusY: // z-axis up, x-axis to right?
1479  sxmid = xmax + xComfort;
1480  symid = ymin - halfHeight - yComfort;
1481  szmid = zmin - zComfort;
1482  break;
1483  case Z: // y-axis up, x-axis to right?
1484  sxmid = xmax + xComfort;
1485  symid = ymin - yComfort;
1486  szmid = zmax + halfHeight + zComfort;
1487  break;
1488  case minusZ: // y-axis up, x-axis to left?
1489  sxmid = xmin - xComfort;
1490  symid = ymin - yComfort;
1491  szmid = zmin - halfHeight - zComfort;
1492  break;
1493  }
1494  }
1495 
1496  G4Transform3D transform;
1497  switch (logoDirection) {
1498  case X: // y-axis up, z-axis to left?
1499  transform = G4RotateY3D(halfpi);
1500  break;
1501  case minusX: // y-axis up, z-axis to right?
1502  transform = G4RotateY3D(-halfpi);
1503  break;
1504  case Y: // z-axis up, x-axis to left?
1505  transform = G4RotateX3D(-halfpi) * G4RotateZ3D(pi);
1506  break;
1507  case minusY: // z-axis up, x-axis to right?
1508  transform = G4RotateX3D(halfpi);
1509  break;
1510  case Z: // y-axis up, x-axis to right?
1511  // No transformation required.
1512  break;
1513  case minusZ: // y-axis up, x-axis to left?
1514  transform = G4RotateY3D(pi);
1515  break;
1516  }
1517  transform = G4Translate3D(sxmid,symid,szmid) * transform;
1518 
1519  G4VisAttributes visAtts(G4Colour(red, green, blue));
1520  visAtts.SetForceSolid(true); // Always solid.
1521 
1522  G4Logo* logo = new G4Logo(height,visAtts);
1523  G4VModel* model =
1525  model->SetType("G4Logo");
1526  model->SetGlobalTag("G4Logo");
1527  model->SetGlobalDescription("G4Logo: " + newValue);
1528  model->SetTransformation(transform);
1529  // Note: it is the responsibility of the model to act upon this, but
1530  // the extent is in local coordinates...
1531  G4double& h = height;
1532  G4double h2 = h/2.;
1533  G4VisExtent extent(-h,h,-h2,h2,-h2,h2);
1534  model->SetExtent(extent);
1535  // This extent gets "added" to existing scene extent in
1536  // AddRunDurationModel below.
1537  const G4String& currentSceneName = pScene -> GetName ();
1538  G4bool successful = pScene -> AddRunDurationModel (model, warn);
1539  if (successful) {
1540  if (verbosity >= G4VisManager::confirmations) {
1541  G4cout << "G4 Logo of height " << userHeight << ' ' << userHeightUnit
1542  << ", " << direction << "-direction, added to scene \""
1543  << currentSceneName << "\"";
1544  if (verbosity >= G4VisManager::parameters) {
1545  G4cout << "\n with extent " << extent
1546  << "\n at " << transform.getRotation()
1547  << transform.getTranslation();
1548  }
1549  G4cout << G4endl;
1550  }
1551  }
1552  else G4VisCommandsSceneAddUnsuccessful(verbosity);
1553  UpdateVisManagerScene (currentSceneName);
1554 }
1555 
1557 (G4double height, const G4VisAttributes& visAtts):
1558  fVisAtts(visAtts)
1559  {
1560  const G4double& h = height;
1561  const G4double h2 = 0.5 * h; // Half height.
1562  const G4double ri = 0.25 * h; // Inner radius.
1563  const G4double ro = 0.5 * h; // Outer radius.
1564  const G4double ro2 = 0.5 * ro; // Half outer radius.
1565  const G4double w = ro - ri; // Width.
1566  const G4double w2 = 0.5 * w; // Half width.
1567  const G4double d2 = 0.2 * h; // Half depth.
1568  const G4double f1 = 0.05 * h; // left edge of stem of "4".
1569  const G4double f2 = -0.3 * h; // bottom edge of cross of "4".
1570  const G4double e = 1.e-4 * h; // epsilon.
1571  const G4double xt = f1, yt = h2; // Top of slope.
1572  const G4double xb = -h2, yb = f2 + w; // Bottom of slope.
1573  const G4double dx = xt - xb, dy = yt - yb;
1574  const G4double angle = std::atan2(dy,dx);
1575  G4RotationMatrix rm;
1576  rm.rotateZ(angle*rad);
1577  const G4double d = std::sqrt(dx * dx + dy * dy);
1578  const G4double ss = h; // Half height of square subtractor
1579  const G4double y8 = ss; // Choose y of subtractor for outer slope.
1580  const G4double x8 = ((-ss * d - dx * (yt - y8)) / dy) + xt;
1581  G4double y9 = ss; // Choose y of subtractor for inner slope.
1582  G4double x9 = ((-(ss - w) * d - dx * (yt - y8)) / dy) + xt;
1583  // But to get inner, we make a triangle translated by...
1584  const G4double xtr = ss - f1, ytr = -ss - f2 -w;
1585  x9 += xtr; y9 += ytr;
1586 
1587  // G...
1588  G4Tubs tG("tG",ri,ro,d2,0.15*pi,1.85*pi);
1589  G4Box bG("bG",w2,ro2,d2);
1590  G4UnionSolid logoG("logoG",&tG,&bG,G4Translate3D(ri+w2,-ro2,0.));
1591  fpG = logoG.CreatePolyhedron();
1592  fpG->SetVisAttributes(&fVisAtts);
1593  fpG->Transform(G4Translate3D(-0.55*h,0.,0.));
1594 
1595  // 4...
1596  G4Box b1("b1",h2,h2,d2);
1597  G4Box bS("bS",ss,ss,d2+e); // Subtractor.
1598  G4Box bS2("bS2",ss,ss,d2+2.*e); // 2nd Subtractor.
1599  G4SubtractionSolid s1("s1",&b1,&bS,G4Translate3D(f1-ss,f2-ss,0.));
1600  G4SubtractionSolid s2("s2",&s1,&bS,G4Translate3D(f1+ss+w,f2-ss,0.));
1601  G4SubtractionSolid s3("s3",&s2,&bS,G4Translate3D(f1+ss+w,f2+ss+w,0.));
1603  ("s4",&s3,&bS,G4Transform3D(rm,G4ThreeVector(x8,y8,0.)));
1604  G4SubtractionSolid s5 // Triangular hole.
1605  ("s5",&bS,&bS2,G4Transform3D(rm,G4ThreeVector(x9,y9,0.)));
1606  G4SubtractionSolid logo4("logo4",&s4,&s5,G4Translate3D(-xtr,-ytr,0.));
1607  fp4 = logo4.CreatePolyhedron();
1608  /* Experiment with creating own polyhedron...
1609  int nNodes = 4;
1610  int nFaces = 4;
1611  double xyz[][3] = {{0,0,0},{1*m,0,0},{0,1*m,0},{0,0,1*m}};
1612  int faces[][4] = {{1,3,2,0},{1,2,4,0},{1,4,3,0},{2,3,4,0}};
1613  fp4 = new G4Polyhedron();
1614  fp4->createPolyhedron(nNodes,nFaces,xyz,faces);
1615  */
1616  fp4->SetVisAttributes(&fVisAtts);
1617  fp4->Transform(G4Translate3D(0.55*h,0.,0.));
1618 }
1619 
1621  delete fpG;
1622  delete fp4;
1623 }
1624 
1625 void G4VisCommandSceneAddLogo::G4Logo::operator()
1626  (G4VGraphicsScene& sceneHandler, const G4Transform3D& transform) {
1627  sceneHandler.BeginPrimitives(transform);
1628  sceneHandler.AddPrimitive(*fpG);
1629  sceneHandler.AddPrimitive(*fp4);
1630  sceneHandler.EndPrimitives();
1631 }
1632 
1634 
1636  G4bool omitable;
1637  fpCommand = new G4UIcommand ("/vis/scene/add/logo2D", this);
1638  fpCommand -> SetGuidance ("Adds 2D logo to current scene.");
1639  G4UIparameter* parameter;
1640  parameter = new G4UIparameter ("size", 'i', omitable = true);
1641  parameter -> SetGuidance ("Screen size of text in pixels.");
1642  parameter -> SetDefaultValue (48);
1643  fpCommand -> SetParameter (parameter);
1644  parameter = new G4UIparameter ("x-position", 'd', omitable = true);
1645  parameter -> SetGuidance ("x screen position in range -1 < x < 1.");
1646  parameter -> SetDefaultValue (-0.9);
1647  fpCommand -> SetParameter (parameter);
1648  parameter = new G4UIparameter ("y-position", 'd', omitable = true);
1649  parameter -> SetGuidance ("y screen position in range -1 < y < 1.");
1650  parameter -> SetDefaultValue (-0.9);
1651  fpCommand -> SetParameter (parameter);
1652  parameter = new G4UIparameter ("layout", 's', omitable = true);
1653  parameter -> SetGuidance ("Layout, i.e., adjustment: left|centre|right.");
1654  parameter -> SetDefaultValue ("left");
1655  fpCommand -> SetParameter (parameter);
1656 }
1657 
1659  delete fpCommand;
1660 }
1661 
1663  return "";
1664 }
1665 
1667 {
1669  G4bool warn(verbosity >= G4VisManager::warnings);
1670 
1671  G4Scene* pScene = fpVisManager->GetCurrentScene();
1672  if (!pScene) {
1673  if (verbosity >= G4VisManager::errors) {
1674  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
1675  }
1676  return;
1677  }
1678 
1679  G4int size;
1680  G4double x, y;
1681  G4String layoutString;
1682  std::istringstream is(newValue);
1683  is >> size >> x >> y >> layoutString;
1684  G4Text::Layout layout = G4Text::right;
1685  if (layoutString(0) == 'l') layout = G4Text::left;
1686  else if (layoutString(0) == 'c') layout = G4Text::centre;
1687  else if (layoutString(0) == 'r') layout = G4Text::right;
1688 
1689  Logo2D* logo2D = new Logo2D(fpVisManager, size, x, y, layout);
1690  G4VModel* model =
1692  model->SetType("G4Logo2D");
1693  model->SetGlobalTag("G4Logo2D");
1694  model->SetGlobalDescription("G4Logo2D: " + newValue);
1695  const G4String& currentSceneName = pScene -> GetName ();
1696  G4bool successful = pScene -> AddRunDurationModel (model, warn);
1697  if (successful) {
1698  if (verbosity >= G4VisManager::confirmations) {
1699  G4cout << "2D logo has been added to scene \""
1700  << currentSceneName << "\"."
1701  << G4endl;
1702  }
1703  }
1704  else G4VisCommandsSceneAddUnsuccessful(verbosity);
1705  UpdateVisManagerScene (currentSceneName);
1706 }
1707 
1708 void G4VisCommandSceneAddLogo2D::Logo2D::operator()
1709  (G4VGraphicsScene& sceneHandler, const G4Transform3D&)
1710 {
1711  G4Text text("Geant4", G4Point3D(fX, fY, 0.));
1712  text.SetScreenSize(fSize);
1713  text.SetLayout(fLayout);
1714  G4VisAttributes textAtts(G4Colour::Brown());
1715  text.SetVisAttributes(textAtts);
1716  sceneHandler.BeginPrimitives2D();
1717  sceneHandler.AddPrimitive(text);
1718  sceneHandler.EndPrimitives2D();
1719 }
1720 
1722 
1724  G4bool omitable;
1725  fpCommand = new G4UIcommand ("/vis/scene/add/magneticField", this);
1726  fpCommand -> SetGuidance
1727  ("Adds magnetic field representation to current scene.");
1728  fpCommand -> SetGuidance
1729  ("The first parameter is no. of data points per half scene. So, possibly, at"
1730  "\nmaximum, the number of data points sampled is (2*n+1)^3, which can grow"
1731  "\nlarge--be warned!"
1732  "\nYou might find that your scene is cluttered by thousands of arrows for"
1733  "\nthe default number of data points, so try reducing to 2 or 3, e.g:"
1734  "\n /vis/scene/add/magneticField 3"
1735  "\nor, if only a small part of the scene has a field:"
1736  "\n /vis/scene/add/magneticField 50 # or more");
1737  fpCommand -> SetGuidance
1738  ("In the arrow representation, the length of the arrow is proportional"
1739  "\nto the magnitude of the field and the colour is mapped onto the range"
1740  "\nas a fraction of the maximum magnitude: 0->0.5->1 is blue->green->red.");
1741  G4UIparameter* parameter;
1742  parameter = new G4UIparameter ("nDataPointsPerHalfScene", 'i', omitable = true);
1743  parameter -> SetDefaultValue (10);
1744  fpCommand -> SetParameter (parameter);
1745  parameter = new G4UIparameter ("representation", 's', omitable = true);
1746  parameter -> SetParameterCandidates("fullArrow lightArrow");
1747  parameter -> SetDefaultValue ("fullArrow");
1748  fpCommand -> SetParameter (parameter);
1749 }
1750 
1752  delete fpCommand;
1753 }
1754 
1756  return "";
1757 }
1758 
1760 (G4UIcommand*, G4String newValue) {
1761 
1763  G4bool warn(verbosity >= G4VisManager::warnings);
1764 
1765  G4Scene* pScene = fpVisManager->GetCurrentScene();
1766  if (!pScene) {
1767  if (verbosity >= G4VisManager::errors) {
1768  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
1769  }
1770  return;
1771  }
1772 
1773  G4int nDataPointsPerHalfScene;
1774  G4String representation;
1775  std::istringstream iss(newValue);
1776  iss >> nDataPointsPerHalfScene >> representation;
1778  modelRepresentation = G4MagneticFieldModel::fullArrow;
1779  if (representation == "lightArrow") {
1780  modelRepresentation = G4MagneticFieldModel::lightArrow;
1781  }
1782  G4MagneticFieldModel* model =
1783  new G4MagneticFieldModel(nDataPointsPerHalfScene,modelRepresentation);
1784  const G4String& currentSceneName = pScene -> GetName ();
1785  G4bool successful = pScene -> AddRunDurationModel (model, warn);
1786  if (successful) {
1787  if (verbosity >= G4VisManager::confirmations) {
1788  G4cout << "Magnetic field, if any, will be drawn in scene \""
1789  << currentSceneName
1790  << "\"\n with "
1791  << nDataPointsPerHalfScene
1792  << " data points per half scene and with representation \""
1793  << representation
1794  << '\"'
1795  << G4endl;
1796  }
1797  }
1798  else G4VisCommandsSceneAddUnsuccessful(verbosity);
1799  UpdateVisManagerScene (currentSceneName);
1800 }
1801 
1803 
1805  G4bool omitable;
1806  fpCommand = new G4UIcmdWithAString ("/vis/scene/add/psHits", this);
1807  fpCommand -> SetGuidance
1808  ("Adds Primitive Scorer Hits (PSHits) to current scene.");
1809  fpCommand -> SetGuidance
1810  ("PSHits are drawn at end of run when the scene in which"
1811  "\nthey are added is current.");
1812  fpCommand -> SetGuidance
1813  ("Optional parameter specifies name of scoring map. By default all"
1814  "\nscoring maps registered with the G4ScoringManager are drawn.");
1815  fpCommand -> SetParameterName ("mapname", omitable = true);
1816  fpCommand -> SetDefaultValue ("all");
1817 }
1818 
1820  delete fpCommand;
1821 }
1822 
1824  return "";
1825 }
1826 
1828 (G4UIcommand*, G4String newValue)
1829 {
1831  G4bool warn(verbosity >= G4VisManager::warnings);
1832 
1833  G4Scene* pScene = fpVisManager->GetCurrentScene();
1834  if (!pScene) {
1835  if (verbosity >= G4VisManager::errors) {
1836  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
1837  }
1838  return;
1839  }
1840 
1841  G4PSHitsModel* model = new G4PSHitsModel(newValue);
1842  const G4String& currentSceneName = pScene -> GetName ();
1843  G4bool successful = pScene -> AddEndOfRunModel (model, warn);
1844  if (successful) {
1845  if (verbosity >= G4VisManager::confirmations) {
1846  if (newValue == "all") {
1847  G4cout << "All Primitive Scorer hits";
1848  } else {
1849  G4cout << "Hits of Primitive Scorer \"" << newValue << '"';
1850  }
1851  G4cout << " will be drawn at end of run in scene \""
1852  << currentSceneName << "\"."
1853  << G4endl;
1854  }
1855  }
1856  else G4VisCommandsSceneAddUnsuccessful(verbosity);
1857  UpdateVisManagerScene (currentSceneName);
1858 }
1859 
1861 
1863  G4bool omitable;
1864  fpCommand = new G4UIcommand ("/vis/scene/add/scale", this);
1865  fpCommand -> SetGuidance
1866  ("Adds an annotated scale line to the current scene.");
1867  fpCommand -> SetGuidance
1868  ("If \"unit\" is \"auto\", length is roughly one tenth of the scene extent.");
1869  fpCommand -> SetGuidance
1870  ("If \"direction\" is \"auto\", scale is roughly in the plane of the current view.");
1871  fpCommand -> SetGuidance
1872  ("If \"placement\" is \"auto\", scale is placed at bottom left of current view."
1873  "\n Otherwise placed at (xmid,ymid,zmid).");
1874  fpCommand -> SetGuidance (G4Scale::GetGuidanceString());
1875  G4UIparameter* parameter;
1876  parameter = new G4UIparameter ("length", 'd', omitable = true);
1877  parameter->SetDefaultValue (1.);
1878  fpCommand->SetParameter (parameter);
1879  parameter = new G4UIparameter ("unit", 's', omitable = true);
1880  parameter->SetDefaultValue ("auto");
1881  fpCommand->SetParameter (parameter);
1882  parameter = new G4UIparameter ("direction", 's', omitable = true);
1883  parameter->SetGuidance ("auto|x|y|z");
1884  parameter->SetDefaultValue ("auto");
1885  fpCommand->SetParameter (parameter);
1886  parameter = new G4UIparameter ("red", 'd', omitable = true);
1887  parameter->SetDefaultValue (1.);
1888  fpCommand->SetParameter (parameter);
1889  parameter = new G4UIparameter ("green", 'd', omitable = true);
1890  parameter->SetDefaultValue (0.);
1891  fpCommand->SetParameter (parameter);
1892  parameter = new G4UIparameter ("blue", 'd', omitable = true);
1893  parameter->SetDefaultValue (0.);
1894  fpCommand->SetParameter (parameter);
1895  parameter = new G4UIparameter ("placement", 's', omitable = true);
1896  parameter -> SetParameterCandidates("auto manual");
1897  parameter->SetDefaultValue ("auto");
1898  fpCommand->SetParameter (parameter);
1899  parameter = new G4UIparameter ("xmid", 'd', omitable = true);
1900  parameter->SetDefaultValue (0.);
1901  fpCommand->SetParameter (parameter);
1902  parameter = new G4UIparameter ("ymid", 'd', omitable = true);
1903  parameter->SetDefaultValue (0.);
1904  fpCommand->SetParameter (parameter);
1905  parameter = new G4UIparameter ("zmid", 'd', omitable = true);
1906  parameter->SetDefaultValue (0.);
1907  fpCommand->SetParameter (parameter);
1908  parameter = new G4UIparameter ("unit", 's', omitable = true);
1909  parameter->SetDefaultValue ("m");
1910  fpCommand->SetParameter (parameter);
1911 }
1912 
1914  delete fpCommand;
1915 }
1916 
1918  return "";
1919 }
1920 
1922 
1924  G4bool warn = verbosity >= G4VisManager::warnings;
1925 
1926  G4Scene* pScene = fpVisManager->GetCurrentScene();
1927  if (!pScene) {
1928  if (verbosity >= G4VisManager::errors) {
1929  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
1930  }
1931  return;
1932  } else {
1933  if (pScene->GetExtent().GetExtentRadius() <= 0.) {
1934  if (verbosity >= G4VisManager::errors) {
1935  G4cerr
1936  << "ERROR: Scene has no extent. Add volumes or use \"/vis/scene/add/extent\"."
1937  << G4endl;
1938  }
1939  return;
1940  }
1941  }
1942 
1943  G4double userLength, red, green, blue, xmid, ymid, zmid;
1944  G4String userLengthUnit, direction, auto_manual, positionUnit;
1945  std::istringstream is (newValue);
1946  is >> userLength >> userLengthUnit >> direction
1947  >> red >> green >> blue
1948  >> auto_manual
1949  >> xmid >> ymid >> zmid >> positionUnit;
1950 
1951  G4double length = userLength;
1952  const G4VisExtent& sceneExtent = pScene->GetExtent(); // Existing extent.
1953  if (userLengthUnit == "auto") {
1954  const G4double lengthMax = 0.5 * sceneExtent.GetExtentRadius();
1955  const G4double intLog10Length = std::floor(std::log10(lengthMax));
1956  length = std::pow(10,intLog10Length);
1957  if (5.*length < lengthMax) length *= 5.;
1958  else if (2.*length < lengthMax) length *= 2.;
1959  } else {
1960  length *= G4UIcommand::ValueOf(userLengthUnit);
1961  }
1962  G4String annotation = G4BestUnit(length,"Length");
1963 
1964  G4double unit = G4UIcommand::ValueOf(positionUnit);
1965  xmid *= unit; ymid *= unit; zmid *= unit;
1966 
1967  G4Scale::Direction scaleDirection (G4Scale::x);
1968  if (direction(0) == 'y') scaleDirection = G4Scale::y;
1969  if (direction(0) == 'z') scaleDirection = G4Scale::z;
1970 
1971  G4VViewer* pViewer = fpVisManager->GetCurrentViewer();
1972  if (!pViewer) {
1973  if (verbosity >= G4VisManager::errors) {
1974  G4cerr <<
1975  "ERROR: G4VisCommandSceneAddScale::SetNewValue: no viewer."
1976  "\n Auto direction needs a viewer."
1977  << G4endl;
1978  }
1979  return;
1980  }
1981 
1982  const G4Vector3D& vp =
1984  const G4Vector3D& up =
1985  pViewer->GetViewParameters().GetUpVector();
1986 
1987  if (direction == "auto") { // Takes cue from viewer.
1988  if (std::abs(vp.x()) > std::abs(vp.y()) &&
1989  std::abs(vp.x()) > std::abs(vp.z())) { // x viewpoint
1990  if (std::abs(up.y()) > std::abs(up.z())) scaleDirection = G4Scale::z;
1991  else scaleDirection = G4Scale::y;
1992  }
1993  else if (std::abs(vp.y()) > std::abs(vp.x()) &&
1994  std::abs(vp.y()) > std::abs(vp.z())) { // y viewpoint
1995  if (std::abs(up.x()) > std::abs(up.z())) scaleDirection = G4Scale::z;
1996  else scaleDirection = G4Scale::x;
1997  }
1998  else if (std::abs(vp.z()) > std::abs(vp.x()) &&
1999  std::abs(vp.z()) > std::abs(vp.y())) { // z viewpoint
2000  if (std::abs(up.y()) > std::abs(up.x())) scaleDirection = G4Scale::x;
2001  else scaleDirection = G4Scale::y;
2002  }
2003  }
2004 
2005  G4bool autoPlacing = false; if (auto_manual == "auto") autoPlacing = true;
2006  // Parameters read and interpreted.
2007 
2008  // Useful constants, etc...
2009  const G4double halfLength(length / 2.);
2010  const G4double comfort(0.01); // 0.15 seems too big. 0.05 might be better.
2011  const G4double freeLengthFraction (1. + 2. * comfort);
2012 
2013  const G4double xmin = sceneExtent.GetXmin();
2014  const G4double xmax = sceneExtent.GetXmax();
2015  const G4double ymin = sceneExtent.GetYmin();
2016  const G4double ymax = sceneExtent.GetYmax();
2017  const G4double zmin = sceneExtent.GetZmin();
2018  const G4double zmax = sceneExtent.GetZmax();
2019 
2020  // Test existing extent and issue warnings...
2021  G4bool worried = false;
2022  if (sceneExtent.GetExtentRadius() == 0) {
2023  worried = true;
2024  if (verbosity >= G4VisManager::warnings) {
2025  G4cout <<
2026  "WARNING: Existing scene does not yet have any extent."
2027  "\n Maybe you have not yet added any geometrical object."
2028  << G4endl;
2029  }
2030  }
2031  // Test existing scene for room...
2032  G4bool room = true;
2033  switch (scaleDirection) {
2034  case G4Scale::x:
2035  if (freeLengthFraction * (xmax - xmin) < length) room = false;
2036  break;
2037  case G4Scale::y:
2038  if (freeLengthFraction * (ymax - ymin) < length) room = false;
2039  break;
2040  case G4Scale::z:
2041  if (freeLengthFraction * (zmax - zmin) < length) room = false;
2042  break;
2043  }
2044  if (!room) {
2045  worried = true;
2046  if (verbosity >= G4VisManager::warnings) {
2047  G4cout <<
2048  "WARNING: Not enough room in existing scene. Maybe scale is too long."
2049  << G4endl;
2050  }
2051  }
2052  if (worried) {
2053  if (verbosity >= G4VisManager::warnings) {
2054  G4cout <<
2055  "WARNING: The scale you have asked for is bigger than the existing"
2056  "\n scene. Maybe you have added it too soon. It is recommended that"
2057  "\n you add the scale last so that it can be correctly auto-positioned"
2058  "\n so as not to be obscured by any existing object and so that the"
2059  "\n view parameters can be correctly recalculated."
2060  << G4endl;
2061  }
2062  }
2063 
2064  // Let's go ahead a construct a scale and a scale model. Since the
2065  // placing is done here, this G4Scale is *not* auto-placed...
2066  G4Scale scale(length, annotation, scaleDirection,
2067  false, xmid, ymid, zmid,
2069  G4VisAttributes visAttr(G4Colour(red, green, blue));
2070  scale.SetVisAttributes(visAttr);
2071  G4VModel* model = new G4ScaleModel(scale);
2072  G4String globalDescription = model->GetGlobalDescription();
2073  globalDescription += " (" + newValue + ")";
2074  model->SetGlobalDescription(globalDescription);
2075 
2076  // Now figure out the extent...
2077  //
2078  // From the G4Scale.hh:
2079  //
2080  // This creates a representation of annotated line in the specified
2081  // direction with tick marks at the end. If autoPlacing is true it
2082  // is required to be centred at the front, right, bottom corner of
2083  // the world space, comfortably outside the existing bounding
2084  // box/sphere so that existing objects do not obscure it. Otherwise
2085  // it is required to be drawn with mid-point at (xmid, ymid, zmid).
2086  //
2087  // The auto placing algorithm might be:
2088  // x = xmin + (1 + comfort) * (xmax - xmin)
2089  // y = ymin - comfort * (ymax - ymin)
2090  // z = zmin + (1 + comfort) * (zmax - zmin)
2091  // if direction == x then (x - length,y,z) to (x,y,z)
2092  // if direction == y then (x,y,z) to (x,y + length,z)
2093  // if direction == z then (x,y,z - length) to (x,y,z)
2094  //
2095  // End of clip from G4Scale.hh:
2096  //
2097  // Implement this in two parts. Here, use the scale's extent to
2098  // "expand" the scene's extent. Then rendering - in
2099  // G4VSceneHandler::AddPrimitive(const G4Scale&) - simply has to
2100  // ensure it's within the new extent.
2101  //
2102 
2103  G4double sxmid(xmid), symid(ymid), szmid(zmid);
2104  if (autoPlacing) {
2105  // Aim to place at bottom right of screen in current view.
2106  // Give some comfort zone.
2107  const G4double xComfort = comfort * (xmax - xmin);
2108  const G4double yComfort = comfort * (ymax - ymin);
2109  const G4double zComfort = comfort * (zmax - zmin);
2110  switch (scaleDirection) {
2111  case G4Scale::x:
2112  if (vp.z() > 0.) {
2113  sxmid = xmax + xComfort;
2114  symid = ymin - yComfort;
2115  szmid = zmin - zComfort;
2116  } else {
2117  sxmid = xmin - xComfort;
2118  symid = ymin - yComfort;
2119  szmid = zmax + zComfort;
2120  }
2121  break;
2122  case G4Scale::y:
2123  if (vp.x() > 0.) {
2124  sxmid = xmin - xComfort;
2125  symid = ymax + yComfort;
2126  szmid = zmin - zComfort;
2127  } else {
2128  sxmid = xmax + xComfort;
2129  symid = ymin - yComfort;
2130  szmid = zmin - zComfort;
2131  }
2132  break;
2133  case G4Scale::z:
2134  if (vp.x() > 0.) {
2135  sxmid = xmax + xComfort;
2136  symid = ymin - yComfort;
2137  szmid = zmax + zComfort;
2138  } else {
2139  sxmid = xmin - xComfort;
2140  symid = ymin - yComfort;
2141  szmid = zmax + zComfort;
2142  }
2143  break;
2144  }
2145  }
2146 
2147  /* Old code - kept for future reference.
2148  G4double sxmid(xmid), symid(ymid), szmid(zmid);
2149  if (autoPlacing) {
2150  sxmid = xmin + onePlusComfort * (xmax - xmin);
2151  symid = ymin - comfort * (ymax - ymin);
2152  szmid = zmin + onePlusComfort * (zmax - zmin);
2153  switch (scaleDirection) {
2154  case G4Scale::x:
2155  sxmid -= halfLength;
2156  break;
2157  case G4Scale::y:
2158  symid += halfLength;
2159  break;
2160  case G4Scale::z:
2161  szmid -= halfLength;
2162  break;
2163  }
2164  }
2165  */
2166 
2167  /* sxmin, etc., not actually used. Comment out to prevent compiler
2168  warnings but keep in case need in future. Extract transform and
2169  scaleExtent into reduced code below.
2170  G4double sxmin(sxmid), sxmax(sxmid);
2171  G4double symin(symid), symax(symid);
2172  G4double szmin(szmid), szmax(szmid);
2173  G4Transform3D transform;
2174  G4VisExtent scaleExtent;
2175  switch (scaleDirection) {
2176  case G4Scale::x:
2177  sxmin = sxmid - halfLength;
2178  sxmax = sxmid + halfLength;
2179  scaleExtent = G4VisExtent(-halfLength,halfLength,0,0,0,0);
2180  break;
2181  case G4Scale::y:
2182  symin = symid - halfLength;
2183  symax = symid + halfLength;
2184  transform = G4RotateZ3D(halfpi);
2185  scaleExtent = G4VisExtent(0,0,-halfLength,halfLength,0,0);
2186  break;
2187  case G4Scale::z:
2188  szmin = szmid - halfLength;
2189  szmax = szmid + halfLength;
2190  transform = G4RotateY3D(halfpi);
2191  scaleExtent = G4VisExtent(0,0,0,0,-halfLength,halfLength);
2192  break;
2193  }
2194  */
2195  G4Transform3D transform;
2196  G4VisExtent scaleExtent;
2197  switch (scaleDirection) {
2198  case G4Scale::x:
2199  scaleExtent = G4VisExtent(-halfLength,halfLength,0,0,0,0);
2200  break;
2201  case G4Scale::y:
2202  transform = G4RotateZ3D(halfpi);
2203  scaleExtent = G4VisExtent(0,0,-halfLength,halfLength,0,0);
2204  break;
2205  case G4Scale::z:
2206  transform = G4RotateY3D(halfpi);
2207  scaleExtent = G4VisExtent(0,0,0,0,-halfLength,halfLength);
2208  break;
2209  }
2210  transform = G4Translate3D(sxmid,symid,szmid) * transform;
2212 
2213 
2214  model->SetTransformation(transform);
2215  // Note: it is the responsibility of the model to act upon this, but
2216  // the extent is in local coordinates...
2217  model->SetExtent(scaleExtent);
2218  // This extent gets "added" to existing scene extent in
2219  // AddRunDurationModel below.
2220 
2221  const G4String& currentSceneName = pScene -> GetName ();
2222  G4bool successful = pScene -> AddRunDurationModel (model, warn);
2223  if (successful) {
2224  if (verbosity >= G4VisManager::confirmations) {
2225  G4cout << "Scale of " << annotation
2226  << " added to scene \"" << currentSceneName << "\".";
2227  if (verbosity >= G4VisManager::parameters) {
2228  G4cout << "\n with extent " << scaleExtent
2229  << "\n at " << transform.getRotation()
2230  << transform.getTranslation();
2231  }
2232  G4cout << G4endl;
2233  }
2234  }
2235  else G4VisCommandsSceneAddUnsuccessful(verbosity);
2236  UpdateVisManagerScene (currentSceneName);
2237 }
2238 
2239 
2241 
2243  G4bool omitable;
2244  fpCommand = new G4UIcommand ("/vis/scene/add/text", this);
2245  fpCommand -> SetGuidance ("Adds text to current scene.");
2246  fpCommand -> SetGuidance
2247  ("Use \"/vis/set/textColour\" to set colour.");
2248  fpCommand -> SetGuidance
2249  ("Use \"/vis/set/textLayout\" to set layout:");
2250  G4UIparameter* parameter;
2251  parameter = new G4UIparameter ("x", 'd', omitable = true);
2252  parameter->SetDefaultValue (0);
2253  fpCommand->SetParameter (parameter);
2254  parameter = new G4UIparameter ("y", 'd', omitable = true);
2255  parameter->SetDefaultValue (0);
2256  fpCommand->SetParameter (parameter);
2257  parameter = new G4UIparameter ("z", 'd', omitable = true);
2258  parameter->SetDefaultValue (0);
2259  fpCommand->SetParameter (parameter);
2260  parameter = new G4UIparameter ("unit", 's', omitable = true);
2261  parameter->SetDefaultValue ("m");
2262  fpCommand->SetParameter (parameter);
2263  parameter = new G4UIparameter ("font_size", 'd', omitable = true);
2264  parameter->SetDefaultValue (12);
2265  parameter->SetGuidance ("pixels");
2266  fpCommand->SetParameter (parameter);
2267  parameter = new G4UIparameter ("x_offset", 'd', omitable = true);
2268  parameter->SetDefaultValue (0);
2269  parameter->SetGuidance ("pixels");
2270  fpCommand->SetParameter (parameter);
2271  parameter = new G4UIparameter ("y_offset", 'd', omitable = true);
2272  parameter->SetDefaultValue (0);
2273  parameter->SetGuidance ("pixels");
2274  fpCommand->SetParameter (parameter);
2275  parameter = new G4UIparameter ("text", 's', omitable = true);
2276  parameter->SetGuidance ("The rest of the line is text.");
2277  parameter->SetDefaultValue ("Hello G4");
2278  fpCommand->SetParameter (parameter);
2279 }
2280 
2282  delete fpCommand;
2283 }
2284 
2286  return "";
2287 }
2288 
2290 
2292  G4bool warn = verbosity >= G4VisManager::warnings;
2293 
2294  G4Scene* pScene = fpVisManager->GetCurrentScene();
2295  if (!pScene) {
2296  if (verbosity >= G4VisManager::errors) {
2297  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
2298  }
2299  return;
2300  }
2301 
2302  G4Tokenizer next(newValue);
2303  G4double x = StoD(next());
2304  G4double y = StoD(next());
2305  G4double z = StoD(next());
2306  G4String unitString = next();
2307  G4double font_size = StoD(next());
2308  G4double x_offset = StoD(next());
2309  G4double y_offset = StoD(next());
2310  G4String text = next("\n");
2311 
2312  G4double unit = G4UIcommand::ValueOf(unitString);
2313  x *= unit; y *= unit; z *= unit;
2314 
2315  G4Text g4text(text, G4Point3D(x,y,z));
2317  g4text.SetVisAttributes(visAtts);
2318  g4text.SetLayout(fCurrentTextLayout);
2319  g4text.SetScreenSize(font_size);
2320  g4text.SetOffset(x_offset,y_offset);
2321  G4VModel* model = new G4TextModel(g4text);
2322  const G4String& currentSceneName = pScene -> GetName ();
2323  G4bool successful = pScene -> AddRunDurationModel (model, warn);
2324  if (successful) {
2325  if (verbosity >= G4VisManager::confirmations) {
2326  G4cout << "Text \"" << text
2327  << "\" has been added to scene \"" << currentSceneName << "\"."
2328  << G4endl;
2329  }
2330  }
2331  else G4VisCommandsSceneAddUnsuccessful(verbosity);
2332  UpdateVisManagerScene (currentSceneName);
2333 }
2334 
2335 
2337 
2339  G4bool omitable;
2340  fpCommand = new G4UIcommand ("/vis/scene/add/text2D", this);
2341  fpCommand -> SetGuidance ("Adds 2D text to current scene.");
2342  fpCommand -> SetGuidance
2343  ("Use \"/vis/set/textColour\" to set colour.");
2344  fpCommand -> SetGuidance
2345  ("Use \"/vis/set/textLayout\" to set layout:");
2346  G4UIparameter* parameter;
2347  parameter = new G4UIparameter ("x", 'd', omitable = true);
2348  parameter->SetDefaultValue (0);
2349  fpCommand->SetParameter (parameter);
2350  parameter = new G4UIparameter ("y", 'd', omitable = true);
2351  parameter->SetDefaultValue (0);
2352  fpCommand->SetParameter (parameter);
2353  parameter = new G4UIparameter ("font_size", 'd', omitable = true);
2354  parameter->SetDefaultValue (12);
2355  parameter->SetGuidance ("pixels");
2356  fpCommand->SetParameter (parameter);
2357  parameter = new G4UIparameter ("x_offset", 'd', omitable = true);
2358  parameter->SetDefaultValue (0);
2359  parameter->SetGuidance ("pixels");
2360  fpCommand->SetParameter (parameter);
2361  parameter = new G4UIparameter ("y_offset", 'd', omitable = true);
2362  parameter->SetDefaultValue (0);
2363  parameter->SetGuidance ("pixels");
2364  fpCommand->SetParameter (parameter);
2365  parameter = new G4UIparameter ("text", 's', omitable = true);
2366  parameter->SetGuidance ("The rest of the line is text.");
2367  parameter->SetDefaultValue ("Hello G4");
2368  fpCommand->SetParameter (parameter);
2369 }
2370 
2372  delete fpCommand;
2373 }
2374 
2376  return "";
2377 }
2378 
2380 
2382  G4bool warn = verbosity >= G4VisManager::warnings;
2383 
2384  G4Scene* pScene = fpVisManager->GetCurrentScene();
2385  if (!pScene) {
2386  if (verbosity >= G4VisManager::errors) {
2387  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
2388  }
2389  return;
2390  }
2391 
2392  G4Tokenizer next(newValue);
2393  G4double x = StoD(next());
2394  G4double y = StoD(next());
2395  G4double font_size = StoD(next());
2396  G4double x_offset = StoD(next());
2397  G4double y_offset = StoD(next());
2398  G4String text = next("\n");
2399 
2400  G4Text g4text(text, G4Point3D(x,y,0.));
2402  g4text.SetVisAttributes(visAtts);
2403  g4text.SetLayout(fCurrentTextLayout);
2404  g4text.SetScreenSize(font_size);
2405  g4text.SetOffset(x_offset,y_offset);
2406  G4Text2D* g4text2D = new G4Text2D(g4text);
2407  G4VModel* model =
2409  model->SetType("Text2D");
2410  model->SetGlobalTag("Text2D");
2411  model->SetGlobalDescription("Text2D: " + newValue);
2412  const G4String& currentSceneName = pScene -> GetName ();
2413  G4bool successful = pScene -> AddRunDurationModel (model, warn);
2414  if (successful) {
2415  if (verbosity >= G4VisManager::confirmations) {
2416  G4cout << "2D text \"" << text
2417  << "\" has been added to scene \"" << currentSceneName << "\"."
2418  << G4endl;
2419  }
2420  }
2421  else G4VisCommandsSceneAddUnsuccessful(verbosity);
2422  UpdateVisManagerScene (currentSceneName);
2423 }
2424 
2426  fText(text)
2427 {}
2428 
2429 void G4VisCommandSceneAddText2D::G4Text2D::operator()
2430  (G4VGraphicsScene& sceneHandler, const G4Transform3D& transform) {
2431  sceneHandler.BeginPrimitives2D(transform);
2432  sceneHandler.AddPrimitive(fText);
2433  sceneHandler.EndPrimitives2D();
2434 }
2435 
2436 
2438 
2440  G4bool omitable;
2442  ("/vis/scene/add/trajectories", this);
2443  fpCommand -> SetGuidance
2444  ("Adds trajectories to current scene.");
2445  fpCommand -> SetGuidance
2446  ("Causes trajectories, if any, to be drawn at the end of processing an"
2447  "\nevent. Switches on trajectory storing and sets the"
2448  "\ndefault trajectory type.");
2449  fpCommand -> SetGuidance
2450  ("The command line parameter list determines the default trajectory type."
2451  "\nIf it contains the string \"smooth\", auxiliary inter-step points will"
2452  "\nbe inserted to improve the smoothness of the drawing of a curved"
2453  "\ntrajectory."
2454  "\nIf it contains the string \"rich\", significant extra information will"
2455  "\nbe stored in the trajectory (G4RichTrajectory) amenable to modeling"
2456  "\nand filtering with \"/vis/modeling/trajectories/create/drawByAttribute\""
2457  "\nand \"/vis/filtering/trajectories/create/attributeFilter\" commands."
2458  "\nIt may contain both strings in any order.");
2459  fpCommand -> SetGuidance
2460  ("\nTo switch off trajectory storing: \"/tracking/storeTrajectory 0\"."
2461  "\nSee also \"/vis/scene/endOfEventAction\".");
2462  fpCommand -> SetGuidance
2463  ("Note: This only sets the default. Independently of the result of this"
2464  "\ncommand, a user may instantiate a trajectory that overrides this default"
2465  "\nin PreUserTrackingAction.");
2466  fpCommand -> SetParameterName ("default-trajectory-type", omitable = true);
2467  fpCommand -> SetDefaultValue ("");
2468 }
2469 
2471  delete fpCommand;
2472 }
2473 
2475  return "";
2476 }
2477 
2479  G4String newValue) {
2480 
2482  G4bool warn = verbosity >= G4VisManager::warnings;
2483 
2484  G4Scene* pScene = fpVisManager->GetCurrentScene();
2485  if (!pScene) {
2486  if (verbosity >= G4VisManager::errors) {
2487  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
2488  }
2489  return;
2490  }
2491 
2492  G4bool smooth = false;
2493  G4bool rich = false;
2494  if (newValue.find("smooth") != std::string::npos) smooth = true;
2495  if (newValue.find("rich") != std::string::npos) rich = true;
2496  if (newValue.size() && !(rich || smooth)) {
2497  if (verbosity >= G4VisManager::errors) {
2498  G4cerr << "ERROR: Unrecognised parameter \"" << newValue << "\""
2499  "\n No action taken."
2500  << G4endl;
2501  }
2502  return;
2503  }
2504 
2505  G4UImanager* UImanager = G4UImanager::GetUIpointer();
2506  G4int keepVerbose = UImanager->GetVerboseLevel();
2507  G4int newVerbose = 2;
2508  UImanager->SetVerboseLevel(newVerbose);
2509  G4String defaultTrajectoryType;
2510  if (smooth && rich) {
2511  UImanager->ApplyCommand("/tracking/storeTrajectory 4");
2512  defaultTrajectoryType = "G4RichTrajectory configured for smooth steps";
2513  } else if (smooth) {
2514  UImanager->ApplyCommand("/tracking/storeTrajectory 2");
2515  defaultTrajectoryType = "G4SmoothTrajectory";
2516  } else if (rich) {
2517  UImanager->ApplyCommand("/tracking/storeTrajectory 3");
2518  defaultTrajectoryType = "G4RichTrajectory";
2519  } else {
2520  UImanager->ApplyCommand("/tracking/storeTrajectory 1");
2521  defaultTrajectoryType = "G4Trajectory";
2522  }
2523  UImanager->SetVerboseLevel(keepVerbose);
2524 
2525  if (verbosity >= G4VisManager::errors) {
2526  G4cout <<
2527  "Attributes available for modeling and filtering with"
2528  "\n \"/vis/modeling/trajectories/create/drawByAttribute\" and"
2529  "\n \"/vis/filtering/trajectories/create/attributeFilter\" commands:"
2530  << G4endl;
2532  if (rich) {
2535  } else if (smooth) {
2538  } else {
2540  << *G4TrajectoryPoint().GetAttDefs();
2541  }
2542  }
2543 
2545  const G4String& currentSceneName = pScene -> GetName ();
2546  pScene -> AddEndOfEventModel (model, warn);
2547 
2548  if (verbosity >= G4VisManager::confirmations) {
2549  G4cout << "Default trajectory type " << defaultTrajectoryType
2550  << "\n will be used to store trajectories for scene \""
2551  << currentSceneName << "\"."
2552  << G4endl;
2553  }
2554 
2555  if (verbosity >= G4VisManager::warnings) {
2556  G4cout <<
2557  "WARNING: Trajectory storing has been requested. This action may be"
2558  "\n reversed with \"/tracking/storeTrajectory 0\"."
2559  << G4endl;
2560  }
2561  UpdateVisManagerScene (currentSceneName);
2562 }
2563 
2565 
2567  G4bool omitable;
2568  fpCommand = new G4UIcmdWithAString("/vis/scene/add/userAction",this);
2569  fpCommand -> SetGuidance
2570  ("Add named Vis User Action to current scene.");
2571  fpCommand -> SetGuidance
2572  ("Attempts to match search string to name of action - use unique sub-string.");
2573  fpCommand -> SetGuidance
2574  ("(Use /vis/list to see names of registered actions.)");
2575  fpCommand -> SetGuidance
2576  ("If name == \"all\" (default), all actions are added.");
2577  fpCommand -> SetParameterName("action-name", omitable = true);
2578  fpCommand -> SetDefaultValue("all");
2579 }
2580 
2582  delete fpCommand;
2583 }
2584 
2586  return "";
2587 }
2588 
2590 (G4UIcommand*, G4String newValue) {
2591 
2593 
2594  G4Scene* pScene = fpVisManager->GetCurrentScene();
2595  if (!pScene) {
2596  if (verbosity >= G4VisManager::errors) {
2597  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
2598  }
2599  return;
2600  }
2601 
2602  G4bool any = false;
2603 
2604  const std::vector<G4VisManager::UserVisAction>& runDurationUserVisActions =
2606  for (size_t i = 0; i < runDurationUserVisActions.size(); i++) {
2607  const G4String& name = runDurationUserVisActions[i].fName;
2608  G4VUserVisAction* visAction = runDurationUserVisActions[i].fpUserVisAction;
2609  if (newValue == "all" || name.find(newValue) != std::string::npos) {
2610  any = true;
2611  AddVisAction(name,visAction,pScene,runDuration,verbosity);
2612  }
2613  }
2614 
2615  const std::vector<G4VisManager::UserVisAction>& endOfEventUserVisActions =
2617  for (size_t i = 0; i < endOfEventUserVisActions.size(); i++) {
2618  const G4String& name = endOfEventUserVisActions[i].fName;
2619  G4VUserVisAction* visAction = endOfEventUserVisActions[i].fpUserVisAction;
2620  if (newValue == "all" || name.find(newValue) != std::string::npos) {
2621  any = true;
2622  AddVisAction(name,visAction,pScene,endOfEvent,verbosity);
2623  }
2624  }
2625 
2626  const std::vector<G4VisManager::UserVisAction>& endOfRunUserVisActions =
2628  for (size_t i = 0; i < endOfRunUserVisActions.size(); i++) {
2629  const G4String& name = endOfRunUserVisActions[i].fName;
2630  G4VUserVisAction* visAction = endOfRunUserVisActions[i].fpUserVisAction;
2631  if (newValue == "all" || name.find(newValue) != std::string::npos) {
2632  any = true;
2633  AddVisAction(name,visAction,pScene,endOfRun,verbosity);
2634  }
2635  }
2636 
2637  if (!any) {
2638  if (verbosity >= G4VisManager::warnings) {
2639  G4cout << "WARNING: No User Vis Action registered." << G4endl;
2640  }
2641  return;
2642  }
2643 
2644  const G4String& currentSceneName = pScene -> GetName ();
2645  UpdateVisManagerScene (currentSceneName);
2646 }
2647 
2649 (const G4String& name,
2650  G4VUserVisAction* visAction,
2651  G4Scene* pScene,
2653  G4VisManager::Verbosity verbosity)
2654 {
2655  G4bool warn = verbosity >= G4VisManager::warnings;
2656 
2657  const std::map<G4VUserVisAction*,G4VisExtent>& visExtentMap =
2659  G4VisExtent extent;
2660  std::map<G4VUserVisAction*,G4VisExtent>::const_iterator i =
2661  visExtentMap.find(visAction);
2662  if (i != visExtentMap.end()) extent = i->second;
2663  if (warn) {
2664  if (extent.GetExtentRadius() <= 0.) {
2665  G4cout << "WARNING: User Vis Action extent is null." << G4endl;
2666  }
2667  }
2668 
2669  G4VModel* model = new G4CallbackModel<G4VUserVisAction>(visAction);
2670  model->SetType("User Vis Action");
2671  model->SetGlobalTag(name);
2672  model->SetGlobalDescription(name);
2673  model->SetExtent(extent);
2674  G4bool successful = false;;
2675  switch (type) {
2676  case runDuration:
2677  successful = pScene -> AddRunDurationModel (model, warn);
2678  break;
2679  case endOfEvent:
2680  successful = pScene -> AddEndOfEventModel (model, warn);
2681  break;
2682  case endOfRun:
2683  successful = pScene -> AddEndOfRunModel (model, warn);
2684  break;
2685  }
2686  if (successful && verbosity >= G4VisManager::confirmations) {
2687  const G4String& currentSceneName = pScene -> GetName ();
2688  G4cout << "User Vis Action added to scene \""
2689  << currentSceneName << "\"";
2690  if (verbosity >= G4VisManager::parameters) {
2691  G4cout << "\n with extent " << extent;
2692  }
2693  G4cout << G4endl;
2694  }
2695  else G4VisCommandsSceneAddUnsuccessful(verbosity);
2696 }
2697 
2699 
2701  G4bool omitable;
2702  fpCommand = new G4UIcommand ("/vis/scene/add/volume", this);
2703  fpCommand -> SetGuidance
2704  ("Adds a physical volume to current scene, with optional clipping volume.");
2705  fpCommand -> SetGuidance
2706  ("If physical-volume-name is \"world\" (the default), the top of the"
2707  "\nmain geometry tree (material world) is added. If \"worlds\", the"
2708  "\ntop of all worlds - material world and parallel worlds, if any - are"
2709  "\nadded. Otherwise a search of all worlds is made, taking the first"
2710  "\nmatching occurence only. To see a representation of the geometry"
2711  "\nhierarchy of the worlds, try \"/vis/drawTree [worlds]\" or one of the"
2712  "\ndriver/browser combinations that have the required functionality, e.g., HepRep.");
2713  fpCommand -> SetGuidance
2714  ("If clip-volume-type is specified, the subsequent parameters are used to"
2715  "\nto define a clipping volume. For example,"
2716  "\n\"/vis/scene/add/volume ! ! ! -box km 0 1 0 1 0 1\" will draw the world"
2717  "\nwith the positive octant cut away. (If the Boolean Processor issues"
2718  "\nwarnings try replacing 0 by 0.000000001 or something.)");
2719  fpCommand -> SetGuidance
2720  ("If clip-volume-type is prepended with '-', the clip-volume is subtracted"
2721  "\n(cutaway). (This is the default if there is no prepended character.)"
2722  "\nIf '*' is prepended, the intersection of the physical-volume and the"
2723  "\nclip-volume is made. (You can make a section/DCUT with a thin box, for"
2724  "\nexample).");
2725  fpCommand -> SetGuidance
2726  ("For \"box\", the parameters are xmin,xmax,ymin,ymax,zmin,zmax."
2727  "\nOnly \"box\" is programmed at present.");
2728  G4UIparameter* parameter;
2729  parameter = new G4UIparameter ("physical-volume-name", 's', omitable = true);
2730  parameter -> SetDefaultValue ("world");
2731  fpCommand -> SetParameter (parameter);
2732  parameter = new G4UIparameter ("copy-no", 'i', omitable = true);
2733  parameter -> SetGuidance
2734  ("If negative, matches any copy no. First name match is taken.");
2735  parameter -> SetDefaultValue (-1);
2736  fpCommand -> SetParameter (parameter);
2737  parameter = new G4UIparameter ("depth-of-descent", 'i', omitable = true);
2738  parameter -> SetGuidance
2739  ("Depth of descent of geometry hierarchy. Default = unlimited depth.");
2740  parameter -> SetDefaultValue (G4Scene::UNLIMITED);
2741  fpCommand -> SetParameter (parameter);
2742  parameter = new G4UIparameter ("clip-volume-type", 's', omitable = true);
2743  parameter -> SetParameterCandidates("none box -box *box");
2744  parameter -> SetDefaultValue ("none");
2745  parameter -> SetGuidance("[-|*]type. See general guidance.");
2746  fpCommand -> SetParameter (parameter);
2747  parameter = new G4UIparameter ("parameter-unit", 's', omitable = true);
2748  parameter -> SetDefaultValue ("m");
2749  fpCommand -> SetParameter (parameter);
2750  parameter = new G4UIparameter ("parameter-1", 'd', omitable = true);
2751  parameter -> SetDefaultValue (0.);
2752  fpCommand -> SetParameter (parameter);
2753  parameter = new G4UIparameter ("parameter-2", 'd', omitable = true);
2754  parameter -> SetDefaultValue (0.);
2755  fpCommand -> SetParameter (parameter);
2756  parameter = new G4UIparameter ("parameter-3", 'd', omitable = true);
2757  parameter -> SetDefaultValue (0.);
2758  fpCommand -> SetParameter (parameter);
2759  parameter = new G4UIparameter ("parameter-4", 'd', omitable = true);
2760  parameter -> SetDefaultValue (0.);
2761  fpCommand -> SetParameter (parameter);
2762  parameter = new G4UIparameter ("parameter-5", 'd', omitable = true);
2763  parameter -> SetDefaultValue (0.);
2764  fpCommand -> SetParameter (parameter);
2765  parameter = new G4UIparameter ("parameter-6", 'd', omitable = true);
2766  parameter -> SetDefaultValue (0.);
2767  fpCommand -> SetParameter (parameter);
2768 }
2769 
2771  delete fpCommand;
2772 }
2773 
2775  return "world 0 -1";
2776 }
2777 
2779  G4String newValue) {
2780 
2782  G4bool warn = verbosity >= G4VisManager::warnings;
2783 
2784  G4Scene* pScene = fpVisManager->GetCurrentScene();
2785  if (!pScene) {
2786  if (verbosity >= G4VisManager::errors) {
2787  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
2788  }
2789  return;
2790  }
2791 
2792  G4String name, clipVolumeType, parameterUnit;
2793  G4int copyNo, requestedDepthOfDescent;
2794  G4double param1, param2, param3, param4, param5, param6;
2795  std::istringstream is (newValue);
2796  is >> name >> copyNo >> requestedDepthOfDescent
2797  >> clipVolumeType >> parameterUnit
2798  >> param1 >> param2 >> param3 >> param4 >> param5 >> param6;
2800  G4PhysicalVolumeModel::subtraction; // Default subtraction mode.
2801  if (clipVolumeType[size_t(0)] == '-') {
2802  clipVolumeType = clipVolumeType.substr(1); // Remove first character.
2803  } else if (clipVolumeType[size_t(0)] == '*') {
2804  clippingMode = G4PhysicalVolumeModel::intersection;
2805  clipVolumeType = clipVolumeType.substr(1);
2806  }
2807  G4double unit = G4UIcommand::ValueOf(parameterUnit);
2808  param1 *= unit; param2 *= unit; param3 *= unit;
2809  param4 *= unit; param5 *= unit; param6 *= unit;
2810 
2811  G4TransportationManager* transportationManager =
2813 
2814  size_t nWorlds = transportationManager->GetNoWorlds();
2815  if (nWorlds > 1) { // Parallel worlds in operation...
2816  if (verbosity >= G4VisManager::warnings) {
2817  static G4bool warned = false;
2818  if (!warned && name != "worlds") {
2819  G4cout <<
2820  "WARNING: Parallel worlds in operation. To visualise, specify"
2821  "\n \"worlds\" or the parallel world volume or sub-volume name"
2822  "\n and control visibility with /vis/geometry."
2823  << G4endl;
2824  std::vector<G4VPhysicalVolume*>::iterator iterWorld =
2825  transportationManager->GetWorldsIterator();
2826  for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
2827  G4cout << " World " << i << ": " << (*iterWorld)->GetName()
2828  << G4endl;
2829  warned = true;
2830  }
2831  }
2832  }
2833  }
2834 
2835  G4VPhysicalVolume* world = *(transportationManager->GetWorldsIterator());
2836 
2837  if (!world) {
2838  if (verbosity >= G4VisManager::errors) {
2839  G4cerr <<
2840  "ERROR: G4VisCommandSceneAddVolume::SetNewValue:"
2841  "\n No world. Maybe the geometry has not yet been defined."
2842  "\n Try \"/run/initialize\""
2843  << G4endl;
2844  }
2845  return;
2846  }
2847 
2848  const std::vector<G4Scene::Model>& rdModelList = pScene -> GetRunDurationModelList();
2849  std::vector<G4Scene::Model>::const_iterator it;
2850  for (it = rdModelList.begin(); it != rdModelList.end(); ++it) {
2851  if (it->fpModel->GetGlobalDescription().find("G4PhysicalVolumeModel")
2852  != std::string::npos) {
2853  if (((G4PhysicalVolumeModel*)(it->fpModel))->GetTopPhysicalVolume () == world) break;
2854  }
2855  }
2856  if (it != rdModelList.end()) {
2857  if (verbosity >= G4VisManager::warnings) {
2858  G4cout << "WARNING: There is already a volume, \""
2859  << it -> fpModel -> GetGlobalDescription()
2860  << "\",\n in the run-duration model list of scene \""
2861  << pScene -> GetName()
2862  << "\".\n To get a clean scene:"
2863  << "\n /vis/drawVolume " << name
2864  << "\n or"
2865  << "\n /vis/scene/create"
2866  << "\n /vis/scene/add/volume " << name
2867  << "\n /vis/sceneHandler/attach"
2868  << "\n (and also, if necessary, /vis/viewer/flush)"
2869  << G4endl;
2870  }
2871  return;
2872  }
2873 
2874  std::vector<G4PhysicalVolumeModel*> models;
2875  std::vector<G4VPhysicalVolume*> foundVolumes;
2876  G4VPhysicalVolume* foundWorld = 0;
2878  typedef std::vector<PVNodeID> PVPath;
2879  PVPath foundFullPVPath;
2880  std::vector<G4int> foundDepths;
2881  std::vector<G4Transform3D> transformations;
2882 
2883  if (name == "world") {
2884 
2885  models.push_back
2886  (new G4PhysicalVolumeModel (world, requestedDepthOfDescent));
2887  foundVolumes.push_back(world);
2888  foundDepths.push_back(0);
2889  transformations.push_back(G4Transform3D());
2890 
2891  } else if (name == "worlds") {
2892 
2893  if (nWorlds == 0) {
2894  if (verbosity >= G4VisManager::warnings) {
2895  G4cout <<
2896  "WARNING: G4VisCommandSceneAddVolume::SetNewValue:"
2897  "\n Parallel worlds requested but none exist."
2898  "\n Just adding material world."
2899  << G4endl;
2900  }
2901  }
2902  std::vector<G4VPhysicalVolume*>::iterator iterWorld =
2903  transportationManager->GetWorldsIterator();
2904  for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
2905  models.push_back
2906  (new G4PhysicalVolumeModel (*iterWorld, requestedDepthOfDescent));
2907  foundVolumes.push_back(*iterWorld);
2908  foundDepths.push_back(0);
2909  transformations.push_back(G4Transform3D());
2910  }
2911 
2912  } else { // Search all worlds...
2913 
2914  std::vector<G4VPhysicalVolume*>::iterator iterWorld =
2915  transportationManager->GetWorldsIterator();
2916  for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
2917  G4PhysicalVolumeModel searchModel (*iterWorld); // Unlimited depth.
2918  G4ModelingParameters mp; // Default - no culling.
2919  searchModel.SetModelingParameters (&mp);
2920  G4PhysicalVolumeSearchScene searchScene (&searchModel, name, copyNo);
2921  searchModel.DescribeYourselfTo (searchScene); // Initiate search.
2922  G4VPhysicalVolume* foundVolume = searchScene.GetFoundVolume ();
2923  if (foundVolume) {
2924  foundWorld = *iterWorld;
2925  foundVolumes.push_back(foundVolume);
2926  foundFullPVPath = searchScene.GetFoundFullPVPath();
2927  foundDepths.push_back(searchScene.GetFoundDepth());
2928  transformations.push_back(searchScene.GetFoundTransformation());
2929  break;
2930  }
2931  }
2932 
2933  if (foundVolumes.size()) {
2934  for (size_t i = 0; i < foundVolumes.size(); ++i) {
2935  G4PhysicalVolumeModel* foundPVModel = new G4PhysicalVolumeModel
2936  (foundVolumes[i], requestedDepthOfDescent, transformations[i]);
2937  foundFullPVPath.pop_back(); // "Base" is "Found - 1".
2938  foundPVModel->SetBaseFullPVPath(foundFullPVPath);
2939  models.push_back(foundPVModel);
2940  }
2941  } else {
2942  if (verbosity >= G4VisManager::errors) {
2943  G4cerr << "ERROR: Volume \"" << name << "\"";
2944  if (copyNo >= 0) {
2945  G4cerr << ", copy no. " << copyNo << ",";
2946  }
2947  G4cerr << " not found." << G4endl;
2948  }
2949  return;
2950  }
2951  }
2952 
2953  if (clipVolumeType == "box") {
2954  const G4double dX = (param2 - param1) / 2.;
2955  const G4double dY = (param4 - param3) / 2.;
2956  const G4double dZ = (param6 - param5) / 2.;
2957  const G4double x0 = (param2 + param1) / 2.;
2958  const G4double y0 = (param4 + param3) / 2.;
2959  const G4double z0 = (param6 + param5) / 2.;
2960  G4VSolid* clippingSolid =
2961  new G4DisplacedSolid
2962  ("_displaced_clipping_box",
2963  new G4Box("_clipping_box",dX,dY,dZ),
2964  G4Translate3D(x0,y0,z0));
2965  for (size_t i = 0; i < foundVolumes.size(); ++i) {
2966  models[i]->SetClippingSolid(clippingSolid);
2967  models[i]->SetClippingMode(clippingMode);
2968  }
2969  } // If any other shape consider NumberOfRotationSides!!!!!!!!!!!
2970 
2971  const G4String& currentSceneName = pScene -> GetName ();
2972  G4bool failure = true;
2973  for (size_t i = 0; i < foundVolumes.size(); ++i) {
2974  G4bool successful = pScene -> AddRunDurationModel (models[i], warn);
2975  if (successful) {
2976  failure = false;
2977  if (verbosity >= G4VisManager::confirmations) {
2978  G4cout << "First occurrence of \""
2979  << foundVolumes[i] -> GetName ()
2980  << "\"";
2981  if (copyNo >= 0) {
2982  G4cout << ", copy no. " << copyNo << ",";
2983  }
2984  G4cout << "\n found ";
2985  if (foundWorld)
2986  G4cout << "in world \"" << foundWorld->GetName() << "\" ";
2987  G4cout << "at depth " << foundDepths[i]
2988  << ",\n with a requested depth of further descent of ";
2989  if (requestedDepthOfDescent < 0) {
2990  G4cout << "<0 (unlimited)";
2991  }
2992  else {
2993  G4cout << requestedDepthOfDescent;
2994  }
2995  G4cout << ",\n has been added to scene \"" << currentSceneName << "\"."
2996  << G4endl;
2997  }
2998  }
2999  }
3000 
3001  if (failure) {
3003  return;
3004  }
3005 
3006  UpdateVisManagerScene (currentSceneName);
3007 }
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
static const double halfpi
Definition: G4SIunits.hh:76
G4String GetCurrentValue(G4UIcommand *command)
HepGeom::RotateY3D G4RotateY3D
Definition: test07.cc:36
G4double GetXmin() const
Definition: G4VisExtent.hh:89
static const G4double f2
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)
G4double z
Definition: TRTMaterials.hh:39
Definition: G4Box.hh:64
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValue)
void UpdateVisManagerScene(const G4String &sceneName="")
G4String name
Definition: TRTMaterials.hh:40
G4String GetCurrentValue(G4UIcommand *command)
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 G4double w[NPOINTSGL]
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
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
static G4Colour Brown()
Definition: G4Colour.hh:147
void SetForceSolid(G4bool)
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 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)
static const double deg
Definition: G4SIunits.hh:151
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:136
static const G4double f1
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
static const double rad
Definition: G4SIunits.hh:148
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)
static const double pi
Definition: G4SIunits.hh:74
virtual void BeginPrimitives2D(const G4Transform3D &objectTransformation=G4Transform3D())=0
G4double StoD(G4String s)
static G4double ValueOf(const char *unitName)
Definition: G4UIcommand.cc:308
const G4double x[NPOINTSGL]
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()
static const G4double b1
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)
G4VViewer * GetCurrentViewer() const
virtual void EndPrimitives()=0
const G4Transform3D & GetFoundTransformation() const
const std::vector< UserVisAction > & GetEndOfRunUserVisActions() const
G4String GetCurrentValue(G4UIcommand *command)
G4String GetCurrentValue(G4UIcommand *command)
double G4double
Definition: G4Types.hh:76
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
static const G4double d2
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:128
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