Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4VisCommandsViewer.cc
이 파일의 문서화 페이지로 가기
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4VisCommandsViewer.cc 109510 2018-04-26 07:15:57Z gcosmo $
28 
29 // /vis/viewer commands - John Allison 25th October 1998
30 
31 #include "G4VisCommandsViewer.hh"
32 
33 #include "G4VisManager.hh"
34 #include "G4GraphicsSystemList.hh"
35 #include "G4VisCommandsScene.hh"
36 #include "G4UImanager.hh"
37 #include "G4UIcommand.hh"
39 #include "G4UIcmdWithAString.hh"
40 #include "G4UIcmdWithADouble.hh"
42 #include "G4UIcmdWith3Vector.hh"
43 #include "G4Point3D.hh"
44 #include "G4SystemOfUnits.hh"
45 #include "G4UnitsTable.hh"
46 #include "G4ios.hh"
47 #ifdef G4VIS_USE_STD11
48 #include <chrono>
49 #include <thread>
50 #endif
51 #include <sstream>
52 #include <fstream>
53 #include <sstream>
54 #include <iomanip>
55 #ifdef WIN32
56 #include <regex>
57 #include <filesystem>
58 #endif //WIN32
59 
61 
63 
65 (G4VViewer* viewer, const G4ViewParameters& viewParams) {
66  viewer->SetViewParameters(viewParams);
67  RefreshIfRequired(viewer);
68 }
69 
72  G4VSceneHandler* sceneHandler = viewer->GetSceneHandler();
73  const G4ViewParameters& viewParams = viewer->GetViewParameters();
74  if (sceneHandler && sceneHandler->GetScene()) {
75  if (viewParams.IsAutoRefresh()) {
76  G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
77  }
78  else {
79  if (verbosity >= G4VisManager::warnings) {
80  G4cout << "Issue /vis/viewer/refresh or flush to see effect."
81  << G4endl;
82  }
83  }
84  }
85 }
86 
88 
90  G4bool omitable;
91  fpCommand = new G4UIcommand ("/vis/viewer/addCutawayPlane", this);
92  fpCommand -> SetGuidance
93  ("Add cutaway plane to current viewer.");
94  G4UIparameter* parameter;
95  parameter = new G4UIparameter("x",'d',omitable = true);
96  parameter -> SetDefaultValue (0);
97  parameter -> SetGuidance ("Coordinate of point on the plane.");
98  fpCommand->SetParameter(parameter);
99  parameter = new G4UIparameter("y",'d',omitable = true);
100  parameter -> SetDefaultValue (0);
101  parameter -> SetGuidance ("Coordinate of point on the plane.");
102  fpCommand->SetParameter(parameter);
103  parameter = new G4UIparameter("z",'d',omitable = true);
104  parameter -> SetDefaultValue (0);
105  parameter -> SetGuidance ("Coordinate of point on the plane.");
106  fpCommand->SetParameter(parameter);
107  parameter = new G4UIparameter("unit",'s',omitable = true);
108  parameter -> SetDefaultValue ("m");
109  parameter -> SetGuidance ("Unit of point on the plane.");
110  fpCommand->SetParameter(parameter);
111  parameter = new G4UIparameter("nx",'d',omitable = true);
112  parameter -> SetDefaultValue (1);
113  parameter -> SetGuidance ("Component of plane normal.");
114  fpCommand->SetParameter(parameter);
115  parameter = new G4UIparameter("ny",'d',omitable = true);
116  parameter -> SetDefaultValue (0);
117  parameter -> SetGuidance ("Component of plane normal.");
118  fpCommand->SetParameter(parameter);
119  parameter = new G4UIparameter("nz",'d',omitable = true);
120  parameter -> SetDefaultValue (0);
121  parameter -> SetGuidance ("Component of plane normal.");
122  fpCommand->SetParameter(parameter);
123 }
124 
126  delete fpCommand;
127 }
128 
130  return "";
131 }
132 
134 
136 
137  G4VViewer* viewer = fpVisManager -> GetCurrentViewer ();
138  if (!viewer) {
139  if (verbosity >= G4VisManager::errors) {
140  G4cerr <<
141  "ERROR: No current viewer - \"/vis/viewer/list\" to see possibilities."
142  << G4endl;
143  }
144  return;
145  }
146 
147  G4double x, y, z, nx, ny, nz;
148  G4String unit;
149  std::istringstream is (newValue);
150  is >> x >> y >> z >> unit >> nx >> ny >> nz;
151  G4double F = G4UIcommand::ValueOf(unit);
152  x *= F; y *= F; z *= F;
153 
154  G4ViewParameters vp = viewer->GetViewParameters();
155  vp.AddCutawayPlane(G4Plane3D(G4Normal3D(nx,ny,nz), G4Point3D(x,y,z)));
156  if (verbosity >= G4VisManager::confirmations) {
157  G4cout << "Cutaway planes for viewer \"" << viewer->GetName() << "\" now:";
158  const G4Planes& cutaways = vp.GetCutawayPlanes();
159  for (size_t i = 0; i < cutaways.size(); ++i)
160  G4cout << "\n " << i << ": " << cutaways[i];
161  G4cout << G4endl;
162  }
163 
164  SetViewParameters(viewer, vp);
165 }
166 
168 
170  G4bool omitable;
171  fpCommand = new G4UIcommand ("/vis/viewer/changeCutawayPlane", this);
172  fpCommand -> SetGuidance("Change cutaway plane.");
173  G4UIparameter* parameter;
174  parameter = new G4UIparameter("index",'i',omitable = false);
175  parameter -> SetGuidance ("Index of plane: 0, 1, 2.");
176  fpCommand->SetParameter(parameter);
177  parameter = new G4UIparameter("x",'d',omitable = true);
178  parameter -> SetDefaultValue (0);
179  parameter -> SetGuidance ("Coordinate of point on the plane.");
180  fpCommand->SetParameter(parameter);
181  parameter = new G4UIparameter("y",'d',omitable = true);
182  parameter -> SetDefaultValue (0);
183  parameter -> SetGuidance ("Coordinate of point on the plane.");
184  fpCommand->SetParameter(parameter);
185  parameter = new G4UIparameter("z",'d',omitable = true);
186  parameter -> SetDefaultValue (0);
187  parameter -> SetGuidance ("Coordinate of point on the plane.");
188  fpCommand->SetParameter(parameter);
189  parameter = new G4UIparameter("unit",'s',omitable = true);
190  parameter -> SetDefaultValue ("m");
191  parameter -> SetGuidance ("Unit of point on the plane.");
192  fpCommand->SetParameter(parameter);
193  parameter = new G4UIparameter("nx",'d',omitable = true);
194  parameter -> SetDefaultValue (1);
195  parameter -> SetGuidance ("Component of plane normal.");
196  fpCommand->SetParameter(parameter);
197  parameter = new G4UIparameter("ny",'d',omitable = true);
198  parameter -> SetDefaultValue (0);
199  parameter -> SetGuidance ("Component of plane normal.");
200  fpCommand->SetParameter(parameter);
201  parameter = new G4UIparameter("nz",'d',omitable = true);
202  parameter -> SetDefaultValue (0);
203  parameter -> SetGuidance ("Component of plane normal.");
204  fpCommand->SetParameter(parameter);
205 }
206 
208  delete fpCommand;
209 }
210 
212  return "";
213 }
214 
216 
218 
219  G4VViewer* viewer = fpVisManager -> GetCurrentViewer ();
220  if (!viewer) {
221  if (verbosity >= G4VisManager::errors) {
222  G4cerr <<
223  "ERROR: No current viewer - \"/vis/viewer/list\" to see possibilities."
224  << G4endl;
225  }
226  return;
227  }
228 
229  size_t index;
230  G4double x, y, z, nx, ny, nz;
231  G4String unit;
232  std::istringstream is (newValue);
233  is >> index >> x >> y >> z >> unit >> nx >> ny >> nz;
234  G4double F = G4UIcommand::ValueOf(unit);
235  x *= F; y *= F; z *= F;
236 
237  G4ViewParameters vp = viewer->GetViewParameters();
238  vp.ChangeCutawayPlane(index,
239  G4Plane3D(G4Normal3D(nx,ny,nz), G4Point3D(x,y,z)));
240  if (verbosity >= G4VisManager::confirmations) {
241  G4cout << "Cutaway planes for viewer \"" << viewer->GetName() << "\" now:";
242  const G4Planes& cutaways = vp.GetCutawayPlanes();
243  for (size_t i = 0; i < cutaways.size(); ++i)
244  G4cout << "\n " << i << ": " << cutaways[i];
245  G4cout << G4endl;
246  }
247 
248  SetViewParameters(viewer, vp);
249 }
250 
252 
254  G4bool omitable, currentAsDefault;
255  fpCommand = new G4UIcmdWithAString ("/vis/viewer/clear", this);
256  fpCommand -> SetGuidance ("Clears viewer.");
257  fpCommand -> SetGuidance
258  ("By default, clears current viewer. Specified viewer becomes current."
259  "\n\"/vis/viewer/list\" to see possible viewer names.");
260  fpCommand -> SetParameterName ("viewer-name",
261  omitable = true,
262  currentAsDefault = true);
263 }
264 
266  delete fpCommand;
267 }
268 
270  G4VViewer* viewer = fpVisManager -> GetCurrentViewer ();
271  return viewer ? viewer -> GetName () : G4String("none");
272 }
273 
275 
277 
278  G4String& clearName = newValue;
279  G4VViewer* viewer = fpVisManager -> GetViewer (clearName);
280  if (!viewer) {
281  if (verbosity >= G4VisManager::errors) {
282  G4cerr << "ERROR: Viewer \"" << clearName
283  << "\" not found - \"/vis/viewer/list\" to see possibilities."
284  << G4endl;
285  }
286  return;
287  }
288 
289  viewer->SetView();
290  viewer->ClearView();
291  viewer->FinishView();
292  if (verbosity >= G4VisManager::confirmations) {
293  G4cout << "Viewer \"" << clearName << "\" cleared." << G4endl;
294  }
295 
296 }
297 
299 
302  ("/vis/viewer/clearCutawayPlanes", this);
303  fpCommand -> SetGuidance ("Clear cutaway planes of current viewer.");
304 }
305 
307  delete fpCommand;
308 }
309 
311  return "";
312 }
313 
315 
317 
318  G4VViewer* viewer = fpVisManager -> GetCurrentViewer ();
319  if (!viewer) {
320  if (verbosity >= G4VisManager::errors) {
321  G4cerr <<
322  "ERROR: No current viewer - \"/vis/viewer/list\" to see possibilities."
323  << G4endl;
324  }
325  return;
326  }
327 
328  G4ViewParameters vp = viewer->GetViewParameters();
329  vp.ClearCutawayPlanes();
330  if (verbosity >= G4VisManager::confirmations) {
331  G4cout << "Cutaway planes for viewer \"" << viewer->GetName()
332  << "\" now cleared." << G4endl;
333  }
334 
335  SetViewParameters(viewer, vp);
336 }
337 
339 
341  G4bool omitable, currentAsDefault;
342  fpCommand = new G4UIcmdWithAString ("/vis/viewer/clearTransients", this);
343  fpCommand -> SetGuidance ("Clears transients from viewer.");
344  fpCommand -> SetGuidance
345  ("By default, operates on current viewer. Specified viewer becomes current."
346  "\n\"/vis/viewer/list\" to see possible viewer names.");
347  fpCommand -> SetParameterName ("viewer-name",
348  omitable = true,
349  currentAsDefault = true);
350 }
351 
353  delete fpCommand;
354 }
355 
357  G4VViewer* viewer = fpVisManager -> GetCurrentViewer ();
358  return viewer ? viewer -> GetName () : G4String("none");
359 }
360 
362 
364 
365  G4String& clearName = newValue;
366  G4VViewer* viewer = fpVisManager -> GetViewer (clearName);
367  if (!viewer) {
368  if (verbosity >= G4VisManager::errors) {
369  G4cerr << "ERROR: Viewer \"" << clearName
370  << "\" not found - \"/vis/viewer/list\" to see possibilities."
371  << G4endl;
372  }
373  return;
374  }
375 
376  G4VSceneHandler* sceneHandler = viewer->GetSceneHandler();
377  sceneHandler->SetMarkForClearingTransientStore(false);
379  sceneHandler->ClearTransientStore();
380  if (verbosity >= G4VisManager::confirmations) {
381  G4cout << "Viewer \"" << clearName << "\" cleared of transients."
382  << G4endl;
383  }
384 
385 }
386 
388 
391  ("/vis/viewer/clearVisAttributesModifiers", this);
392  fpCommand -> SetGuidance ("Clear vis attribute modifiers of current viewer.");
393  fpCommand -> SetGuidance ("(These are used for touchables, etc.)");
394 }
395 
397  delete fpCommand;
398 }
399 
401  return "";
402 }
403 
405 
407 
408  G4VViewer* viewer = fpVisManager -> GetCurrentViewer ();
409  if (!viewer) {
410  if (verbosity >= G4VisManager::errors) {
411  G4cerr <<
412  "ERROR: No current viewer - \"/vis/viewer/list\" to see possibilities."
413  << G4endl;
414  }
415  return;
416  }
417 
418  G4ViewParameters vp = viewer->GetViewParameters();
420  if (verbosity >= G4VisManager::confirmations) {
421  G4cout << "Vis attributes modifiers for viewer \"" << viewer->GetName()
422  << "\" now cleared." << G4endl;
423  }
424 
425  SetViewParameters(viewer, vp);
426 }
427 
429 
431  G4bool omitable;
432  fpCommand = new G4UIcommand ("/vis/viewer/clone", this);
433  fpCommand -> SetGuidance ("Clones viewer.");
434  fpCommand -> SetGuidance
435  ("By default, clones current viewer. Clone becomes current."
436  "\nClone name, if not provided, is derived from the original name."
437  "\n\"/vis/viewer/list\" to see possible viewer names.");
438  G4UIparameter* parameter;
439  parameter = new G4UIparameter ("original-viewer-name", 's', omitable = true);
440  parameter -> SetCurrentAsDefault (true);
441  fpCommand -> SetParameter (parameter);
442  parameter = new G4UIparameter ("clone-name", 's', omitable = true);
443  parameter -> SetDefaultValue ("none");
444  fpCommand -> SetParameter (parameter);
445 }
446 
448  delete fpCommand;
449 }
450 
452  G4VViewer* viewer = fpVisManager -> GetCurrentViewer ();
453  G4String originalName = viewer ? viewer -> GetName () : G4String("none");
454  return "\"" + originalName + "\"";
455 }
456 
458 
460 
461  G4String originalName, cloneName;
462  std::istringstream is (newValue);
463 
464  // Need to handle the possibility that the names contain embedded
465  // blanks within quotation marks...
466  char c = ' ';
467  while (is.get(c) && c == ' '){}
468  if (c == '"') {
469  while (is.get(c) && c != '"') {originalName += c;}
470  }
471  else {
472  originalName += c;
473  while (is.get(c) && c != ' ') {originalName += c;}
474  }
475  originalName = originalName.strip (G4String::both, ' ');
476  originalName = originalName.strip (G4String::both, '"');
477 
478  G4VViewer* originalViewer = fpVisManager -> GetViewer (originalName);
479  if (!originalViewer) {
480  if (verbosity >= G4VisManager::errors) {
481  G4cerr << "ERROR: Viewer \"" << originalName
482  << "\" not found - \"/vis/viewer/list\" to see possibilities."
483  << G4endl;
484  }
485  return;
486  }
487  originalName = originalViewer->GetName(); // Ensures long name.
488 
489  while (is.get(c) && c == ' '){}
490  if (c == '"') {
491  while (is.get(c) && c != '"') {cloneName += c;}
492  }
493  else {
494  cloneName += c;
495  while (is.get(c) && c != ' ') {cloneName += c;}
496  }
497  cloneName = cloneName.strip (G4String::both, ' ');
498  cloneName = cloneName.strip (G4String::both, '"');
499 
500  G4bool errorWhileNaming = false;
501  if (cloneName == "none") {
502  G4int subID = 0;
503  do {
504  cloneName = originalName;
505  std::ostringstream oss;
506  oss << '-' << subID++;
507  G4String::size_type lastDashPosition, nextSpacePosition;
508  if ((lastDashPosition = cloneName.rfind('-')) != G4String::npos &&
509  (nextSpacePosition = cloneName.find(" ", lastDashPosition)) !=
510  G4String::npos) {
511  cloneName.insert(nextSpacePosition, oss.str());
512  } else {
513  G4String::size_type spacePosition = cloneName.find(' ');
514  if (spacePosition != G4String::npos)
515  cloneName.insert(spacePosition, oss.str());
516  else
517  errorWhileNaming = true;
518  }
519  } while (!errorWhileNaming && fpVisManager -> GetViewer (cloneName));
520  }
521 
522  if (errorWhileNaming) {
523  if (verbosity >= G4VisManager::errors) {
524  G4cerr << "ERROR: While naming clone viewer \"" << cloneName
525  << "\"."
526  << G4endl;
527  }
528  return;
529  }
530 
531  if (fpVisManager -> GetViewer (cloneName)) {
532  if (verbosity >= G4VisManager::errors) {
533  G4cerr << "ERROR: Putative clone viewer \"" << cloneName
534  << "\" already exists."
535  << G4endl;
536  }
537  return;
538  }
539 
540  G4String windowSizeHint =
541  originalViewer->GetViewParameters().GetXGeometryString();
542 
543  G4UImanager* UImanager = G4UImanager::GetUIpointer();
544  G4int keepVerbose = UImanager->GetVerboseLevel();
545  G4int newVerbose(0);
546  if (keepVerbose >= 2 ||
548  newVerbose = 2;
549  UImanager->SetVerboseLevel(newVerbose);
550  UImanager->ApplyCommand(G4String("/vis/viewer/select " + originalName));
551  UImanager->ApplyCommand
552  (G4String("/vis/viewer/create ! \"" + cloneName + "\" " + windowSizeHint));
553  UImanager->ApplyCommand(G4String("/vis/viewer/set/all " + originalName));
554  UImanager->SetVerboseLevel(keepVerbose);
555 
556  if (verbosity >= G4VisManager::confirmations) {
557  G4cout << "Viewer \"" << originalName << "\" cloned." << G4endl;
558  G4cout << "Clone \"" << cloneName << "\" now current." << G4endl;
559  }
560 }
561 
563 
565  G4bool omitable;
566  fpCommand = new G4UIcommand ("/vis/viewer/colourByDensity", this);
567  fpCommand -> SetGuidance
568  ("If a volume has no vis attributes, colour it by density.");
569  fpCommand -> SetGuidance
570  ("Provide algorithm number, e.g., \"1\" (or \"0\" to switch off)."
571  "\nThen a unit of density, e.g., \"g/cm3\"."
572  "\nThen parameters for the algorithm assumed to be densities in that unit.");
573  fpCommand -> SetGuidance
574  ("Algorithm 1: Simple algorithm takes 3 parameters: d0, d1 and d2."
575  "\nVolumes with density < d0 are invisible."
576  "\nVolumes with d0 <= density < d1 have colour on range red->green."
577  "\nVolumes with d1 <= density < d2 have colour on range green->blue."
578  "\nVolumes with density > d2 are blue.");
579  G4UIparameter* parameter;
580  parameter = new G4UIparameter("n",'i',omitable = true);
581  parameter -> SetDefaultValue (0);
582  parameter -> SetGuidance ("Algorithm number (or \"0\" to switch off).");
583  fpCommand->SetParameter(parameter);
584  parameter = new G4UIparameter("unit",'s',omitable = true);
585  parameter -> SetDefaultValue ("g/cm3");
586  parameter -> SetGuidance ("Unit of following densities, e.g., \"g/cm3\".");
587  fpCommand->SetParameter(parameter);
588  parameter = new G4UIparameter("d0",'d',omitable = true);
589  parameter -> SetDefaultValue (0.);
590  parameter -> SetGuidance ("Density parameter 0.");
591  fpCommand->SetParameter(parameter);
592  parameter = new G4UIparameter("d1",'d',omitable = true);
593  parameter -> SetDefaultValue (0.);
594  parameter -> SetGuidance ("Density parameter 1.");
595  fpCommand->SetParameter(parameter);
596  parameter = new G4UIparameter("d2",'d',omitable = true);
597  parameter -> SetDefaultValue (0.);
598  parameter -> SetGuidance ("Density parameter 2.");
599  fpCommand->SetParameter(parameter);
600 }
601 
603  delete fpCommand;
604 }
605 
607  return "";
608 }
609 
611 
613 
614  G4VViewer* viewer = fpVisManager -> GetCurrentViewer ();
615  if (!viewer) {
616  if (verbosity >= G4VisManager::errors) {
617  G4cerr <<
618  "ERROR: No current viewer - \"/vis/viewer/list\" to see possibilities."
619  << G4endl;
620  }
621  return;
622  }
623  G4ViewParameters vp = viewer->GetViewParameters();
624 
625  G4int algorithmNumber;
626  G4double d0, d1, d2;
627  G4String unit;
628  std::istringstream is (newValue);
629  is >> algorithmNumber >> unit >> d0 >> d1 >> d2;
630 
631  if (algorithmNumber < 0 || algorithmNumber > 1) {
632  if (verbosity >= G4VisManager::errors) {
633  G4cerr <<
634  "ERROR: Unrecognised algorithm number: " << algorithmNumber
635  << G4endl;
636  }
637  return;
638  }
639 
640  std::vector<G4double> parameters;
641  if (algorithmNumber > 0) {
642  const G4String where = "G4VisCommandViewerColourByDensity::SetNewValue";
643  G4double valueOfUnit;
644  // "Volumic Mass" is Michel's phrase for "Density"
645  if (ProvideValueOfUnit(where,unit,"Volumic Mass",valueOfUnit)) {
646  // Successful outcome of unit search
647  d0 *= valueOfUnit; d1 *= valueOfUnit; d2 *= valueOfUnit;
648  } else {
649  if (verbosity >= G4VisManager::errors) {
650  G4cerr <<
651  "ERROR: Unrecognised or inappropriate unit: " << unit
652  << G4endl;
653  }
654  return;
655  }
656  parameters.push_back(d0);
657  parameters.push_back(d1);
658  parameters.push_back(d2);
659  }
660  vp.SetCBDAlgorithmNumber(algorithmNumber);
661  vp.SetCBDParameters(parameters);
662 
663  if (verbosity >= G4VisManager::confirmations) {
664  if (vp.GetCBDAlgorithmNumber() == 0) {
665  G4cout << "Colour by density deactivated" << G4endl;
666  } else {
667  G4cout << "Colour by density algorithm " << vp.GetCBDAlgorithmNumber()
668  << " selected for viewer \"" << viewer->GetName()
669  << "\n Parameters:";
670  for (auto p: vp.GetCBDParameters()) {
671  G4cout << ' ' << G4BestUnit(p,"Volumic Mass");
672  }
673  G4cout << G4endl;
674  }
675  }
676 
677  SetViewParameters(viewer, vp);
678 }
679 
681 
683  G4bool omitable;
684  fpCommand = new G4UIcmdWithAString ("/vis/viewer/copyViewFrom", this);
685  fpCommand -> SetGuidance
686  ("Copy the camera-specific parameters from the specified viewer.");
687  fpCommand -> SetGuidance
688  ("Note: To copy ALL view parameters, including scene modifications,"
689  "\nuse \"/vis/viewer/set/all\"");
690  fpCommand -> SetParameterName ("from-viewer-name", omitable = false);
691 }
692 
694  delete fpCommand;
695 }
696 
698  return "";
699 }
700 
702 
704 
705  G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
706  if (!currentViewer) {
707  if (verbosity >= G4VisManager::errors) {
708  G4cerr <<
709  "ERROR: G4VisCommandsViewerCopyViewFrom::SetNewValue: no current viewer."
710  << G4endl;
711  }
712  return;
713  }
714 
715  const G4String& fromViewerName = newValue;
716  G4VViewer* fromViewer = fpVisManager -> GetViewer (fromViewerName);
717  if (!fromViewer) {
718  if (verbosity >= G4VisManager::errors) {
719  G4cerr << "ERROR: Viewer \"" << fromViewerName
720  << "\" not found - \"/vis/viewer/list\" to see possibilities."
721  << G4endl;
722  }
723  return;
724  }
725 
726  if (fromViewer == currentViewer) {
727  if (verbosity >= G4VisManager::warnings) {
728  G4cout <<
729  "WARNING: G4VisCommandsViewerSet::SetNewValue:"
730  "\n from-viewer and current viewer are identical."
731  << G4endl;
732  }
733  return;
734  }
735 
736  // Copy camera-specific view parameters
737  G4ViewParameters vp = currentViewer->GetViewParameters();
738  const G4ViewParameters& fromVP = fromViewer->GetViewParameters();
742  vp.SetUpVector (fromVP.GetUpVector());
743  vp.SetFieldHalfAngle (fromVP.GetFieldHalfAngle());
744  vp.SetZoomFactor (fromVP.GetZoomFactor());
745  vp.SetScaleFactor (fromVP.GetScaleFactor());
747  vp.SetDolly (fromVP.GetDolly());
748  SetViewParameters(currentViewer, vp);
749 
750  if (verbosity >= G4VisManager::confirmations) {
751  G4cout << "Camera parameters of viewer \"" << currentViewer->GetName()
752  << "\"\n set to those of viewer \"" << fromViewer->GetName()
753  << "\"."
754  << G4endl;
755  }
756 }
757 
759 
761  G4bool omitable;
762  fpCommand = new G4UIcommand ("/vis/viewer/create", this);
763  fpCommand -> SetGuidance
764  ("Creates a viewer for the specified scene handler.");
765  fpCommand -> SetGuidance
766  ("Default scene handler is the current scene handler. Invents a name"
767  "\nif not supplied. (Note: the system adds information to the name"
768  "\nfor identification - only the characters up to the first blank are"
769  "\nused for removing, selecting, etc.) This scene handler and viewer"
770  "\nbecome current.");
771  G4UIparameter* parameter;
772  parameter = new G4UIparameter ("scene-handler", 's', omitable = true);
773  parameter -> SetCurrentAsDefault (true);
774  fpCommand -> SetParameter (parameter);
775  parameter = new G4UIparameter ("viewer-name", 's', omitable = true);
776  parameter -> SetCurrentAsDefault (true);
777  fpCommand -> SetParameter (parameter);
778  parameter = new G4UIparameter ("window-size-hint", 's', omitable = true);
779  parameter->SetGuidance
780  ("integer (pixels) for square window placed by window manager or"
781  " X-Windows-type geometry string, e.g. 600x600-100+100");
782  parameter->SetDefaultValue("600");
783  fpCommand -> SetParameter (parameter);
784 }
785 
787  delete fpCommand;
788 }
789 
791  std::ostringstream oss;
792  G4VSceneHandler* sceneHandler = fpVisManager -> GetCurrentSceneHandler ();
793  oss << "viewer-" << fId << " (";
794  if (sceneHandler) {
795  oss << sceneHandler -> GetGraphicsSystem () -> GetName ();
796  }
797  else {
798  oss << "no_scene_handlers";
799  }
800  oss << ")";
801  return oss.str();
802 }
803 
805  G4String currentValue;
806  G4VSceneHandler* currentSceneHandler =
807  fpVisManager -> GetCurrentSceneHandler ();
808  if (currentSceneHandler) {
809  currentValue = currentSceneHandler -> GetName ();
810  }
811  else {
812  currentValue = "none";
813  }
814  currentValue += ' ';
815  currentValue += '"';
816  currentValue += NextName ();
817  currentValue += '"';
818 
819  currentValue += " 600"; // Default number of pixels for window size hint.
820 
821  return currentValue;
822 }
823 
825 
827 
828  G4String sceneHandlerName, newName;
829  G4String windowSizeHintString;
830  std::istringstream is (newValue);
831  is >> sceneHandlerName;
832 
833  // Now need to handle the possibility that the second string
834  // contains embedded blanks within quotation marks...
835  char c = ' ';
836  while (is.get(c) && c == ' '){}
837  if (c == '"') {
838  while (is.get(c) && c != '"') {newName += c;}
839  }
840  else {
841  newName += c;
842  while (is.get(c) && c != ' ') {newName += c;}
843  }
844  newName = newName.strip (G4String::both, ' ');
845  newName = newName.strip (G4String::both, '"');
846 
847  // Now get window size hint...
848  is >> windowSizeHintString;
849 
850  const G4SceneHandlerList& sceneHandlerList =
851  fpVisManager -> GetAvailableSceneHandlers ();
852  G4int nHandlers = sceneHandlerList.size ();
853  if (nHandlers <= 0) {
854  if (verbosity >= G4VisManager::errors) {
855  G4cerr <<
856  "ERROR: G4VisCommandViewerCreate::SetNewValue: no scene handlers."
857  "\n Create a scene handler with \"/vis/sceneHandler/create\""
858  << G4endl;
859  }
860  return;
861  }
862 
863  G4int iHandler;
864  for (iHandler = 0; iHandler < nHandlers; iHandler++) {
865  if (sceneHandlerList [iHandler] -> GetName () == sceneHandlerName) break;
866  }
867 
868  if (iHandler < 0 || iHandler >= nHandlers) {
869  // Invalid command line argument or none.
870  // This shouldn't happen!!!!!!
871  if (verbosity >= G4VisManager::errors) {
872  G4cout << "G4VisCommandViewerCreate::SetNewValue:"
873  " invalid scene handler specified."
874  << G4endl;
875  }
876  return;
877  }
878 
879  // Valid index. Set current scene handler and graphics system in
880  // preparation for creating viewer.
881  G4VSceneHandler* sceneHandler = sceneHandlerList [iHandler];
882  if (sceneHandler != fpVisManager -> GetCurrentSceneHandler ()) {
883  fpVisManager -> SetCurrentSceneHandler (sceneHandler);
884  }
885 
886  // Now deal with name of viewer.
887  G4String nextName = NextName ();
888  if (newName == "") {
889  newName = nextName;
890  }
891  if (newName == nextName) fId++;
892  G4String newShortName = fpVisManager -> ViewerShortName (newName);
893 
894  for (G4int ih = 0; ih < nHandlers; ih++) {
895  G4VSceneHandler* sh = sceneHandlerList [ih];
896  const G4ViewerList& viewerList = sh -> GetViewerList ();
897  for (size_t iViewer = 0; iViewer < viewerList.size (); iViewer++) {
898  if (viewerList [iViewer] -> GetShortName () == newShortName ) {
899  if (verbosity >= G4VisManager::errors) {
900  G4cerr << "ERROR: Viewer \"" << newShortName << "\" already exists."
901  << G4endl;
902  }
903  return;
904  }
905  }
906  }
907 
908  // WindowSizeHint and XGeometryString are picked up from the vis
909  // manager in the G4VViewer constructor. In G4VisManager, after Viewer
910  // creation, we will store theses parameters in G4ViewParameters.
911 
912  fpVisManager -> CreateViewer (newName,windowSizeHintString);
913 
914  G4VViewer* newViewer = fpVisManager -> GetCurrentViewer ();
915  if (newViewer && newViewer -> GetName () == newName) {
916  if (verbosity >= G4VisManager::confirmations) {
917  G4cout << "New viewer \"" << newName << "\" created." << G4endl;
918  }
919  }
920  else {
921  if (verbosity >= G4VisManager::errors) {
922  if (newViewer) {
923  G4cerr << "ERROR: New viewer doesn\'t match!!! Curious!!" << G4endl;
924  } else {
925  G4cout << "WARNING: No viewer created." << G4endl;
926  }
927  }
928  }
929  // Refresh if appropriate...
930  if (newViewer) {
931  if (newViewer->GetViewParameters().IsAutoRefresh()) {
932  G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
933  }
934  else {
935  if (verbosity >= G4VisManager::warnings) {
936  G4cout << "Issue /vis/viewer/refresh or flush to see effect."
937  << G4endl;
938  }
939  }
940  }
941 }
942 
944 
946  fDollyIncrement (0.),
947  fDollyTo (0.)
948 {
949  G4bool omitable, currentAsDefault;
950 
952  ("/vis/viewer/dolly", this);
953  fpCommandDolly -> SetGuidance
954  ("Incremental dolly.");
955  fpCommandDolly -> SetGuidance
956  ("Moves the camera incrementally towards target point.");
957  fpCommandDolly -> SetParameterName("increment",
958  omitable=true,
959  currentAsDefault=true);
960  fpCommandDolly -> SetDefaultUnit("m");
961 
963  ("/vis/viewer/dollyTo", this);
964  fpCommandDollyTo -> SetGuidance
965  ("Dolly to specific coordinate.");
966  fpCommandDollyTo -> SetGuidance
967  ("Places the camera towards target point relative to standard camera point.");
968  fpCommandDollyTo -> SetParameterName("distance",
969  omitable=true,
970  currentAsDefault=true);
971  fpCommandDollyTo -> SetDefaultUnit("m");
972 }
973 
975  delete fpCommandDolly;
976  delete fpCommandDollyTo;
977 }
978 
980  G4String currentValue;
981  if (command == fpCommandDolly) {
982  currentValue = fpCommandDolly->ConvertToString(fDollyIncrement, "m");
983  }
984  else if (command == fpCommandDollyTo) {
985  currentValue = fpCommandDollyTo->ConvertToString(fDollyTo, "m");
986  }
987  return currentValue;
988 }
989 
991  G4String newValue) {
992 
993 
995 
996  G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
997  if (!currentViewer) {
998  if (verbosity >= G4VisManager::errors) {
999  G4cerr <<
1000  "ERROR: G4VisCommandsViewerDolly::SetNewValue: no current viewer."
1001  << G4endl;
1002  }
1003  return;
1004  }
1005 
1006  G4ViewParameters vp = currentViewer->GetViewParameters();
1007 
1008  if (command == fpCommandDolly) {
1011  }
1012  else if (command == fpCommandDollyTo) {
1014  vp.SetDolly(fDollyTo);
1015  }
1016 
1017  if (verbosity >= G4VisManager::confirmations) {
1018  G4cout << "Dolly distance changed to " << vp.GetDolly() << G4endl;
1019  }
1020 
1021  SetViewParameters(currentViewer, vp);
1022 }
1023 
1025 
1027  G4bool omitable, currentAsDefault;
1028  fpCommand = new G4UIcmdWithAString ("/vis/viewer/flush", this);
1029  fpCommand -> SetGuidance
1030  ("Compound command: \"/vis/viewer/refresh\" + \"/vis/viewer/update\".");
1031  fpCommand -> SetGuidance
1032  ("Useful for refreshing and initiating post-processing for graphics"
1033  "\nsystems which need post-processing. By default, acts on current"
1034  "\nviewer. \"/vis/viewer/list\" to see possible viewers. Viewer"
1035  "\nbecomes current.");
1036  fpCommand -> SetParameterName ("viewer-name",
1037  omitable = true,
1038  currentAsDefault = true);
1039 }
1040 
1042  delete fpCommand;
1043 }
1044 
1047  G4VViewer* viewer = fpVisManager -> GetCurrentViewer ();
1048  return viewer ? viewer -> GetName () : G4String("none");
1049 }
1050 
1052 
1054 
1055  G4String& flushName = newValue;
1056  G4VViewer* viewer = fpVisManager -> GetViewer (flushName);
1057  if (!viewer) {
1058  if (verbosity >= G4VisManager::errors) {
1059  G4cerr << "ERROR: Viewer \"" << flushName << "\"" <<
1060  " not found - \"/vis/viewer/list\"\n to see possibilities."
1061  << G4endl;
1062  }
1063  return;
1064  }
1065 
1067  G4int keepVerbose = ui->GetVerboseLevel();
1068  G4int newVerbose(0);
1069  if (keepVerbose >= 2 || verbosity >= G4VisManager::confirmations)
1070  newVerbose = 2;
1071  ui->SetVerboseLevel(newVerbose);
1072  ui->ApplyCommand(G4String("/vis/viewer/refresh " + flushName));
1073  ui->ApplyCommand(G4String("/vis/viewer/update " + flushName));
1074  ui->SetVerboseLevel(keepVerbose);
1075  if (verbosity >= G4VisManager::confirmations) {
1076  G4cout << "Viewer \"" << viewer -> GetName () << "\""
1077  << " flushed." << G4endl;
1078  }
1079 }
1080 
1082 
1084  G4bool omitable;
1085  fpCommand = new G4UIcommand ("/vis/viewer/interpolate", this);
1086  fpCommand -> SetGuidance
1087  ("Interpolate views defined by the first argument, which can contain "
1088  "Unix-shell-style pattern matching characters such as '*', '?' and '[' "
1089  "- see \"man sh\" and look for \"Pattern Matching\". The contents "
1090  "of each file are assumed to be \"/vis/viewer\" commands "
1091  "that specify a particular view. The files are processed in alphanumeric "
1092  "order of filename. The files may be written by hand or produced by the "
1093  "\"/vis/viewer/save\" command.");
1094  fpCommand -> SetGuidance
1095  ("The default is to search the working directory for files with a .g4view "
1096  "extension. Another procedure is to assemble view files in a subdirectory, "
1097  "e.g., \"myviews\"; then they can be interpolated with\n"
1098  "\"/vis/viewer/interpolate myviews/*\".");
1099  fpCommand -> SetGuidance
1100  ("To export interpolated views to file for a future possible movie, "
1101  "write \"export\" as 5th parameter (OpenGL only).");
1102  G4UIparameter* parameter;
1103  parameter = new G4UIparameter("pattern", 's', omitable = true);
1104  parameter -> SetGuidance("Pattern that defines the view files.");
1105  parameter -> SetDefaultValue("*.g4view");
1106  fpCommand -> SetParameter(parameter);
1107  parameter = new G4UIparameter("no-of-points", 'i', omitable = true);
1108  parameter -> SetGuidance ("Number of interpolation points per interval.");
1109  parameter -> SetDefaultValue(50);
1110  fpCommand -> SetParameter(parameter);
1111  parameter = new G4UIparameter("wait-time", 's', omitable = true);
1112  parameter -> SetGuidance("Wait time per interpolated point");
1113  parameter -> SetDefaultValue("20.");
1114  fpCommand -> SetParameter(parameter);
1115  parameter = new G4UIparameter("time-unit", 's', omitable = true);
1116  parameter -> SetDefaultValue("millisecond");
1117  fpCommand -> SetParameter (parameter);
1118  parameter = new G4UIparameter("export", 's', omitable = true);
1119  parameter -> SetDefaultValue("no");
1120  fpCommand -> SetParameter (parameter);
1121 }
1122 
1124  delete fpCommand;
1125 }
1126 
1128  return "";
1129 }
1130 
1132 
1134 
1135  G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
1136  if (!currentViewer) {
1137  if (verbosity >= G4VisManager::errors) {
1138  G4cerr <<
1139  "ERROR: G4VisCommandViewerInterpolate::SetNewValue: no current viewer."
1140  << G4endl;
1141  }
1142  return;
1143  }
1144 
1145  G4String pattern;
1146  G4int nInterpolationPoints;
1147  G4String waitTimePerPointString;
1148  G4String timeUnit;
1149  G4String exportString;
1150 
1151  std::istringstream iss (newValue);
1152  iss
1153  >> pattern
1154  >> nInterpolationPoints
1155  >> waitTimePerPointString
1156  >> timeUnit
1157  >> exportString;
1158  G4String waitTimePerPointDimString(waitTimePerPointString + ' ' + timeUnit);
1159  const G4double waitTimePerPoint =
1160  G4UIcommand::ConvertToDimensionedDouble(waitTimePerPointDimString.c_str());
1161  G4int waitTimePerPointmilliseconds = waitTimePerPoint/millisecond;
1162  if (waitTimePerPointmilliseconds < 0) waitTimePerPointmilliseconds = 0;
1163 
1164  G4UImanager* uiManager = G4UImanager::GetUIpointer();
1165 
1166  // Save current view parameters
1167  G4ViewParameters saveVP = currentViewer->GetViewParameters();
1168 
1169  // Save current verbosities
1170  G4VisManager::Verbosity keepVisVerbosity = fpVisManager->GetVerbosity();
1171  G4int keepUIVerbosity = uiManager->GetVerboseLevel();
1172 
1173  // Set verbosities for this operation
1175  uiManager->SetVerboseLevel(0);
1176 
1177  // Switch off auto-refresh while we read in the view files (it will be
1178  // restored later). Note: the view files do not set auto-refresh.
1179  G4ViewParameters non_auto = saveVP;
1180  non_auto.SetAutoRefresh(false);
1181  currentViewer->SetViewParameters(non_auto);
1182 
1183  // View vector of way points
1184  std::vector<G4ViewParameters> viewVector;
1185 
1186  const G4int safety = 9999;
1187  G4int safetyCount = 0;
1188  G4String pathname;
1189 
1190 #ifndef WIN32
1191 
1192  // Execute pattern and get resulting list of filles
1193  G4String shellCommand = "echo " + pattern;
1194  FILE *filelist = popen(shellCommand.c_str(), "r");
1195  if (!filelist) {
1196  if (verbosity >= G4VisManager::errors) {
1197  G4cerr
1198  << "ERROR: G4VisCommandViewerInterpolate::SetNewValue:"
1199  << "\n Error obtaining pipe."
1200  << G4endl;
1201  }
1202  return;
1203  }
1204 
1205  // Build view vector of way points
1206  const size_t BUFLENGTH = 999999;
1207  char buf[BUFLENGTH];
1208  fgets(buf, BUFLENGTH, filelist);
1209  std::istringstream fileliststream(buf);
1210  while (fileliststream >> pathname
1211  && safetyCount++ < safety) { // Loop checking, 16.02.2016, J.Allison
1212  uiManager->ApplyCommand("/control/execute " + pathname);
1213  viewVector.push_back(currentViewer->GetViewParameters());
1214  }
1215  pclose(filelist);
1216 
1217 #else // WIN32 (popen is not available in Windows)
1218 
1219  std::experimental::filesystem::v1::path filePattern(pattern);
1220 
1221  // Default pattern : *.g4view
1222  // Translated to a regexp : ^.*\\.g4view
1223  // Convert pattern into a regexp
1224  std::string regexp_pattern("^" + filePattern.filename().string());
1225  std::string result_pattern = "";
1226  // Replace '.' by "\\."
1227  size_t currentPos = 0;
1228  size_t nextPos = 0;
1229  std::string currentReplacement = "";
1230  size_t pos1 = regexp_pattern.find('.', nextPos);
1231  size_t pos2 = regexp_pattern.find('*', nextPos);
1232  size_t pos3 = regexp_pattern.find('?', nextPos);
1233  while ((pos1 != std::string::npos) || (pos2 != std::string::npos) || (pos3 != std::string::npos)) {
1234  nextPos = pos1;
1235  currentReplacement = "\\.";
1236  if (pos2 < nextPos) {
1237  nextPos = pos2;
1238  currentReplacement = ".*";
1239  }
1240  if (pos3 < nextPos) {
1241  nextPos = pos3;
1242  currentReplacement = "(.{1,1})";
1243  }
1244  result_pattern += regexp_pattern.substr(currentPos, nextPos - currentPos) + currentReplacement;
1245  nextPos++;
1246  currentPos = nextPos;
1247  pos1 = regexp_pattern.find('.', currentPos);
1248  pos2 = regexp_pattern.find('*', currentPos);
1249  pos3 = regexp_pattern.find('?', currentPos);
1250  }
1251  result_pattern += regexp_pattern.substr(currentPos);
1252 
1253  // Build view vector of way points
1254  // Add "./" for empty paths
1255  G4String parentPath(filePattern.parent_path().string().length() ? filePattern.parent_path().string() : std::string("./"));
1256  // Iterate through files in directory and apply regex match to filter appropriate files
1257  std::regex result_pattern_regex (result_pattern, std::regex_constants::basic | std::regex_constants::icase);
1258  for (auto iter = std::experimental::filesystem::v1::directory_iterator(parentPath);
1259  iter != std::experimental::filesystem::v1::directory_iterator() && safetyCount++ < safety;
1260  ++iter)
1261  {
1262  const auto& file = iter->path();
1263 
1264  G4String filename(file.filename().string());
1265  if (std::regex_match(filename, result_pattern_regex))
1266  {
1267  uiManager->ApplyCommand("/control/execute " + filename);
1268  viewVector.push_back(currentViewer->GetViewParameters());
1269  }
1270  }
1271 
1272 #endif // WIN32
1273 
1274  if (safetyCount >= safety) {
1275  if (verbosity >= G4VisManager::errors) {
1276  G4cout <<
1277  "/vis/viewer/interpolate:"
1278  "\n the number of way points exceeds the maximum currently allowed: "
1279  << safety << G4endl;
1280  }
1281  return;
1282  }
1283 
1284  // Interpolate views
1285  safetyCount = 0;
1286  do {
1287  G4ViewParameters* vp =
1288  G4ViewParameters::CatmullRomCubicSplineInterpolation(viewVector,nInterpolationPoints);
1289  if (!vp) break; // Finished.
1290  // Set original auto-refresh status.
1291  vp->SetAutoRefresh(saveVP.IsAutoRefresh());
1292  currentViewer->SetViewParameters(*vp);
1293  currentViewer->RefreshView();
1294  if (exportString == "export" &&
1295  currentViewer->GetName().contains("OpenGL")) {
1296  uiManager->ApplyCommand("/vis/ogl/export");
1297  }
1298  // File-writing viewers need to close the file
1299  currentViewer->ShowView();
1300 #ifdef G4VIS_USE_STD11
1301  if (waitTimePerPointmilliseconds > 0)
1302  std::this_thread::sleep_for(std::chrono::milliseconds(waitTimePerPointmilliseconds));
1303 #endif
1304  } while (safetyCount++ < safety); // Loop checking, 16.02.2016, J.Allison
1305 
1306  // Restore original verbosities
1307  uiManager->SetVerboseLevel(keepUIVerbosity);
1308  fpVisManager->SetVerboseLevel(keepVisVerbosity);
1309 
1310  // Restore original view parameters
1311  currentViewer->SetViewParameters(saveVP);
1312  currentViewer->RefreshView();
1313  if (verbosity >= G4VisManager::confirmations) {
1314  G4cout << "Viewer \"" << currentViewer -> GetName () << "\""
1315  << " restored." << G4endl;
1316  }
1317 }
1318 
1320 
1322  G4bool omitable;
1323  fpCommand = new G4UIcommand ("/vis/viewer/list", this);
1324  fpCommand -> SetGuidance ("Lists viewers(s).");
1325  fpCommand -> SetGuidance
1326  ("See \"/vis/verbose\" for definition of verbosity.");
1327  G4UIparameter* parameter;
1328  parameter = new G4UIparameter("viewer-name", 's',
1329  omitable = true);
1330  parameter -> SetDefaultValue ("all");
1331  fpCommand -> SetParameter (parameter);
1332  parameter = new G4UIparameter ("verbosity", 's',
1333  omitable = true);
1334  parameter -> SetDefaultValue ("warnings");
1335  fpCommand -> SetParameter (parameter);
1336 }
1337 
1339  delete fpCommand;
1340 }
1341 
1343  return "";
1344 }
1345 
1347  G4String name, verbosityString;
1348  std::istringstream is (newValue);
1349  is >> name >> verbosityString;
1350  G4String shortName = fpVisManager -> ViewerShortName (name);
1351  G4VisManager::Verbosity verbosity =
1352  fpVisManager->GetVerbosityValue(verbosityString);
1353 
1354  const G4VViewer* currentViewer = fpVisManager -> GetCurrentViewer ();
1355  G4String currentViewerShortName;
1356  if (currentViewer) {
1357  currentViewerShortName = currentViewer -> GetShortName ();
1358  }
1359  else {
1360  currentViewerShortName = "none";
1361  }
1362 
1363  const G4SceneHandlerList& sceneHandlerList =
1364  fpVisManager -> GetAvailableSceneHandlers ();
1365  G4int nHandlers = sceneHandlerList.size ();
1366  G4bool found = false;
1367  G4bool foundCurrent = false;
1368  for (int iHandler = 0; iHandler < nHandlers; iHandler++) {
1369  G4VSceneHandler* sceneHandler = sceneHandlerList [iHandler];
1370  const G4ViewerList& viewerList = sceneHandler -> GetViewerList ();
1371  G4cout
1372  << "Scene handler \"" << sceneHandler -> GetName () << "\" ("
1373  << sceneHandler->GetGraphicsSystem()->GetNickname() << ')';
1374  const G4Scene* pScene = sceneHandler -> GetScene ();
1375  if (pScene) {
1376  G4cout << ", scene \"" << pScene -> GetName () << "\"";
1377  }
1378  G4cout << ':';
1379  G4int nViewers = viewerList.size ();
1380  if (nViewers == 0) {
1381  G4cout << "\n No viewers for this scene handler." << G4endl;
1382  }
1383  else {
1384  for (int iViewer = 0; iViewer < nViewers; iViewer++) {
1385  const G4VViewer* thisViewer = viewerList [iViewer];
1386  G4String thisName = thisViewer -> GetName ();
1387  G4String thisShortName = thisViewer -> GetShortName ();
1388  if (name != "all") {
1389  if (thisShortName != shortName) continue;
1390  }
1391  found = true;
1392  G4cout << "\n ";
1393  if (thisShortName == currentViewerShortName) {
1394  foundCurrent = true;
1395  G4cout << "(current)";
1396  }
1397  else {
1398  G4cout << " ";
1399  }
1400  G4cout << " viewer \"" << thisName << "\"";
1401  if (verbosity >= G4VisManager::parameters) {
1402  G4cout << "\n " << *thisViewer;
1403  }
1404  }
1405  }
1406  G4cout << G4endl;
1407  }
1408 
1409  if (!foundCurrent) {
1410  G4cout << "No valid current viewer - please create or select one."
1411  << G4endl;
1412  }
1413 
1414  if (!found) {
1415  G4cout << "No viewers";
1416  if (name != "all") {
1417  G4cout << " of name \"" << name << "\"";
1418  }
1419  G4cout << " found." << G4endl;
1420  }
1421 }
1422 
1424 
1426  fPanIncrementRight (0.),
1427  fPanIncrementUp (0.),
1428  fPanToRight (0.),
1429  fPanToUp (0.)
1430 {
1431  G4bool omitable;
1432 
1434  ("/vis/viewer/pan", this);
1435  fpCommandPan -> SetGuidance
1436  ("Incremental pan.");
1437  fpCommandPan -> SetGuidance
1438  ("Moves the camera incrementally right and up by these amounts (as seen"
1439  "\nfrom viewpoint direction).");
1440  G4UIparameter* parameter;
1441  parameter = new G4UIparameter("right-increment", 'd', omitable = true);
1442  parameter -> SetCurrentAsDefault (true);
1443  fpCommandPan -> SetParameter (parameter);
1444  parameter = new G4UIparameter("up-increment", 'd', omitable = true);
1445  parameter -> SetCurrentAsDefault (true);
1446  fpCommandPan -> SetParameter (parameter);
1447  parameter = new G4UIparameter ("unit", 's', omitable = true);
1448  parameter -> SetDefaultValue ("m");
1449  fpCommandPan -> SetParameter (parameter);
1450 
1452  ("/vis/viewer/panTo", this);
1453  fpCommandPanTo -> SetGuidance
1454  ("Pan to specific coordinate.");
1455  fpCommandPanTo -> SetGuidance
1456  ("Places the camera in this position right and up relative to standard"
1457  "\ntarget point (as seen from viewpoint direction).");
1458  parameter = new G4UIparameter("right", 'd', omitable = true);
1459  parameter -> SetCurrentAsDefault (true);
1460  fpCommandPanTo -> SetParameter (parameter);
1461  parameter = new G4UIparameter("up", 'd', omitable = true);
1462  parameter -> SetCurrentAsDefault (true);
1463  fpCommandPanTo -> SetParameter (parameter);
1464  parameter = new G4UIparameter ("unit", 's', omitable = true);
1465  parameter -> SetDefaultValue ("m");
1466  fpCommandPanTo -> SetParameter (parameter);
1467 }
1468 
1470  delete fpCommandPan;
1471  delete fpCommandPanTo;
1472 }
1473 
1475  G4String currentValue;
1476  if (command == fpCommandPan) {
1477  currentValue = ConvertToString(fPanIncrementRight, fPanIncrementUp, "m");
1478  }
1479  else if (command == fpCommandPanTo) {
1480  currentValue = ConvertToString(fPanToRight, fPanToUp, "m");
1481  }
1482  return currentValue;
1483 }
1484 
1486  G4String newValue) {
1487 
1488 
1490 
1491  G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
1492  if (!currentViewer) {
1493  if (verbosity >= G4VisManager::errors) {
1494  G4cerr <<
1495  "ERROR: G4VisCommandsViewerPan::SetNewValue: no current viewer."
1496  << G4endl;
1497  }
1498  return;
1499  }
1500 
1501  G4ViewParameters vp = currentViewer->GetViewParameters();
1502 
1503  if (command == fpCommandPan) {
1506  }
1507  else if (command == fpCommandPanTo) {
1510  }
1511 
1512  if (verbosity >= G4VisManager::confirmations) {
1513  G4cout << "Current target point now " << vp.GetCurrentTargetPoint()
1514  << G4endl;
1515  }
1516 
1517  SetViewParameters(currentViewer, vp);
1518 }
1519 
1521 
1523  G4bool omitable, currentAsDefault;
1524  fpCommand = new G4UIcmdWithAString ("/vis/viewer/rebuild", this);
1525  fpCommand -> SetGuidance ("Forces rebuild of graphical database.");
1526  fpCommand -> SetGuidance
1527  ("By default, acts on current viewer. \"/vis/viewer/list\""
1528  "\nto see possible viewers. Viewer becomes current.");
1529  fpCommand -> SetParameterName ("viewer-name",
1530  omitable = true,
1531  currentAsDefault = true);
1532 }
1533 
1535  delete fpCommand;
1536 }
1537 
1539  G4VViewer* viewer = fpVisManager -> GetCurrentViewer ();
1540  if (viewer) {
1541  return viewer -> GetName ();
1542  }
1543  else {
1544  return "none";
1545  }
1546 }
1547 
1549 
1551 
1552  G4String& rebuildName = newValue;
1553 
1554  G4VViewer* viewer = fpVisManager -> GetViewer (rebuildName);
1555  if (!viewer) {
1556  if (verbosity >= G4VisManager::errors) {
1557  G4cerr << "ERROR: Viewer \"" << rebuildName
1558  << "\" not found - \"/vis/viewer/list\" to see possibilities."
1559  << G4endl;
1560  }
1561  return;
1562  }
1563 
1564  G4VSceneHandler* sceneHandler = viewer->GetSceneHandler();
1565  if (!sceneHandler) {
1566  if (verbosity >= G4VisManager::errors) {
1567  G4cerr << "ERROR: Viewer \"" << viewer->GetName() << "\"" <<
1568  " has no scene handler - report serious bug."
1569  << G4endl;
1570  }
1571  return;
1572  }
1573 
1574  sceneHandler->ClearTransientStore();
1575  viewer->NeedKernelVisit();
1576  viewer->SetView();
1577  viewer->ClearView();
1578  viewer->DrawView();
1579 
1580  // Check auto-refresh and print confirmations.
1581  RefreshIfRequired(viewer);
1582 }
1583 
1585 
1587  G4bool omitable, currentAsDefault;
1588  fpCommand = new G4UIcmdWithAString ("/vis/viewer/refresh", this);
1589  fpCommand -> SetGuidance
1590  ("Refreshes viewer.");
1591  fpCommand -> SetGuidance
1592  ("By default, acts on current viewer. \"/vis/viewer/list\""
1593  "\nto see possible viewers. Viewer becomes current.");
1594  fpCommand -> SetParameterName ("viewer-name",
1595  omitable = true,
1596  currentAsDefault = true);
1597 }
1598 
1600  delete fpCommand;
1601 }
1602 
1604  G4VViewer* viewer = fpVisManager -> GetCurrentViewer ();
1605  return viewer ? viewer -> GetName () : G4String("none");
1606 }
1607 
1609 
1611  G4bool warn(verbosity >= G4VisManager::warnings);
1612 
1613  G4String& refreshName = newValue;
1614  G4VViewer* viewer = fpVisManager -> GetViewer (refreshName);
1615  if (!viewer) {
1616  if (verbosity >= G4VisManager::errors) {
1617  G4cerr << "ERROR: Viewer \"" << refreshName << "\"" <<
1618  " not found - \"/vis/viewer/list\"\n to see possibilities."
1619  << G4endl;
1620  }
1621  return;
1622  }
1623 
1624  G4VSceneHandler* sceneHandler = viewer->GetSceneHandler();
1625  if (!sceneHandler) {
1626  if (verbosity >= G4VisManager::errors) {
1627  G4cerr << "ERROR: Viewer \"" << refreshName << "\"" <<
1628  " has no scene handler - report serious bug."
1629  << G4endl;
1630  }
1631  return;
1632  }
1633 
1634  G4Scene* scene = sceneHandler->GetScene();
1635  if (!scene) {
1636  if (verbosity >= G4VisManager::confirmations) {
1637  G4cout << "NOTE: SceneHandler \"" << sceneHandler->GetName()
1638  << "\", to which viewer \"" << refreshName << "\"" <<
1639  "\n is attached, has no scene - \"/vis/scene/create\" and"
1640  " \"/vis/sceneHandler/attach\""
1641  "\n (or use compound command \"/vis/drawVolume\")."
1642  << G4endl;
1643  }
1644  return;
1645  }
1646  if (scene->GetRunDurationModelList().empty()) {
1647  G4bool successful = scene -> AddWorldIfEmpty (warn);
1648  if (!successful) {
1649  if (verbosity >= G4VisManager::warnings) {
1650  G4cout <<
1651  "WARNING: Scene is empty. Perhaps no geometry exists."
1652  "\n Try /run/initialize."
1653  << G4endl;
1654  }
1655  return;
1656  }
1657  // Scene has changed. UpdateVisManagerScene issues
1658  // /vis/scene/notifyHandlers, which does a refresh anyway, so the
1659  // ordinary refresh becomes part of the else phrase...
1660  UpdateVisManagerScene(scene->GetName());
1661  } else {
1662  if (verbosity >= G4VisManager::confirmations) {
1663  G4cout << "Refreshing viewer \"" << viewer -> GetName () << "\"..."
1664  << G4endl;
1665  }
1666  viewer -> SetView ();
1667  viewer -> ClearView ();
1668  viewer -> DrawView ();
1669  if (verbosity >= G4VisManager::confirmations) {
1670  G4cout << "Viewer \"" << viewer -> GetName () << "\"" << " refreshed."
1671  "\n (You might also need \"/vis/viewer/update\".)" << G4endl;
1672  }
1673  }
1674 }
1675 
1677 
1679  G4bool omitable, currentAsDefault;
1680  fpCommand = new G4UIcmdWithAString ("/vis/viewer/reset", this);
1681  fpCommand -> SetGuidance ("Resets viewer.");
1682  fpCommand -> SetGuidance
1683  ("By default, acts on current viewer. \"/vis/viewer/list\""
1684  "\nto see possible viewers. Viewer becomes current.");
1685  fpCommand -> SetParameterName ("viewer-name",
1686  omitable = true,
1687  currentAsDefault = true);
1688 }
1689 
1691  delete fpCommand;
1692 }
1693 
1695  G4VViewer* viewer = fpVisManager -> GetCurrentViewer ();
1696  if (viewer) {
1697  return viewer -> GetName ();
1698  }
1699  else {
1700  return "none";
1701  }
1702 }
1703 
1705 
1707 
1708  G4String& resetName = newValue;
1709  G4VViewer* viewer = fpVisManager -> GetViewer (resetName);
1710  if (!viewer) {
1711  if (verbosity >= G4VisManager::errors) {
1712  G4cerr << "ERROR: Viewer \"" << resetName
1713  << "\" not found - \"/vis/viewer/list\" to see possibilities."
1714  << G4endl;
1715  }
1716  return;
1717  }
1718 
1719  viewer->ResetView();
1720  RefreshIfRequired(viewer);
1721 }
1722 
1724 
1726  G4bool omitable;
1727  fpCommand = new G4UIcmdWithAString ("/vis/viewer/save", this);
1728  fpCommand -> SetGuidance
1729  ("Write commands that define the current view to file.");
1730  fpCommand -> SetGuidance
1731  ("Read them back into the same or any viewer with \"/control/execute\".");
1732  fpCommand -> SetGuidance
1733  ("If the filename is omitted the view is saved to a file "
1734  "\"g4_nn.g4view\", where nn is a sequential two-digit number.");
1735  fpCommand -> SetGuidance
1736  ("If the filename is \"-\", the data are written to G4cout.");
1737  fpCommand -> SetGuidance
1738  ("If you are wanting to save views for future interpolation a recommended "
1739  "procedure is: save views to \"g4_nn.g4view\", as above, then move the files "
1740  "into a sub-directory, say, \"views\", then interpolate with"
1741  "\"/vis/viewer/interpolate views/\" (note the trailing \'/\').");
1742  fpCommand -> SetParameterName ("filename", omitable = true);
1743  fpCommand -> SetDefaultValue ("");
1744 }
1745 
1747  delete fpCommand;
1748 }
1749 
1752  return "";
1753 }
1754 
1755 namespace {
1756  void WriteCommands
1757  (std::ostream& os,
1758  const G4ViewParameters& vp,
1759  const G4Point3D& stp) // Standard Target Point
1760  {
1761  os
1762  << vp.CameraAndLightingCommands(stp)
1763  << vp.DrawingStyleCommands()
1764  << vp.SceneModifyingCommands()
1765  << vp.TouchableCommands()
1766  << vp.TimeWindowCommands()
1767  << std::endl;
1768  }
1769 }
1770 
1772 
1774 
1775  const G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
1776  if (!currentViewer) {
1777  if (verbosity >= G4VisManager::errors) {
1778  G4cerr <<
1779  "ERROR: G4VisCommandsViewerSave::SetNewValue: no current viewer."
1780  << G4endl;
1781  }
1782  return;
1783  }
1784 
1785  const G4Scene* currentScene = currentViewer->GetSceneHandler()->GetScene();
1786  if (!currentScene) {
1787  if (verbosity >= G4VisManager::errors) {
1788  G4cerr <<
1789  "ERROR: G4VisCommandsViewerSave::SetNewValue: no current scene."
1790  << G4endl;
1791  }
1792  return;
1793  }
1794 
1795  // Get view parameters and ther relevant information.
1796  G4ViewParameters vp = currentViewer->GetViewParameters();
1797  // Concatenate any private vis attributes modifiers...
1798  const std::vector<G4ModelingParameters::VisAttributesModifier>*
1799  privateVAMs = currentViewer->GetPrivateVisAttributesModifiers();
1800  if (privateVAMs) {
1801  std::vector<G4ModelingParameters::VisAttributesModifier>::const_iterator i;
1802  for (i = privateVAMs->begin(); i != privateVAMs->end(); ++i) {
1803  vp.AddVisAttributesModifier(*i);
1804  }
1805  }
1806  const G4Point3D& stp = currentScene->GetStandardTargetPoint();
1807 
1808  G4String filename = newValue;
1809 
1810  if (newValue.length() == 0) {
1811  // Null filename - generate a filename
1812  const G4int maxNoOfFiles = 100;
1813  static G4int sequenceNumber = 0;
1814  if (sequenceNumber >= maxNoOfFiles) {
1815  if (verbosity >= G4VisManager::errors) {
1816  G4cerr
1817  << "ERROR: G4VisCommandsViewerSave::SetNewValue: Maximum number, "
1818  << maxNoOfFiles
1819  << ", of files exceeded."
1820  << G4endl;
1821  }
1822  return;
1823  }
1824  std::ostringstream oss;
1825  oss << std::setw(2) << std::setfill('0') << sequenceNumber++;
1826  filename = "g4_" + oss.str() + ".g4view";
1827  }
1828 
1829  if (filename == "-") {
1830  // Write to standard output
1831  WriteCommands(G4cout,vp,stp);
1832  } else {
1833  // Write to file - but add extension if not prescribed
1834  if (!filename.contains('.')) {
1835  // No extension supplied - add .g4view
1836  filename += ".g4view";
1837  }
1838  std::ofstream ofs(filename);
1839  if (!ofs) {
1840  if (verbosity >= G4VisManager::errors) {
1841  G4cerr <<
1842  "ERROR: G4VisCommandsViewerSave::SetNewValue: Trouble opening file \""
1843  << filename << "\"."
1844  << G4endl;
1845  }
1846  ofs.close();
1847  return;
1848  }
1849  WriteCommands(ofs,vp,stp);
1850  ofs.close();
1851  }
1852 
1853  if (verbosity >= G4VisManager::warnings) {
1854  G4cout << "Viewer \"" << currentViewer -> GetName ()
1855  << "\"" << " saved to ";
1856  if (filename == "-") {
1857  G4cout << "G4cout.";
1858  } else {
1859  G4cout << "file \'" << filename << "\"." <<
1860  "\n Read the view back into this or any viewer with"
1861  "\n \"/control/execute " << filename << "\" or use"
1862  "\n \"/vis/viewer/interpolate\" if you have several saved files -"
1863  "\n see \"help /vis/viewer/interpolate\" for guidance.";
1864  }
1865  G4cout << G4endl;
1866  }
1867 }
1868 
1870 
1872  fScaleMultiplier (G4Vector3D (1., 1., 1.)),
1873  fScaleTo (G4Vector3D (1., 1., 1.))
1874 {
1875  G4bool omitable, currentAsDefault;
1876 
1878  ("/vis/viewer/scale", this);
1879  fpCommandScale -> SetGuidance ("Incremental (non-uniform) scaling.");
1880  fpCommandScale -> SetGuidance
1881  ("Multiplies components of current scaling by components of this factor."
1882  "\n Scales (x,y,z) by corresponding components of the resulting factor.");
1883  fpCommandScale -> SetGuidance
1884  ("");
1885  fpCommandScale -> SetParameterName
1886  ("x-scale-multiplier","y-scale-multiplier","z-scale-multiplier",
1887  omitable=true, currentAsDefault=true);
1888 
1890  ("/vis/viewer/scaleTo", this);
1891  fpCommandScaleTo -> SetGuidance ("Absolute (non-uniform) scaling.");
1892  fpCommandScaleTo -> SetGuidance
1893  ("Scales (x,y,z) by corresponding components of this factor.");
1894  fpCommandScaleTo -> SetParameterName
1895  ("x-scale-factor","y-scale-factor","z-scale-factor",
1896  omitable=true, currentAsDefault=true);
1897 }
1898 
1900  delete fpCommandScale;
1901  delete fpCommandScaleTo;
1902 }
1903 
1905  G4String currentValue;
1906  if (command == fpCommandScale) {
1908  }
1909  else if (command == fpCommandScaleTo) {
1911  }
1912  return currentValue;
1913 }
1914 
1916  G4String newValue) {
1917 
1918 
1920 
1921  G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
1922  if (!currentViewer) {
1923  if (verbosity >= G4VisManager::errors) {
1924  G4cerr <<
1925  "ERROR: G4VisCommandsViewerScale::SetNewValue: no current viewer."
1926  << G4endl;
1927  }
1928  return;
1929  }
1930 
1931  G4ViewParameters vp = currentViewer->GetViewParameters();
1932 
1933  if (command == fpCommandScale) {
1936  }
1937  else if (command == fpCommandScaleTo) {
1940  }
1941 
1942  if (verbosity >= G4VisManager::confirmations) {
1943  G4cout << "Scale factor changed to " << vp.GetScaleFactor() << G4endl;
1944  }
1945 
1946  SetViewParameters(currentViewer, vp);
1947 }
1948 
1950 
1952  G4bool omitable;
1953  fpCommand = new G4UIcmdWithAString ("/vis/viewer/select", this);
1954  fpCommand -> SetGuidance ("Selects viewer.");
1955  fpCommand -> SetGuidance
1956  ("Specify viewer by name. \"/vis/viewer/list\" to see possible viewers.");
1957  fpCommand -> SetParameterName ("viewer-name", omitable = false);
1958 }
1959 
1961  delete fpCommand;
1962 }
1963 
1965  return "";
1966 }
1967 
1969 
1971 
1972  G4String& selectName = newValue;
1973  G4VViewer* viewer = fpVisManager -> GetViewer (selectName);
1974 
1975  if (!viewer) {
1976  if (verbosity >= G4VisManager::errors) {
1977  G4cerr << "ERROR: Viewer \"" << selectName << "\"";
1978  G4cerr << " not found - \"/vis/viewer/list\""
1979  "\n to see possibilities."
1980  << G4endl;
1981  }
1982  return;
1983  }
1984 
1985  if (viewer == fpVisManager -> GetCurrentViewer ()) {
1986  if (verbosity >= G4VisManager::warnings) {
1987  G4cout << "WARNING: Viewer \"" << viewer -> GetName () << "\""
1988  << " already selected." << G4endl;
1989  }
1990  return;
1991  }
1992 
1993  // Set pointers, call SetView and print confirmation.
1994  fpVisManager -> SetCurrentViewer (viewer);
1995 
1996  RefreshIfRequired(viewer);
1997 }
1998 
2000 
2002  G4bool omitable, currentAsDefault;
2003  fpCommand = new G4UIcmdWithAString ("/vis/viewer/update", this);
2004  fpCommand -> SetGuidance
2005  ("Triggers graphical database post-processing for viewers"
2006  "\nusing that technique.");
2007  fpCommand -> SetGuidance
2008  ("For such viewers the view only becomes visible with this command."
2009  "\nBy default, acts on current viewer. \"/vis/viewer/list\""
2010  "\nto see possible viewers. Viewer becomes current.");
2011  fpCommand -> SetParameterName ("viewer-name",
2012  omitable = true,
2013  currentAsDefault = true);
2014 }
2015 
2017  delete fpCommand;
2018 }
2019 
2021  G4VViewer* viewer = fpVisManager -> GetCurrentViewer ();
2022  if (viewer) {
2023  return viewer -> GetName ();
2024  }
2025  else {
2026  return "none";
2027  }
2028 }
2029 
2031 
2033 
2034  G4String& updateName = newValue;
2035 
2036  G4VViewer* viewer = fpVisManager -> GetViewer (updateName);
2037  if (!viewer) {
2038  if (verbosity >= G4VisManager::errors) {
2039  G4cout <<
2040  "WARNING: command \"/vis/viewer/update\" could not be applied: no current viewer."
2041  << G4endl;
2042  }
2043  return;
2044  }
2045 
2046  G4VSceneHandler* sceneHandler = viewer->GetSceneHandler();
2047  if (!sceneHandler) {
2048  if (verbosity >= G4VisManager::errors) {
2049  G4cerr << "ERROR: Viewer \"" << updateName << "\"" <<
2050  " has no scene handler - report serious bug."
2051  << G4endl;
2052  }
2053  return;
2054  }
2055 
2056  G4Scene* scene = sceneHandler->GetScene();
2057  if (!scene) {
2058  if (verbosity >= G4VisManager::confirmations) {
2059  G4cout << "NOTE: SceneHandler \"" << sceneHandler->GetName()
2060  << "\", to which viewer \"" << updateName << "\"" <<
2061  "\n is attached, has no scene - \"/vis/scene/create\" and"
2062  " \"/vis/sceneHandler/attach\""
2063  "\n (or use compound command \"/vis/drawVolume\")."
2064  << G4endl;
2065  }
2066  return;
2067  }
2068 
2069  if (verbosity >= G4VisManager::confirmations) {
2070  G4cout << "Viewer \"" << viewer -> GetName () << "\"";
2071  G4cout << " post-processing triggered." << G4endl;
2072  }
2073  viewer -> ShowView ();
2074  // Assume future need to "refresh" transients...
2075  sceneHandler -> SetMarkForClearingTransientStore(true);
2076 }
2077 
2079 
2081  fZoomMultiplier (1.),
2082  fZoomTo (1.)
2083 {
2084  G4bool omitable, currentAsDefault;
2085 
2087  ("/vis/viewer/zoom", this);
2088  fpCommandZoom -> SetGuidance ("Incremental zoom.");
2089  fpCommandZoom -> SetGuidance
2090  ("Multiplies current magnification by this factor.");
2091  fpCommandZoom -> SetParameterName("multiplier",
2092  omitable=true,
2093  currentAsDefault=true);
2094 
2096  ("/vis/viewer/zoomTo", this);
2097  fpCommandZoomTo -> SetGuidance ("Absolute zoom.");
2098  fpCommandZoomTo -> SetGuidance
2099  ("Magnifies standard magnification by this factor.");
2100  fpCommandZoomTo -> SetParameterName("factor",
2101  omitable=true,
2102  currentAsDefault=true);
2103 }
2104 
2106  delete fpCommandZoom;
2107  delete fpCommandZoomTo;
2108 }
2109 
2111  G4String currentValue;
2112  if (command == fpCommandZoom) {
2114  }
2115  else if (command == fpCommandZoomTo) {
2116  currentValue = fpCommandZoomTo->ConvertToString(fZoomTo);
2117  }
2118  return currentValue;
2119 }
2120 
2122  G4String newValue) {
2123 
2124 
2126 
2127  G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
2128  if (!currentViewer) {
2129  if (verbosity >= G4VisManager::errors) {
2130  G4cerr <<
2131  "ERROR: G4VisCommandsViewerZoom::SetNewValue: no current viewer."
2132  << G4endl;
2133  }
2134  return;
2135  }
2136 
2137  G4ViewParameters vp = currentViewer->GetViewParameters();
2138 
2139  if (command == fpCommandZoom) {
2142  }
2143  else if (command == fpCommandZoomTo) {
2145  vp.SetZoomFactor(fZoomTo);
2146  }
2147 
2148  if (verbosity >= G4VisManager::confirmations) {
2149  G4cout << "Zoom factor changed to " << vp.GetZoomFactor() << G4endl;
2150  }
2151 
2152  SetViewParameters(currentViewer, vp);
2153 }
Float_t x
Definition: compare.C:6
const G4String & GetName() const
const std::vector< Model > & GetRunDurationModelList() const
static G4double ValueOf(const char *unitName)
Definition: G4UIcommand.cc:311
void ClearCutawayPlanes()
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValue)
const XML_Char * name
Definition: expat.h:151
G4UIcmdWithAString * fpCommand
void AddCutawayPlane(const G4Plane3D &cutawayPlane)
const G4String & GetNickname() const
virtual void FinishView()
Definition: G4VViewer.cc:101
CLHEP::Hep3Vector G4ThreeVector
G4UIcmdWithAString * fpCommand
G4String GetCurrentValue(G4UIcommand *command)
void SetFieldHalfAngle(G4double fieldHalfAngle)
G4String GetCurrentValue(G4UIcommand *command)
void ResetTransientsDrawnFlags()
void SetNewValue(G4UIcommand *command, G4String newValue)
G4UIcmdWithAString * fpCommand
G4String GetCurrentValue(G4UIcommand *command)
static Verbosity GetVerbosityValue(const G4String &)
static G4String ConvertToString(G4double x, G4double y, const char *unitName)
void SetCBDParameters(const std::vector< G4double > &)
void IncrementDolly(G4double dollyIncrement)
const G4Point3D & GetCurrentTargetPoint() const
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:466
G4String GetCurrentValue(G4UIcommand *command)
#define G4endl
Definition: G4ios.hh:61
Float_t y
Definition: compare.C:6
const char * p
Definition: xmltok.h:285
void SetScaleFactor(const G4Vector3D &scaleFactor)
G4UIcmdWithAString * fpCommand
void SetNewValue(G4UIcommand *command, G4String newValue)
Double_t z
void ChangeCutawayPlane(size_t index, const G4Plane3D &cutawayPlane)
void SetLightsMoveWithCamera(G4bool moves)
static constexpr double millisecond
Definition: G4SIunits.hh:159
void SetViewParameters(G4VViewer *, const G4ViewParameters &)
const G4Vector3D & GetUpVector() const
G4String GetCurrentValue(G4UIcommand *command)
G4String GetCurrentValue(G4UIcommand *command)
void SetViewParameters(const G4ViewParameters &vp)
Definition: G4VViewer.cc:120
virtual void ClearTransientStore()
void SetNewValue(G4UIcommand *command, G4String newValue)
static G4double GetNewDoubleValue(const char *paramString)
const G4ViewParameters & GetViewParameters() const
static G4ViewParameters * CatmullRomCubicSplineInterpolation(const std::vector< G4ViewParameters > &views, G4int nInterpolationPoints=50)
G4String GetCurrentValue(G4UIcommand *command)
virtual void DrawView()=0
G4String CameraAndLightingCommands(const G4Point3D standardTargetPoint) const
G4UIcmdWithAString * fpCommand
void SetGuidance(const char *theGuidance)
void SetVerboseLevel(G4int val)
Definition: G4UImanager.hh:227
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:73
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
void SetLightpointDirection(const G4Vector3D &lightpointDirection)
void SetVerboseLevel(G4int)
G4String GetCurrentValue(G4UIcommand *command)
void UpdateVisManagerScene(const G4String &sceneName="")
const std::vector< G4double > & GetCBDParameters() const
const G4Vector3D & GetScaleFactor() const
virtual void ShowView()
Definition: G4VViewer.cc:103
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:152
G4String GetCurrentValue(G4UIcommand *command)
G4double GetZoomFactor() const
const G4Vector3D & GetLightpointDirection() const
const G4Vector3D & GetViewpointDirection() const
void SetDefaultValue(const char *theDefaultValue)
static G4double GetNewDoubleValue(const char *paramString)
G4bool GetLightsMoveWithCamera() const
G4VSceneHandler * GetSceneHandler() const
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
G4String TimeWindowCommands() const
const G4String & GetXGeometryString() const
G4String TouchableCommands() const
static const G4double d2
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetUpVector(const G4Vector3D &upVector)
const G4String & GetName() const
G4String GetCurrentValue(G4UIcommand *command)
G4int GetCBDAlgorithmNumber() const
void NeedKernelVisit()
Definition: G4VViewer.cc:78
void SetNewValue(G4UIcommand *command, G4String newValue)
G4VViewer * GetCurrentViewer() const
static const G4double d1
void SetPan(G4double right, G4double up)
G4String GetCurrentValue(G4UIcommand *command)
HepGeom::Normal3D< G4double > G4Normal3D
Definition: G4Normal3D.hh:35
void IncrementPan(G4double right, G4double up)
G4UIcmdWithADoubleAndUnit * fpCommandDolly
G4double GetDolly() const
G4String strip(G4int strip_Type=trailing, char c=' ')
static Verbosity GetVerbosity()
virtual void ClearView()=0
G4double GetFieldHalfAngle() const
void SetNewValue(G4UIcommand *command, G4String newValue)
HepGeom::Plane3D< G4double > G4Plane3D
Definition: G4Plane3D.hh:37
const G4String & GetName() const
void SetNewValue(G4UIcommand *command, G4String newValue)
G4bool contains(const std::string &) const
void SetNewValue(G4UIcommand *command, G4String newValue)
G4GLOB_DLL std::ostream G4cerr
G4String GetCurrentValue(G4UIcommand *command)
static G4ThreeVector GetNew3VectorValue(const char *paramString)
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
G4bool IsAutoRefresh() const
void SetCurrentTargetPoint(const G4Point3D &currentTargetPoint)
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:374
void RefreshIfRequired(G4VViewer *)
void RefreshView()
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
const G4Planes & GetCutawayPlanes() const
int G4int
Definition: G4Types.hh:78
G4UIcmdWithAString * fpCommand
void SetNewValue(G4UIcommand *command, G4String newValue)
void MultiplyZoomFactor(G4double zoomFactorMultiplier)
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValue)
G4VGraphicsSystem * GetGraphicsSystem() const
G4bool ProvideValueOfUnit(const G4String &where, const G4String &unit, const G4String &category, G4double &value)
void SetNewValue(G4UIcommand *command, G4String newValue)
G4UIcmdWithADoubleAndUnit * fpCommandDollyTo
G4UIcmdWithAString * fpCommand
G4String GetCurrentValue(G4UIcommand *command)
void SetCBDAlgorithmNumber(G4int)
G4int GetVerboseLevel() const
Definition: G4UImanager.hh:229
G4String GetCurrentValue(G4UIcommand *command)
void AddVisAttributesModifier(const G4ModelingParameters::VisAttributesModifier &)
TFile * file
G4String SceneModifyingCommands() const
G4String GetCurrentValue(G4UIcommand *command)
G4GLOB_DLL std::ostream G4cout
void SetDolly(G4double dolly)
G4UIcmdWithADouble * fpCommandZoom
virtual const std::vector< G4ModelingParameters::VisAttributesModifier > * GetPrivateVisAttributesModifiers() const
virtual void SetView()=0
void ClearVisAttributesModifiers()
G4UIcmdWith3Vector * fpCommandScale
void MultiplyScaleFactor(const G4Vector3D &scaleFactorMultiplier)
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetNewValue(G4UIcommand *command, G4String newValue)
const G4Point3D & GetStandardTargetPoint() const
G4UIcmdWith3Vector * fpCommandScaleTo
static G4double ConvertToDimensionedDouble(const char *st)
Definition: G4UIcommand.cc:465
G4UIcmdWithADouble * fpCommandZoomTo
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetZoomFactor(G4double zoomFactor)
static G4VisManager * fpVisManager
HepGeom::Point3D< G4double > G4Point3D
Definition: G4Point3D.hh:35
G4String GetCurrentValue(G4UIcommand *command)
void SetAutoRefresh(G4bool)
G4String DrawingStyleCommands() const
std::vector< G4Plane3D > G4Planes
G4String GetCurrentValue(G4UIcommand *command)
virtual void ResetView()
void SetViewpointDirection(const G4Vector3D &viewpointDirection)
void SetNewValue(G4UIcommand *command, G4String newValue)
G4Scene * GetScene() const
static G4bool ConvertToDoublePair(const G4String &paramString, G4double &xval, G4double &yval)
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetMarkForClearingTransientStore(G4bool)
G4UIcmdWithAString * fpCommand