source: trunk/geant4/visualization/management/src/G4VisCommandsCompound.cc@ 594

Last change on this file since 594 was 593, checked in by garnier, 18 years ago

r627@mac-90108: laurentgarnier | 2007-11-09 07:57:42 +0100
modif dans les includes directives

  • Property svn:mime-type set to text/cpp
File size: 13.1 KB
RevLine 
[531]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//
[593]27// $Id: G4VisCommandsCompound.cc,v 1.38 2007/03/27 15:41:34 allison Exp $
28// GEANT4 tag $Name: geant4-09-00-ref-01 $
[531]29
30// Compound /vis/ commands - John Allison 15th May 2000
31
32#include "G4VisCommandsCompound.hh"
33
34#include "G4VisManager.hh"
35#include "G4UImanager.hh"
36#include "G4UIcmdWithAString.hh"
37
38#include <sstream>
39
40////////////// /vis/drawTree ///////////////////////////////////////
41
42G4VisCommandDrawTree::G4VisCommandDrawTree() {
43 G4bool omitable;
44 fpCommand = new G4UIcommand("/vis/drawTree", this);
45 fpCommand->SetGuidance
46 ("(DTREE) Creates a scene consisting of this physical volume and"
47 "\n produces a representation of the geometry hieracrhy.");
48 fpCommand->SetGuidance("The scene becomes current.");
49 G4UIparameter* parameter;
50 parameter = new G4UIparameter("physical-volume-name", 's', omitable = true);
51 parameter -> SetDefaultValue("world");
52 fpCommand -> SetParameter (parameter);
53 parameter = new G4UIparameter("system", 's', omitable = true);
54 parameter -> SetDefaultValue("ATree");
55 fpCommand -> SetParameter (parameter);
56}
57
58G4VisCommandDrawTree::~G4VisCommandDrawTree() {
59 delete fpCommand;
60}
61
62void G4VisCommandDrawTree::SetNewValue(G4UIcommand*, G4String newValue) {
63
64 G4String pvname, system;
65 std::istringstream is(newValue);
66 is >> pvname >> system;
67
68 G4UImanager* UImanager = G4UImanager::GetUIpointer();
69 G4int keepVerbose = UImanager->GetVerboseLevel();
70 G4int newVerbose(0);
71 if (keepVerbose >= 2 ||
72 fpVisManager->GetVerbosity() >= G4VisManager::confirmations)
73 newVerbose = 2;
74 UImanager->SetVerboseLevel(newVerbose);
75 UImanager->ApplyCommand(G4String("/vis/open " + system));
76 UImanager->ApplyCommand(G4String("/vis/drawVolume " + pvname));
77 UImanager->ApplyCommand("/vis/viewer/flush");
78 UImanager->SetVerboseLevel(keepVerbose);
79}
80
81////////////// /vis/drawView ///////////////////////////////////////
82
83G4VisCommandDrawView::G4VisCommandDrawView() {
84 G4bool omitable;
85 fpCommand = new G4UIcommand("/vis/drawView", this);
86 fpCommand->SetGuidance
87 ("Draw view from this angle, etc.");
88 G4UIparameter* parameter;
89 parameter = new G4UIparameter("theta-degrees", 'd', omitable = true);
90 parameter -> SetDefaultValue(0.);
91 fpCommand -> SetParameter (parameter);
92 parameter = new G4UIparameter("phi-degrees", 'd', omitable = true);
93 parameter -> SetDefaultValue(0.);
94 fpCommand -> SetParameter (parameter);
95 parameter = new G4UIparameter("pan-right", 'd', omitable = true);
96 parameter -> SetDefaultValue(0.);
97 fpCommand -> SetParameter (parameter);
98 parameter = new G4UIparameter("pan-up", 'd', omitable = true);
99 parameter -> SetDefaultValue(0.);
100 fpCommand -> SetParameter (parameter);
101 parameter = new G4UIparameter("pan-unit", 's', omitable = true);
102 parameter -> SetDefaultValue("cm");
103 fpCommand -> SetParameter (parameter);
104 parameter = new G4UIparameter("zoom-factor", 'd', omitable = true);
105 parameter -> SetDefaultValue(1.);
106 fpCommand -> SetParameter (parameter);
107 parameter = new G4UIparameter("dolly", 'd', omitable = true);
108 parameter -> SetDefaultValue(0.);
109 fpCommand -> SetParameter (parameter);
110 parameter = new G4UIparameter("dolly-unit", 's', omitable = true);
111 parameter -> SetDefaultValue("cm");
112 fpCommand -> SetParameter (parameter);
113}
114
115G4VisCommandDrawView::~G4VisCommandDrawView() {
116 delete fpCommand;
117}
118
119void G4VisCommandDrawView::SetNewValue(G4UIcommand*, G4String newValue) {
120
121 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
122
123 G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
124 if (!currentViewer) {
125 if (verbosity >= G4VisManager::warnings) {
126 G4cout <<
127 "WARNING: G4VisCommandsDrawView::SetNewValue: no current viewer."
128 << G4endl;
129 }
130 return;
131 }
132
133 G4String thetaDeg;
134 G4String phiDeg;
135 G4String panRight;
136 G4String panUp;
137 G4String panUnit;
138 G4String zoomFactor;
139 G4String dolly;
140 G4String dollyUnit;
141 std::istringstream is(newValue);
142 is >> thetaDeg >> phiDeg >> panRight >> panUp >> panUnit
143 >> zoomFactor >> dolly >> dollyUnit;
144
145 G4UImanager* UImanager = G4UImanager::GetUIpointer();
146 G4int keepVerbose = UImanager->GetVerboseLevel();
147 G4int newVerbose(0);
148 if (keepVerbose >= 2 ||
149 fpVisManager->GetVerbosity() >= G4VisManager::confirmations)
150 newVerbose = 2;
151 UImanager->SetVerboseLevel(newVerbose);
152 G4ViewParameters vp = currentViewer->GetViewParameters();
153 G4bool keepAutoRefresh = vp.IsAutoRefresh();
154 vp.SetAutoRefresh(false);
155 currentViewer->SetViewParameters(vp);
156 UImanager->ApplyCommand(
157 G4String("/vis/viewer/set/viewpointThetaPhi " + thetaDeg + " " + phiDeg + " deg"));
158 UImanager->ApplyCommand(
159 G4String("/vis/viewer/panTo " + panRight + " " + panUp + " " + panUnit));
160 UImanager->ApplyCommand(
161 G4String("/vis/viewer/zoomTo " + zoomFactor));
162 vp = currentViewer->GetViewParameters();
163 vp.SetAutoRefresh(keepAutoRefresh);
164 currentViewer->SetViewParameters(vp);
165 UImanager->ApplyCommand(
166 G4String("/vis/viewer/dollyTo " + dolly + " " + dollyUnit));
167 UImanager->SetVerboseLevel(keepVerbose);
168}
169
170////////////// /vis/drawVolume ///////////////////////////////////////
171
172G4VisCommandDrawVolume::G4VisCommandDrawVolume() {
173 G4bool omitable;
174 fpCommand = new G4UIcmdWithAString("/vis/drawVolume", this);
175 fpCommand->SetGuidance
176 ("Creates a scene containing this physical volume and asks the"
177 "\ncurrent viewer to draw it. The scene becomes current.");
178 fpCommand -> SetGuidance
179 ("If physical-volume-name is \"world\" (the default), the main geometry"
180 "\ntree (material world) is drawn. If \"worlds\", all worlds - material"
181 "\nworld and parallel worlds, if any - are drawn. Otherwise a search of"
182 "\nall worlds is made, taking the first matching occurence only. To see"
183 "\na representation of the geometry hierarchy of the worlds, try"
184 "\n\"/vis/drawTree [worlds]\" or one of the driver/browser combinations"
185 "\nthat have the required functionality, e.g., HepRepFile/XML with the"
186 "\nWIRED3/4 browser.");
187 fpCommand->SetParameterName("physical-volume-name", omitable = true);
188 fpCommand->SetDefaultValue("world");
189}
190
191G4VisCommandDrawVolume::~G4VisCommandDrawVolume() {
192 delete fpCommand;
193}
194
195void G4VisCommandDrawVolume::SetNewValue(G4UIcommand*, G4String newValue) {
196 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
197 G4UImanager* UImanager = G4UImanager::GetUIpointer();
198 G4int keepVerbose = UImanager->GetVerboseLevel();
199 G4int newVerbose(0);
200 if (keepVerbose >= 2 || verbosity >= G4VisManager::confirmations)
201 newVerbose = 2;
202 UImanager->SetVerboseLevel(newVerbose);
203 UImanager->ApplyCommand("/vis/scene/create");
204 UImanager->ApplyCommand(G4String("/vis/scene/add/volume " + newValue));
205 UImanager->ApplyCommand("/vis/sceneHandler/attach");
206 UImanager->SetVerboseLevel(keepVerbose);
207 static G4bool warned = false;
[593]208 if (verbosity >= G4VisManager::confirmations && !warned) {
[531]209 G4cout <<
[593]210 "NOTE: For systems which are not \"auto-refresh\" you will need to"
[531]211 "\n issue \"/vis/viewer/refresh\" or \"/vis/viewer/flush\"."
212 << G4endl;
213 warned = true;
214 }
215}
216
217////////////// /vis/open ///////////////////////////////////////
218
219G4VisCommandOpen::G4VisCommandOpen() {
220 G4bool omitable;
221 fpCommand = new G4UIcommand("/vis/open", this);
222 fpCommand->SetGuidance
223 ("Creates a scene handler ready for drawing.");
224 fpCommand->SetGuidance
225 ("The scene handler becomes current (the name is auto-generated).");
226 G4UIparameter* parameter;
227 parameter = new G4UIparameter("graphics-system-name", 's', omitable = false);
228 const G4GraphicsSystemList& gslist =
229 fpVisManager->GetAvailableGraphicsSystems();
230 G4String candidates;
231 for (size_t igslist = 0; igslist < gslist.size(); igslist++) {
232 const G4String& name = gslist[igslist]->GetName();
233 const G4String& nickname = gslist[igslist]->GetNickname();
234 if (nickname.isNull()) {
235 candidates += name;
236 }
237 else {
238 candidates += nickname;
239 }
240 candidates += " ";
241 }
242 candidates = candidates.strip();
243 parameter->SetParameterCandidates(candidates);
244 fpCommand->SetParameter(parameter);
245 parameter = new G4UIparameter("window-size-hint", 's', omitable = true);
246 parameter->SetGuidance
247 ("integer (pixels) for square window placed by window manager or"
248 " X-Windows-type geometry string, e.g. 600x600-100+100");
249 parameter->SetDefaultValue("600");
250 fpCommand->SetParameter(parameter);
251}
252
253G4VisCommandOpen::~G4VisCommandOpen() {
254 delete fpCommand;
255}
256
257void G4VisCommandOpen::SetNewValue (G4UIcommand*, G4String newValue) {
258 G4String systemName, windowSizeHint;
259 std::istringstream is(newValue);
260 is >> systemName >> windowSizeHint;
261 G4UImanager* UImanager = G4UImanager::GetUIpointer();
262 G4int keepVerbose = UImanager->GetVerboseLevel();
263 G4int newVerbose(0);
264 if (keepVerbose >= 2 ||
265 fpVisManager->GetVerbosity() >= G4VisManager::confirmations)
266 newVerbose = 2;
267 UImanager->SetVerboseLevel(newVerbose);
268 UImanager->ApplyCommand(G4String("/vis/sceneHandler/create " + systemName));
269 UImanager->ApplyCommand(G4String("/vis/viewer/create ! ! " + windowSizeHint));
270 UImanager->SetVerboseLevel(keepVerbose);
271}
272
273////////////// /vis/specify ///////////////////////////////////////
274
275G4VisCommandSpecify::G4VisCommandSpecify() {
276 G4bool omitable;
277 fpCommand = new G4UIcommand("/vis/specify", this);
278 fpCommand->SetGuidance
279 ("Draws logical volume with Boolean components, voxels and readout geometry.");
280 fpCommand->SetGuidance
281 ("Creates a scene consisting of this logical volume and asks the"
282 "\n current viewer to draw it to the specified depth of descent"
283 "\n showing boolean components (if any), voxels (if any)"
284 "\n and readout geometry (if any), under control of the appropriate flag.");
285 fpCommand->SetGuidance
286 ("Note: voxels are not constructed until start of run - /run/beamOn.");
287 fpCommand->SetGuidance("The scene becomes current.");
288 G4UIparameter* parameter;
289 parameter = new G4UIparameter("logical-volume-name", 's', omitable = false);
290 fpCommand->SetParameter(parameter);
291 parameter = new G4UIparameter("depth-of-descent", 'i', omitable = true);
292 parameter->SetDefaultValue(1);
293 fpCommand->SetParameter(parameter);
294 parameter = new G4UIparameter("booleans-flag", 'b', omitable = true);
295 parameter->SetDefaultValue(true);
296 fpCommand->SetParameter(parameter);
297 parameter = new G4UIparameter("voxels-flag", 'b', omitable = true);
298 parameter->SetDefaultValue(true);
299 fpCommand->SetParameter(parameter);
300 parameter = new G4UIparameter("readout-flag", 'b', omitable = true);
301 parameter->SetDefaultValue(true);
302 fpCommand->SetParameter(parameter);
303}
304
305G4VisCommandSpecify::~G4VisCommandSpecify() {
306 delete fpCommand;
307}
308
309void G4VisCommandSpecify::SetNewValue(G4UIcommand*, G4String newValue) {
310 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
311 G4UImanager* UImanager = G4UImanager::GetUIpointer();
312 G4int keepVerbose = UImanager->GetVerboseLevel();
313 G4int newVerbose(0);
314 if (keepVerbose >= 2 || verbosity >= G4VisManager::confirmations)
315 newVerbose = 2;
316 UImanager->SetVerboseLevel(newVerbose);
317 // UImanager->ApplyCommand(G4String("/geometry/print " + newValue));
318 UImanager->ApplyCommand("/vis/scene/create");
319 UImanager->ApplyCommand(G4String("/vis/scene/add/logicalVolume " + newValue));
320 UImanager->ApplyCommand("/vis/sceneHandler/attach");
321 UImanager->SetVerboseLevel(keepVerbose);
322 static G4bool warned = false;
[593]323 if (verbosity >= G4VisManager::confirmations && !warned) {
[531]324 G4cout <<
[593]325 "NOTE: For systems which are not \"auto-refresh\" you will need to"
[531]326 "\n issue \"/vis/viewer/refresh\" or \"/vis/viewer/flush\"."
327 << G4endl;
328 warned = true;
329 }
330}
Note: See TracBrowser for help on using the repository browser.