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