Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4VisCommandsSet.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: G4VisCommands.cc,v 1.24 2009-03-09 12:42:00 allison Exp $
28 
29 // /vis/set - John Allison 21st March 2012
30 // Set quantities for use in appropriate future commands.
31 
32 #include "G4VisCommandsSet.hh"
33 
34 #include "G4UIcommand.hh"
35 #include "G4UIcmdWithAnInteger.hh"
36 #include "G4UIcmdWithADouble.hh"
37 #include "G4UIcmdWithAString.hh"
38 #include <sstream>
39 
41 
43 {
44  G4bool omitable;
45  fpCommand = new G4UIcmdWithAnInteger("/vis/set/arrow3DLineSegmentsPerCircle", this);
47  ("Defines number of line segments per circle for drawing 3D arrows"
48  " for future \"/vis/scene/add/\" commands.");
49  fpCommand->SetParameterName ("number", omitable = true);
51  fpCommand->SetRange("number >= 3");
52 }
53 
55 {
56  delete fpCommand;
57 }
58 
60 {
61  return G4String();
62 }
63 
65 {
67 
69 
70  if (verbosity >= G4VisManager::confirmations) {
71  G4cout <<
72  "Number of line segments per circle for drawing 3D arrows for future"
73  "\n \"/vis/scene/add/\" commands has been set to "
75  << G4endl;
76  }
77 }
78 
80 
82 {
83  G4bool omitable;
84  fpCommand = new G4UIcommand("/vis/set/colour", this);
86  ("Defines colour and opacity for future \"/vis/scene/add/\" commands.");
88  ("(Except \"/vis/scene/add/text\" commands - see \"/vis/set/textColour\".)");
90  fpCommand->SetGuidance("Default: white and opaque.");
91  G4UIparameter* parameter;
92  parameter = new G4UIparameter ("red", 's', omitable = true);
93  parameter->SetGuidance
94  ("Red component or a string, e.g., \"cyan\" (green and blue parameters are ignored).");
95  parameter->SetDefaultValue ("1.");
96  fpCommand->SetParameter (parameter);
97  parameter = new G4UIparameter ("green", 'd', omitable = true);
98  parameter->SetDefaultValue (1.);
99  fpCommand->SetParameter (parameter);
100  parameter = new G4UIparameter ("blue", 'd', omitable = true);
101  parameter->SetDefaultValue (1.);
102  fpCommand->SetParameter (parameter);
103  parameter = new G4UIparameter ("alpha", 'd', omitable = true);
104  parameter->SetDefaultValue (1.);
105  parameter->SetGuidance ("Opacity");
106  fpCommand->SetParameter (parameter);
107 }
108 
110 {
111  delete fpCommand;
112 }
113 
115 {
116  return G4String();
117 }
118 
120 {
122 
123  G4String redOrString;
124  G4double green, blue, opacity;
125  std::istringstream iss(newValue);
126  iss >> redOrString >> green >> blue >> opacity;
127 
128  ConvertToColour(fCurrentColour, redOrString, green, blue, opacity);
129 
130  if (verbosity >= G4VisManager::confirmations) {
131  G4cout <<
132  "Colour for future \"/vis/scene/add/\" commands has been set to "
133  << fCurrentColour <<
134  ".\n(Except \"/vis/scene/add/text\" commands - use \"/vis/set/textColour\".)"
135  << G4endl;
136  }
137 }
138 
140 
142 {
143  G4bool omitable;
144  fpCommand = new G4UIcmdWithADouble("/vis/set/lineWidth", this);
146  ("Defines line width for future \"/vis/scene/add/\" commands.");
147  fpCommand->SetParameterName ("lineWidth", omitable = true);
149  fpCommand->SetRange("lineWidth >= 1.");
150 }
151 
153 {
154  delete fpCommand;
155 }
156 
158 {
159  return G4String();
160 }
161 
163 {
165 
167 
168  if (verbosity >= G4VisManager::confirmations) {
169  G4cout <<
170  "Line width for future \"/vis/scene/add/\" commands has been set to "
172  << G4endl;
173  }
174 }
175 
177 
179 {
180  G4bool omitable;
181  fpCommand = new G4UIcommand("/vis/set/textColour", this);
183  ("Defines colour and opacity for future \"/vis/scene/add/text\" commands.");
185  fpCommand->SetGuidance("Default: blue and opaque.");
186  G4UIparameter* parameter;
187  parameter = new G4UIparameter ("red", 's', omitable = true);
188  parameter->SetGuidance
189  ("Red component or a string, e.g., \"cyan\" (green and blue parameters are ignored).");
190  parameter->SetDefaultValue ("0.");
191  fpCommand->SetParameter (parameter);
192  parameter = new G4UIparameter ("green", 'd', omitable = true);
193  parameter->SetDefaultValue (0.);
194  fpCommand->SetParameter (parameter);
195  parameter = new G4UIparameter ("blue", 'd', omitable = true);
196  parameter->SetDefaultValue (1.);
197  fpCommand->SetParameter (parameter);
198  parameter = new G4UIparameter ("alpha", 'd', omitable = true);
199  parameter->SetDefaultValue (1.);
200  parameter->SetGuidance ("Opacity");
201  fpCommand->SetParameter (parameter);
202 }
203 
205 {
206  delete fpCommand;
207 }
208 
210 {
211  return G4String();
212 }
213 
215 {
217 
218  G4String redOrString;
219  G4double green, blue, opacity;
220  std::istringstream iss(newValue);
221  iss >> redOrString >> green >> blue >> opacity;
222 
223  ConvertToColour(fCurrentTextColour, redOrString, green, blue, opacity);
224 
225  if (verbosity >= G4VisManager::confirmations) {
226  G4cout <<
227  "Colour for future \"/vis/scene/add/text\" commands has been set to "
228  << fCurrentTextColour << '.'
229  << G4endl;
230  }
231 }
232 
234 
236 {
237  G4bool omitable;
238  fpCommand = new G4UIcmdWithAString("/vis/set/textLayout", this);
240  ("Defines layout future \"/vis/scene/add/text\" commands.");
242  ("\"left\" (default) for left justification to provided coordinate.");
244  ("\"centre\" or \"center\" for text centered on provided coordinate.");
246  ("\"right\" for right justification to provided coordinate.");
247  fpCommand->SetGuidance("Default: left.");
248  fpCommand->SetParameterName("layout", omitable = true);
249  fpCommand->SetCandidates ("left centre center right");
250  fpCommand->SetDefaultValue ("left");
251 }
252 
254 {
255  delete fpCommand;
256 }
257 
259 {
260  return G4String();
261 }
262 
264 {
265  G4Text::Layout layout = G4Text::left;
266  if (newValue == "left") layout = G4Text::left;
267  else if (newValue == "centre" || newValue == "center")
268  layout = G4Text::centre;
269  else if (newValue == "right") layout = G4Text::right;
270 
271  fCurrentTextLayout = layout;
272 
274  if (verbosity >= G4VisManager::confirmations) {
275  G4cout << "Text layout (for future \"text\" commands) has been set to \""
276  << fCurrentTextLayout << "\"."
277  << G4endl;
278  }
279 }
280 
282 
284 {
285  G4bool omitable;
286  fpCommand = new G4UIcmdWithADouble("/vis/set/textSize", this);
288  ("Defines text size (pixels) for future \"/vis/scene/add/\" commands.");
289  fpCommand->SetParameterName ("textSize", omitable = true);
290  fpCommand->SetDefaultValue (12.); // pixels
291  fpCommand->SetRange("textSize >= 1.");
292 }
293 
295 {
296  delete fpCommand;
297 }
298 
300 {
301  return G4String();
302 }
303 
305 {
307 
309 
310  if (verbosity >= G4VisManager::confirmations) {
311  G4cout <<
312  "Text size for future \"/vis/scene/add/\" commands has been set to "
314  << G4endl;
315  }
316 }
317 
319 
321 {
322  G4bool omitable;
323  G4UIparameter* parameter;
324  fpCommand = new G4UIcommand("/vis/set/touchable", this);
326  ("Defines touchable for future \"/vis/touchable/set/\" commands.");
328  ("Please provide a list of space-separated physical volume names and"
329  "\ncopy number pairs starting at the world volume, e.g:"
330  "\n /vis/set/touchable World 0 Envelope 0 Shape1 0"
331  "\n(To get list of touchables, use \"/vis/drawTree\")"
332  "\n(To save, use \"/vis/viewer/save\")");
333  parameter = new G4UIparameter ("list", 's', omitable = false);
334  parameter->SetGuidance
335  ("List of physical volume names and copy number pairs");
336  fpCommand->SetParameter (parameter);
337 }
338 
340 {
341  delete fpCommand;
342 }
343 
345 {
346  return G4String();
347 }
348 
350 {
352 
353  G4ModelingParameters::PVNameCopyNoPath currentTouchablePath;
354 
355  // Algorithm from Josuttis p.476.
356  G4String::size_type iBegin, iEnd;
357  iBegin = newValue.find_first_not_of(' ');
358  while (iBegin != G4String::npos) {
359  iEnd = newValue.find_first_of(' ',iBegin);
360  if (iEnd == G4String::npos) {
361  iEnd = newValue.length();
362  }
363  G4String name(newValue.substr(iBegin,iEnd-iBegin));
364  iBegin = newValue.find_first_not_of(' ',iEnd);
365  if (iBegin == G4String::npos) {
366  if (verbosity >= G4VisManager::warnings) {
367  G4cout <<
368  "WARNING: G4VisCommandSetTouchable::SetNewValue"
369  "\n A pair not found. (Did you have an even number of parameters?)"
370  "\n Command ignored."
371  << G4endl;
372  return;
373  }
374  }
375  iEnd = newValue.find_first_of(' ',iBegin);
376  if (iEnd == G4String::npos) {
377  iEnd = newValue.length();
378  }
379  G4int copyNo;
380  std::istringstream iss(newValue.substr(iBegin,iEnd-iBegin));
381  if (!(iss >> copyNo)) {
382  if (verbosity >= G4VisManager::warnings) {
383  G4cout <<
384  "WARNING: G4VisCommandSetTouchable::SetNewValue"
385  "\n Error reading copy number - it was not numeric?"
386  "\n Command ignored."
387  << G4endl;
388  return;
389  }
390  }
391  currentTouchablePath.push_back
393  iBegin = newValue.find_first_not_of(' ',iEnd);
394  }
395 
396  fCurrentTouchablePath = currentTouchablePath;
397 
398  if (verbosity >= G4VisManager::confirmations) {
400  << G4endl;
401  }
402 }
403 
std::vector< PVNameCopyNo > PVNameCopyNoPath
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
G4String GetCurrentValue(G4UIcommand *command)
const XML_Char * name
Definition: expat.h:151
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetDefaultValue(G4int defVal)
#define G4endl
Definition: G4ios.hh:61
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetRange(const char *rs)
Definition: G4UIcommand.hh:125
static G4double GetNewDoubleValue(const char *paramString)
void SetDefaultValue(const char *defVal)
G4UIcmdWithADouble * fpCommand
void SetNewValue(G4UIcommand *command, G4String newValue)
static G4double fCurrentLineWidth
G4String GetCurrentValue(G4UIcommand *command)
G4String GetCurrentValue(G4UIcommand *command)
Definition: test07.cc:36
void SetGuidance(const char *theGuidance)
void ConvertToColour(G4Colour &colour, const G4String &redOrString, G4double green, G4double blue, G4double opacity)
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:152
void SetDefaultValue(const char *theDefaultValue)
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValue)
static Verbosity GetVerbosity()
void SetCandidates(const char *candidateList)
G4UIcmdWithAString * fpCommand
const G4String & ConvertToColourGuidance()
void SetNewValue(G4UIcommand *command, G4String newValue)
static G4Colour fCurrentColour
Layout
Definition: G4Text.hh:77
int G4int
Definition: G4Types.hh:78
G4UIcmdWithADouble * fpCommand
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
static G4ModelingParameters::PVNameCopyNoPath fCurrentTouchablePath
void SetDefaultValue(G4double defVal)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
static G4int GetNewIntValue(const char *paramString)
G4GLOB_DLL std::ostream G4cout
G4String GetCurrentValue(G4UIcommand *command)
static G4Text::Layout fCurrentTextLayout
static G4int fCurrentArrow3DLineSegmentsPerCircle
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
static G4Colour fCurrentTextColour
static G4double fCurrentTextSize
static G4VisManager * fpVisManager
void SetNewValue(G4UIcommand *command, G4String newValue)