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