Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4VisCommandsCompound.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: G4VisCommandsCompound.cc 110513 2018-05-28 07:37:38Z gcosmo $
28 
29 // Compound /vis/ commands - John Allison 15th May 2000
30 
31 #include "G4VisCommandsCompound.hh"
32 
33 #include "G4VisManager.hh"
34 #include "G4UImanager.hh"
35 #include "G4UIcmdWithAString.hh"
36 
37 #include <sstream>
38 #include <set>
39 
41 
43  G4bool omitable;
44  fpCommand = new G4UIcommand("/vis/drawTree", this);
46  ("Produces a representation of the geometry hierarchy. Further"
47  "\nguidance is given on running the command. Or look at the guidance"
48  "\nfor \"/vis/ASCIITree/verbose\".");
49  fpCommand->SetGuidance("The pre-existing scene and view are preserved.");
50  G4UIparameter* parameter;
51  parameter = new G4UIparameter("physical-volume-name", 's', omitable = true);
52  parameter -> SetDefaultValue("world");
53  fpCommand -> SetParameter (parameter);
54  parameter = new G4UIparameter("system", 's', omitable = true);
55  parameter -> SetDefaultValue("ATree");
56  fpCommand -> SetParameter (parameter);
57 }
58 
60  delete fpCommand;
61 }
62 
64 
65  G4String pvname, system;
66  std::istringstream is(newValue);
67  is >> pvname >> system;
68 
69  // Note: The second parameter, "system", is intended to allow the user
70  // a choice of dedicated tree printing/displaying systems but at present
71  // the only such dedicated system is ASCIITree. It doesn't make sense to
72  // specify OGLSX, for example. So to avoid confusion we restrict this
73  // feature to systems that have "Tree" in the name or nickname.
74 
75  // Of course, some other systems, such as OGLSQt, have a tree browser
76  // built-in. The HepRApp offline browser also has a tree browser
77  // built in.
78 
79  if (!system.contains("Tree")) {
80  system = "ATree";
81  }
82 
84  G4Scene* keepScene = fpVisManager->GetCurrentScene();
86  G4VViewer* keepViewer = fpVisManager->GetCurrentViewer();
87 
89  G4int keepVerbose = UImanager->GetVerboseLevel();
90  G4int newVerbose(0);
91  if (keepVerbose >= 2 ||
93  newVerbose = 2;
94  UImanager->SetVerboseLevel(newVerbose);
95  UImanager->ApplyCommand(G4String("/vis/open " + system));
96  if (fErrorCode == 0) {
97  UImanager->ApplyCommand(G4String("/vis/drawVolume " + pvname));
98  UImanager->ApplyCommand("/vis/viewer/flush");
99  if (keepViewer) {
101  G4cout << "Reverting to " << keepViewer->GetName() << G4endl;
102  }
104  fpVisManager->SetCurrentScene(keepScene);
105  fpVisManager->SetCurrentSceneHandler(keepSceneHandler);
106  fpVisManager->SetCurrentViewer(keepViewer);
107  }
108  }
109  UImanager->SetVerboseLevel(keepVerbose);
110 }
111 
113 
115  G4bool omitable;
116  fpCommand = new G4UIcommand("/vis/drawView", this);
118  ("Draw view from this angle, etc.");
119  G4UIparameter* parameter;
120  parameter = new G4UIparameter("theta-degrees", 'd', omitable = true);
121  parameter -> SetDefaultValue(0.);
122  fpCommand -> SetParameter (parameter);
123  parameter = new G4UIparameter("phi-degrees", 'd', omitable = true);
124  parameter -> SetDefaultValue(0.);
125  fpCommand -> SetParameter (parameter);
126  parameter = new G4UIparameter("pan-right", 'd', omitable = true);
127  parameter -> SetDefaultValue(0.);
128  fpCommand -> SetParameter (parameter);
129  parameter = new G4UIparameter("pan-up", 'd', omitable = true);
130  parameter -> SetDefaultValue(0.);
131  fpCommand -> SetParameter (parameter);
132  parameter = new G4UIparameter("pan-unit", 's', omitable = true);
133  parameter -> SetDefaultValue("cm");
134  fpCommand -> SetParameter (parameter);
135  parameter = new G4UIparameter("zoom-factor", 'd', omitable = true);
136  parameter -> SetDefaultValue(1.);
137  fpCommand -> SetParameter (parameter);
138  parameter = new G4UIparameter("dolly", 'd', omitable = true);
139  parameter -> SetDefaultValue(0.);
140  fpCommand -> SetParameter (parameter);
141  parameter = new G4UIparameter("dolly-unit", 's', omitable = true);
142  parameter -> SetDefaultValue("cm");
143  fpCommand -> SetParameter (parameter);
144 }
145 
147  delete fpCommand;
148 }
149 
151 
153 
154  G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
155  if (!currentViewer) {
156  if (verbosity >= G4VisManager::warnings) {
157  G4cout <<
158  "WARNING: G4VisCommandsDrawView::SetNewValue: no current viewer."
159  << G4endl;
160  }
161  return;
162  }
163 
164  G4String thetaDeg;
165  G4String phiDeg;
166  G4String panRight;
167  G4String panUp;
168  G4String panUnit;
169  G4String zoomFactor;
170  G4String dolly;
171  G4String dollyUnit;
172  std::istringstream is(newValue);
173  is >> thetaDeg >> phiDeg >> panRight >> panUp >> panUnit
174  >> zoomFactor >> dolly >> dollyUnit;
175 
176  G4UImanager* UImanager = G4UImanager::GetUIpointer();
177  G4int keepVerbose = UImanager->GetVerboseLevel();
178  G4int newVerbose(0);
179  if (keepVerbose >= 2 ||
181  newVerbose = 2;
182  UImanager->SetVerboseLevel(newVerbose);
183  G4ViewParameters vp = currentViewer->GetViewParameters();
184  G4bool keepAutoRefresh = vp.IsAutoRefresh();
185  vp.SetAutoRefresh(false);
186  currentViewer->SetViewParameters(vp);
187  UImanager->ApplyCommand(
188  G4String("/vis/viewer/set/viewpointThetaPhi " + thetaDeg + " " + phiDeg + " deg"));
189  UImanager->ApplyCommand(
190  G4String("/vis/viewer/panTo " + panRight + " " + panUp + " " + panUnit));
191  UImanager->ApplyCommand(
192  G4String("/vis/viewer/zoomTo " + zoomFactor));
193  vp = currentViewer->GetViewParameters();
194  vp.SetAutoRefresh(keepAutoRefresh);
195  currentViewer->SetViewParameters(vp);
196  UImanager->ApplyCommand(
197  G4String("/vis/viewer/dollyTo " + dolly + " " + dollyUnit));
198  UImanager->SetVerboseLevel(keepVerbose);
199 }
200 
202 
204  G4bool omitable;
205  fpCommand = new G4UIcommand("/vis/drawLogicalVolume", this);
207  ("Draws logical volume with Boolean components, voxels and readout geometry.");
209  ("Synonymous with \"/vis/specify\".");
211  ("Creates a scene consisting of this logical volume and asks the"
212  "\n current viewer to draw it to the specified depth of descent"
213  "\n showing boolean components (if any), voxels (if any),"
214  "\n readout geometry (if any), local axes and overlaps (if any),"
215  "\n under control of the appropriate flag.");
217  ("Note: voxels are not constructed until start of run - /run/beamOn."
218  "\n (For voxels without a run, \"/run/beamOn 0\".)");
219  fpCommand->SetGuidance("The scene becomes current.");
220  G4UIparameter* parameter;
221  parameter = new G4UIparameter("logical-volume-name", 's', omitable = false);
222  fpCommand->SetParameter(parameter);
223  parameter = new G4UIparameter("depth-of-descent", 'i', omitable = true);
224  parameter->SetDefaultValue(1);
225  fpCommand->SetParameter(parameter);
226  parameter = new G4UIparameter("booleans-flag", 'b', omitable = true);
227  parameter->SetDefaultValue(true);
228  fpCommand->SetParameter(parameter);
229  parameter = new G4UIparameter("voxels-flag", 'b', omitable = true);
230  parameter->SetDefaultValue(true);
231  fpCommand->SetParameter(parameter);
232  parameter = new G4UIparameter("readout-flag", 'b', omitable = true);
233  parameter->SetDefaultValue(true);
234  fpCommand->SetParameter(parameter);
235  parameter = new G4UIparameter("axes-flag", 'b', omitable = true);
236  parameter->SetDefaultValue(true);
237  parameter -> SetGuidance ("Set \"false\" to suppress axes.");
238  fpCommand->SetParameter(parameter);
239  parameter = new G4UIparameter("check-overlap-flag", 'b', omitable = true);
240  parameter->SetDefaultValue(true);
241  parameter -> SetGuidance ("Set \"false\" to suppress overlap check.");
242  fpCommand->SetParameter(parameter);
243 }
244 
246  delete fpCommand;
247 }
248 
251  G4UImanager* UImanager = G4UImanager::GetUIpointer();
252  G4int keepVerbose = UImanager->GetVerboseLevel();
253  G4int newVerbose(0);
254  if (keepVerbose >= 2 || verbosity >= G4VisManager::confirmations)
255  newVerbose = 2;
256  UImanager->SetVerboseLevel(newVerbose);
257  // UImanager->ApplyCommand(G4String("/geometry/print " + newValue));
258  UImanager->ApplyCommand("/vis/scene/create");
259  UImanager->ApplyCommand(G4String("/vis/scene/add/logicalVolume " + newValue));
260  UImanager->ApplyCommand("/vis/sceneHandler/attach");
261  UImanager->SetVerboseLevel(keepVerbose);
262  static G4bool warned = false;
263  if (verbosity >= G4VisManager::confirmations && !warned) {
264  G4cout <<
265  "NOTE: For systems which are not \"auto-refresh\" you will need to"
266  "\n issue \"/vis/viewer/refresh\" or \"/vis/viewer/flush\"."
267  << G4endl;
268  warned = true;
269  }
270 }
271 
273 
275  G4bool omitable;
276  fpCommand = new G4UIcmdWithAString("/vis/drawVolume", this);
278  ("Creates a scene containing this physical volume and asks the"
279  "\ncurrent viewer to draw it. The scene becomes current.");
280  fpCommand -> SetGuidance
281  ("If physical-volume-name is \"world\" (the default), the main geometry"
282  "\ntree (material world) is drawn. If \"worlds\", all worlds - material"
283  "\nworld and parallel worlds, if any - are drawn. Otherwise a search of"
284  "\nall worlds is made, taking the first matching occurence only. To see"
285  "\na representation of the geometry hierarchy of the worlds, try"
286  "\n\"/vis/drawTree worlds\" or one of the driver/browser combinations"
287  "\nthat have the required functionality, e.g., HepRepFile/HepRApp.");
288  fpCommand->SetParameterName("physical-volume-name", omitable = true);
289  fpCommand->SetDefaultValue("world");
290 }
291 
293  delete fpCommand;
294 }
295 
298  G4UImanager* UImanager = G4UImanager::GetUIpointer();
299  G4int keepVerbose = UImanager->GetVerboseLevel();
300  G4int newVerbose(0);
301  if (keepVerbose >= 2 || verbosity >= G4VisManager::confirmations)
302  newVerbose = 2;
303  UImanager->SetVerboseLevel(newVerbose);
304  UImanager->ApplyCommand("/vis/scene/create");
305  UImanager->ApplyCommand(G4String("/vis/scene/add/volume " + newValue));
306  UImanager->ApplyCommand("/vis/sceneHandler/attach");
307  UImanager->SetVerboseLevel(keepVerbose);
308  static G4bool warned = false;
309  if (verbosity >= G4VisManager::confirmations && !warned) {
310  G4cout <<
311  "NOTE: For systems which are not \"auto-refresh\" you will need to"
312  "\n issue \"/vis/viewer/refresh\" or \"/vis/viewer/flush\"."
313  << G4endl;
314  warned = true;
315  }
316 }
317 
319 
321  G4bool omitable;
322  fpCommand = new G4UIcommand("/vis/open", this);
324  ("Creates a scene handler ready for drawing.");
326  ("The scene handler becomes current (the name is auto-generated).");
327  G4UIparameter* parameter;
328  parameter = new G4UIparameter("graphics-system-name", 's', omitable = false);
329  fpCommand->SetParameter(parameter);
330  parameter = new G4UIparameter("window-size-hint", 's', omitable = true);
331  parameter->SetGuidance
332  ("integer (pixels) for square window placed by window manager or"
333  " X-Windows-type geometry string, e.g. 600x600-100+100");
334  parameter->SetDefaultValue("600");
335  fpCommand->SetParameter(parameter);
336 }
337 
339  delete fpCommand;
340 }
341 
343  G4String systemName, windowSizeHint;
344  std::istringstream is(newValue);
345  is >> systemName >> windowSizeHint;
346  G4UImanager* UImanager = G4UImanager::GetUIpointer();
347  G4int keepVerbose = UImanager->GetVerboseLevel();
348  G4int newVerbose(0);
349  if (keepVerbose >= 2 ||
351  newVerbose = 2;
352  UImanager->SetVerboseLevel(newVerbose);
353  fErrorCode = UImanager->ApplyCommand(G4String("/vis/sceneHandler/create " + systemName));
354  if (fErrorCode == 0) {
355  UImanager->ApplyCommand(G4String("/vis/viewer/create ! ! " + windowSizeHint));
356  } else {
357  // Use set to get alphabetical order
358  std::set<G4String> candidates;
359  for (const auto gs: fpVisManager -> GetAvailableGraphicsSystems()) {
360  // Just list nicknames, but exclude FALLBACK nicknames
361  for (const auto& nickname: gs->GetNicknames()) {
362  if (!nickname.contains("FALLBACK")) {
363  candidates.insert(nickname);
364  }
365  }
366  }
367  G4cerr << "Candidates are:";
368  for (const auto& candidate: candidates) {
369  G4cerr << ' ' << candidate;
370  }
371  G4cerr << G4endl;
372  }
373  UImanager->SetVerboseLevel(keepVerbose);
374 }
375 
377 
379  G4bool omitable;
380  fpCommand = new G4UIcommand("/vis/specify", this);
382  ("Draws logical volume with Boolean components, voxels and readout geometry.");
384  ("Synonymous with \"/vis/drawLogicalVolume\".");
386  ("Creates a scene consisting of this logical volume and asks the"
387  "\n current viewer to draw it to the specified depth of descent"
388  "\n showing boolean components (if any), voxels (if any),"
389  "\n readout geometry (if any), local axes and overlaps (if any),"
390  "\n under control of the appropriate flag.");
392  ("Note: voxels are not constructed until start of run - /run/beamOn."
393  "\n (For voxels without a run, \"/run/beamOn 0\".)");
394  fpCommand->SetGuidance("The scene becomes current.");
395  G4UIparameter* parameter;
396  parameter = new G4UIparameter("logical-volume-name", 's', omitable = false);
397  fpCommand->SetParameter(parameter);
398  parameter = new G4UIparameter("depth-of-descent", 'i', omitable = true);
399  parameter->SetDefaultValue(1);
400  fpCommand->SetParameter(parameter);
401  parameter = new G4UIparameter("booleans-flag", 'b', omitable = true);
402  parameter->SetDefaultValue(true);
403  fpCommand->SetParameter(parameter);
404  parameter = new G4UIparameter("voxels-flag", 'b', omitable = true);
405  parameter->SetDefaultValue(true);
406  fpCommand->SetParameter(parameter);
407  parameter = new G4UIparameter("readout-flag", 'b', omitable = true);
408  parameter->SetDefaultValue(true);
409  fpCommand->SetParameter(parameter);
410  parameter = new G4UIparameter("axes-flag", 'b', omitable = true);
411  parameter->SetDefaultValue(true);
412  parameter -> SetGuidance ("Set \"false\" to suppress axes.");
413  fpCommand->SetParameter(parameter);
414  parameter = new G4UIparameter("check-overlap-flag", 'b', omitable = true);
415  parameter->SetDefaultValue(true);
416  parameter -> SetGuidance ("Set \"false\" to suppress overlap check.");
417  fpCommand->SetParameter(parameter);
418 }
419 
421  delete fpCommand;
422 }
423 
426  G4UImanager* UImanager = G4UImanager::GetUIpointer();
427  G4int keepVerbose = UImanager->GetVerboseLevel();
428  G4int newVerbose(0);
429  if (keepVerbose >= 2 || verbosity >= G4VisManager::confirmations)
430  newVerbose = 2;
431  UImanager->SetVerboseLevel(newVerbose);
432  // UImanager->ApplyCommand(G4String("/geometry/print " + newValue));
433  UImanager->ApplyCommand("/vis/scene/create");
434  UImanager->ApplyCommand(G4String("/vis/scene/add/logicalVolume " + newValue));
435  UImanager->ApplyCommand("/vis/sceneHandler/attach");
436  UImanager->SetVerboseLevel(keepVerbose);
437  static G4bool warned = false;
438  if (verbosity >= G4VisManager::confirmations && !warned) {
439  G4cout <<
440  "NOTE: For systems which are not \"auto-refresh\" you will need to"
441  "\n issue \"/vis/viewer/refresh\" or \"/vis/viewer/flush\"."
442  << G4endl;
443  warned = true;
444  }
445 }
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
system("rm -rf microbeam.root")
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:466
#define G4endl
Definition: G4ios.hh:61
void SetViewParameters(const G4ViewParameters &vp)
Definition: G4VViewer.cc:120
const G4ViewParameters & GetViewParameters() const
void SetDefaultValue(const char *defVal)
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetGuidance(const char *theGuidance)
void SetVerboseLevel(G4int val)
Definition: G4UImanager.hh:227
G4Scene * GetCurrentScene() const
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:73
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:152
static G4int fErrorCode
void SetDefaultValue(const char *theDefaultValue)
bool G4bool
Definition: G4Types.hh:79
void SetCurrentViewer(G4VViewer *)
G4VViewer * GetCurrentViewer() const
static Verbosity GetVerbosity()
G4UIcmdWithAString * fpCommand
const G4String & GetName() const
void SetNewValue(G4UIcommand *command, G4String newValue)
G4GLOB_DLL std::ostream G4cerr
G4bool IsAutoRefresh() const
void SetCurrentGraphicsSystem(G4VGraphicsSystem *)
void SetCurrentSceneHandler(G4VSceneHandler *)
void SetNewValue(G4UIcommand *command, G4String newValue)
int G4int
Definition: G4Types.hh:78
void SetCurrentScene(G4Scene *)
G4int GetVerboseLevel() const
Definition: G4UImanager.hh:229
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetNewValue(G4UIcommand *command, G4String newValue)
G4GLOB_DLL std::ostream G4cout
G4VSceneHandler * GetCurrentSceneHandler() const
static G4VisManager * fpVisManager
void SetAutoRefresh(G4bool)
G4VGraphicsSystem * GetCurrentGraphicsSystem() const