Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4RTMessenger.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: G4RTMessenger.cc 86973 2014-11-21 11:57:27Z gcosmo $
28 //
29 //
30 //
31 
32 
33 #include "G4RTMessenger.hh"
34 
35 #include "G4UIdirectory.hh"
36 #include "G4UIcmdWithABool.hh"
37 #include "G4UIcmdWith3Vector.hh"
40 #include "G4UIcmdWithAnInteger.hh"
41 #include "G4UIcmdWithAString.hh"
42 #include "G4RTSteppingAction.hh"
43 #include "G4ThreeVector.hh"
44 #include "G4VisManager.hh"
45 #include "G4RayTracerViewer.hh"
46 #include "G4TheRayTracer.hh"
47 
49 
52 {
53  if (!fpInstance) fpInstance = new G4RTMessenger(p1);
54  return fpInstance;
55 }
56 
58 {
59  theDefaultTracer = p1;
61 
62  rayDirectory = new G4UIdirectory("/vis/rayTracer/");
63  rayDirectory->SetGuidance("RayTracer commands.");
64 
65  fileCmd = new G4UIcmdWithAString("/vis/rayTracer/trace",this);
66  fileCmd->SetGuidance("Start the ray tracing.");
67  fileCmd->SetGuidance("Define the name of output JPEG file.");
68  fileCmd->SetParameterName("fileName",true);
69  fileCmd->SetDefaultValue("g4RayTracer.jpeg");
71 
72  columnCmd = new G4UIcmdWithAnInteger("/vis/rayTracer/column",this);
73  columnCmd->SetGuidance("Define the number of horizontal pixels.");
74  columnCmd->SetParameterName("nPixel",false);
75  columnCmd->SetRange("nPixel > 0");
76 
77  rowCmd = new G4UIcmdWithAnInteger("/vis/rayTracer/row",this);
78  rowCmd->SetGuidance("Define the number of virtical pixels.");
79  rowCmd->SetParameterName("nPixel",false);
80  rowCmd->SetRange("nPixel > 0");
81 
82  targetCmd = new G4UIcmdWith3VectorAndUnit("/vis/rayTracer/target",this);
83  targetCmd->SetGuidance("Define the center position of the target.");
84  targetCmd->SetParameterName("X","Y","Z",true);
87 
88  eyePosCmd = new G4UIcmdWith3VectorAndUnit("/vis/rayTracer/eyePosition",this);
89  eyePosCmd->SetGuidance("Define the eye position.");
90  eyePosCmd->SetGuidance("Eye direction is calsurated from (target - eyePosition).");
91  eyePosCmd->SetParameterName("X","Y","Z",true);
94 
95  lightCmd = new G4UIcmdWith3Vector("/vis/rayTracer/lightDirection",this);
96  lightCmd->SetGuidance("Define the direction of illumination light.");
97  lightCmd->SetGuidance("The vector needs not to be a unit vector, but it must not be a zero vector.");
98  lightCmd->SetParameterName("Px","Py","Pz",true);
99  lightCmd->SetDefaultValue(G4ThreeVector(0.1,0.2,0.3));
100  lightCmd->SetRange("Px != 0 || Py != 0 || Pz != 0");
101 
102  spanXCmd = new G4UIcmdWithADoubleAndUnit("/vis/rayTracer/span",this);
103  spanXCmd->SetGuidance("Define the angle per 100 pixels.");
104  spanXCmd->SetParameterName("span",true);
106  spanXCmd->SetDefaultUnit("deg");
107  spanXCmd->SetRange("span>0.");
108 
109  headCmd = new G4UIcmdWithADoubleAndUnit("/vis/rayTracer/headAngle",this);
110  headCmd->SetGuidance("Define the head direction.");
111  headCmd->SetParameterName("headAngle",true);
112  headCmd->SetDefaultValue(270.);
113  headCmd->SetDefaultUnit("deg");
114  headCmd->SetRange("headAngle>=0. && headAngle<360.");
115 
116  attCmd = new G4UIcmdWithADoubleAndUnit("/vis/rayTracer/attenuation",this);
117  attCmd->SetGuidance("Define the attenuation length for transparent material.");
118  attCmd->SetGuidance("Note that this value is independent to the attenuation length for the optical photon processes.");
119  attCmd->SetParameterName("Length",true);
120  attCmd->SetDefaultValue(1.0);
121  attCmd->SetDefaultUnit("m");
122  attCmd->SetRange("Length > 0.");
123 
124  distCmd = new G4UIcmdWithABool("/vis/rayTracer/distortion",this);
125  distCmd->SetGuidance("Distortion effect of the fish eye lens.");
126  distCmd->SetParameterName("flag",true);
127  distCmd->SetDefaultValue(false);
128 
129  transCmd = new G4UIcmdWithABool("/vis/rayTracer/ignoreTransparency",this);
130  transCmd->SetGuidance("Ignore transparency even if the alpha of G4Colour < 1.");
131  transCmd->SetParameterName("flag",true);
132  transCmd->SetDefaultValue(false);
133 
134  bkgColCmd = new G4UIcmdWith3Vector("/vis/rayTracer/backgroundColour",this);
135  bkgColCmd->SetGuidance("Command has been deprecated. Use /vis/viewer/set/background instead.");
136  bkgColCmd->SetParameterName("red","green","blue",true);
138 }
139 
141 {
142  delete columnCmd;
143  delete rowCmd;
144  delete targetCmd;
145  delete eyePosCmd;
146  delete lightCmd;
147  delete spanXCmd;
148  delete headCmd;
149  delete attCmd;
150  delete distCmd;
151  delete transCmd;
152  delete fileCmd;
153  delete bkgColCmd;
154  delete rayDirectory;
155 }
156 
158 {
159  G4String currentValue;
160  if(command==columnCmd)
161  { currentValue = columnCmd->ConvertToString(theTracer->GetNColumn()); }
162  else if(command==rowCmd)
163  { currentValue = rowCmd->ConvertToString(theTracer->GetNRow()); }
164  else if(command==targetCmd)
165  { currentValue = targetCmd->ConvertToString(theTracer->GetTargetPosition(),"m"); }
166  else if(command==eyePosCmd)
167  { currentValue = eyePosCmd->ConvertToString(theTracer->GetEyePosition(),"m"); }
168  else if(command==lightCmd)
169  { currentValue = lightCmd->ConvertToString(theTracer->GetLightDirection()); }
170  else if(command==spanXCmd)
171  { currentValue = spanXCmd->ConvertToString(theTracer->GetViewSpan(),"deg"); }
172  else if(command==headCmd)
173  { currentValue = headCmd->ConvertToString(theTracer->GetHeadAngle(),"deg"); }
174  else if(command==attCmd)
175  { currentValue = attCmd->ConvertToString(theTracer->GetAttenuationLength(),"m");}
176  else if(command==distCmd)
177  { currentValue = distCmd->ConvertToString(theTracer->GetDistortion()); }
178  else if(command==transCmd)
180  else if(command==bkgColCmd)
181  { currentValue = bkgColCmd->ConvertToString(theTracer->GetBackgroundColour()); }
182  return currentValue;
183 }
184 
186 {
187  G4VisManager* pVisManager = G4VisManager::GetInstance();
188 
190 
191  G4VViewer* pVViewer = pVisManager->GetCurrentViewer();
192  if (pVViewer) {
193  G4RayTracerViewer* pViewer = dynamic_cast<G4RayTracerViewer*>(pVViewer);
194  if (pViewer) {
195  theTracer = pViewer->GetTracer();
196  } else {
197  G4cout <<
198  "G4RTMessenger::SetNewValue: Current viewer is not of type RayTracer."
199  "\n Use \"/vis/viewer/select\" or \"/vis/open\"."
200  << G4endl;
201  }
202  }
203 
204  if (theTracer == theDefaultTracer) {
205  G4cout <<
206 "G4RTMessenger::SetNewValue: No valid current viewer. Using default RayTracer."
207  << G4endl;
208  }
209 
210  if(command==columnCmd)
211  { theTracer->SetNColumn(columnCmd->GetNewIntValue(newValue)); }
212  else if(command==rowCmd)
213  { theTracer->SetNRow(rowCmd->GetNewIntValue(newValue)); }
214  else if(command==targetCmd)
216  else if(command==eyePosCmd)
218  else if(command==lightCmd)
220  else if(command==spanXCmd)
222  else if(command==headCmd)
224  else if(command==attCmd)
226  else if(command==distCmd)
228  else if(command==bkgColCmd)
229  {
230  G4cout << "WARNING: /vis/rayTracer/backgroundColour has been deprecated."
231  "\n Use \"/vis/viewer/set/background\" instead."
232  << G4endl;
233  }
234  else if(command==transCmd)
236  else if(command==fileCmd)
237  { theTracer->Trace(newValue); }
238 }
239 
240 
241 
242 
243 
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
void SetViewSpan(G4double val)
void SetDefaultValue(G4ThreeVector defVal)
G4UIcmdWith3VectorAndUnit * targetCmd
CLHEP::Hep3Vector G4ThreeVector
G4UIcmdWithABool * distCmd
G4TheRayTracer * theDefaultTracer
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
G4bool GetDistortion() const
G4Colour GetBackgroundColour() const
virtual void SetNewValue(G4UIcommand *command, G4String newValue)
void SetTargetPosition(const G4ThreeVector &val)
static G4RTMessenger * GetInstance(G4TheRayTracer *p1)
void SetDefaultValue(G4bool defVal)
#define G4endl
Definition: G4ios.hh:61
void SetParameterName(const char *theNameX, const char *theNameY, const char *theNameZ, G4bool omittable, G4bool currentAsDefault=false)
void SetEyePosition(const G4ThreeVector &val)
static G4VisManager * GetInstance()
void SetRange(const char *rs)
Definition: G4UIcommand.hh:125
G4TheRayTracer * theTracer
void SetDefaultValue(const char *defVal)
G4int GetNColumn() const
void SetAttenuationLength(G4double val)
G4UIcmdWith3Vector * bkgColCmd
static G4bool GetNewBoolValue(const char *paramString)
virtual G4String GetCurrentValue(G4UIcommand *command)
void SetHeadAngle(G4double val)
G4ThreeVector GetEyePosition() const
G4RTMessenger(G4TheRayTracer *p1)
static G4double GetNewDoubleValue(const char *paramString)
G4ThreeVector GetLightDirection() const
virtual ~G4RTMessenger()
G4ThreeVector GetTargetPosition() const
G4UIcmdWithAString * fileCmd
virtual void Trace(const G4String &fileName)
G4double GetViewSpan() const
G4VViewer * GetCurrentViewer() const
G4TheRayTracer * GetTracer()
G4UIdirectory * rayDirectory
G4double GetAttenuationLength() const
G4UIcmdWith3Vector * lightCmd
G4UIcmdWithABool * transCmd
void SetNColumn(G4int val)
void SetDistortion(G4bool val)
static G4ThreeVector GetNew3VectorValue(const char *paramString)
static void SetIgnoreTransparency(G4bool val)
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:374
G4double GetHeadAngle() const
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
G4UIcmdWith3VectorAndUnit * eyePosCmd
G4UIcmdWithADoubleAndUnit * headCmd
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
static G4int GetNewIntValue(const char *paramString)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetLightDirection(const G4ThreeVector &val)
G4UIcmdWithADoubleAndUnit * spanXCmd
G4GLOB_DLL std::ostream G4cout
G4int GetNRow() const
void SetNRow(G4int val)
void SetDefaultValue(G4ThreeVector defVal)
void SetDefaultUnit(const char *defUnit)
static G4ThreeVector GetNew3VectorValue(const char *paramString)
G4UIcmdWithAnInteger * columnCmd
G4UIcmdWithADoubleAndUnit * attCmd
void SetParameterName(const char *theNameX, const char *theNameY, const char *theNameZ, G4bool omittable, G4bool currentAsDefault=false)
static G4bool GetIgnoreTransparency()
G4UIcmdWithAnInteger * rowCmd
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:242
void SetDefaultUnit(const char *defUnit)
static G4RTMessenger * fpInstance