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 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /visualization/RayTracer/src/G4RTMessenger.cc (Version 11.3.0) and /visualization/RayTracer/src/G4RTMessenger.cc (Version 3.0)


                                                   >>   1 // This code implementation is the intellectual property of
                                                   >>   2 // the GEANT4 collaboration.
  1 //                                                  3 //
  2 // ******************************************* <<   4 // By copying, distributing or modifying the Program (or any work
  3 // * License and Disclaimer                    <<   5 // based on the Program) you indicate your acceptance of this statement,
  4 // *                                           <<   6 // and all its terms.
  5 // * The  Geant4 software  is  copyright of th << 
  6 // * the Geant4 Collaboration.  It is provided << 
  7 // * conditions of the Geant4 Software License << 
  8 // * LICENSE and available at  http://cern.ch/ << 
  9 // * include a list of copyright holders.      << 
 10 // *                                           << 
 11 // * Neither the authors of this software syst << 
 12 // * institutes,nor the agencies providing fin << 
 13 // * work  make  any representation or  warran << 
 14 // * regarding  this  software system or assum << 
 15 // * use.  Please see the license in the file  << 
 16 // * for the full disclaimer and the limitatio << 
 17 // *                                           << 
 18 // * This  code  implementation is the result  << 
 19 // * technical work of the GEANT4 collaboratio << 
 20 // * By using,  copying,  modifying or  distri << 
 21 // * any work based  on the software)  you  ag << 
 22 // * use  in  resulting  scientific  publicati << 
 23 // * acceptance of all terms of the Geant4 Sof << 
 24 // ******************************************* << 
 25 //                                             << 
 26 //                                                  7 //
                                                   >>   8 // $Id: G4RTMessenger.cc,v 1.4 2000/06/07 02:52:45 asaim Exp $
                                                   >>   9 // GEANT4 tag $Name: geant4-03-00 $
 27 //                                                 10 //
 28 //                                                 11 //
 29 //                                                 12 //
 30                                                    13 
 31                                                    14 
 32 #include "G4RTMessenger.hh"                        15 #include "G4RTMessenger.hh"
 33                                                    16 
 34 #include "G4UIdirectory.hh"                        17 #include "G4UIdirectory.hh"
 35 #include "G4UIcmdWithABool.hh"                     18 #include "G4UIcmdWithABool.hh"
 36 #include "G4UIcmdWith3Vector.hh"                   19 #include "G4UIcmdWith3Vector.hh"
 37 #include "G4UIcmdWith3VectorAndUnit.hh"            20 #include "G4UIcmdWith3VectorAndUnit.hh"
 38 #include "G4UIcmdWithADoubleAndUnit.hh"            21 #include "G4UIcmdWithADoubleAndUnit.hh"
 39 #include "G4UIcmdWithAnInteger.hh"                 22 #include "G4UIcmdWithAnInteger.hh"
 40 #include "G4UIcmdWithAString.hh"                   23 #include "G4UIcmdWithAString.hh"
                                                   >>  24 #include "G4RayTracer.hh"
 41 #include "G4RTSteppingAction.hh"                   25 #include "G4RTSteppingAction.hh"
 42 #include "G4ThreeVector.hh"                        26 #include "G4ThreeVector.hh"
 43 #include "G4VisManager.hh"                     << 
 44 #include "G4RayTracerViewer.hh"                << 
 45 #include "G4TheRayTracer.hh"                   << 
 46                                                << 
 47 #define G4warn G4cout                          << 
 48                                                << 
 49 G4RTMessenger* G4RTMessenger::fpInstance = 0;  << 
 50                                                << 
 51 G4RTMessenger* G4RTMessenger::GetInstance      << 
 52 (G4TheRayTracer* p1)                           << 
 53 {                                              << 
 54   if (!fpInstance) fpInstance = new G4RTMessen << 
 55   return fpInstance;                           << 
 56 }                                              << 
 57                                                    27 
 58 G4RTMessenger::G4RTMessenger(G4TheRayTracer* p <<  28 G4RTMessenger::G4RTMessenger(G4RayTracer* p1,G4RTSteppingAction* p2)
 59 {                                                  29 {
 60   theDefaultTracer = p1;                       <<  30   theTracer = p1;
 61   theTracer = theDefaultTracer;                <<  31   theSteppingAction = p2;
 62                                                    32 
 63   rayDirectory = new G4UIdirectory("/vis/rayTr     33   rayDirectory = new G4UIdirectory("/vis/rayTracer/");
 64   rayDirectory->SetGuidance("RayTracer command     34   rayDirectory->SetGuidance("RayTracer commands.");
 65                                                    35 
 66   fileCmd = new G4UIcmdWithAString("/vis/rayTr     36   fileCmd = new G4UIcmdWithAString("/vis/rayTracer/trace",this);
 67   fileCmd->SetGuidance("Start the ray tracing.     37   fileCmd->SetGuidance("Start the ray tracing.");
 68   fileCmd->SetGuidance("Define the name of out     38   fileCmd->SetGuidance("Define the name of output JPEG file.");
 69   fileCmd->SetParameterName("fileName",true);      39   fileCmd->SetParameterName("fileName",true);
 70   fileCmd->SetDefaultValue("g4RayTracer.jpeg")     40   fileCmd->SetDefaultValue("g4RayTracer.jpeg");
 71   fileCmd->AvailableForStates(G4State_Idle);   <<  41   fileCmd->AvailableForStates(Idle);
 72                                                    42 
 73   columnCmd = new G4UIcmdWithAnInteger("/vis/r     43   columnCmd = new G4UIcmdWithAnInteger("/vis/rayTracer/column",this);
 74   columnCmd->SetGuidance("Define the number of     44   columnCmd->SetGuidance("Define the number of horizontal pixels.");
 75   columnCmd->SetParameterName("nPixel",false);     45   columnCmd->SetParameterName("nPixel",false);
 76   columnCmd->SetRange("nPixel > 0");               46   columnCmd->SetRange("nPixel > 0");
 77                                                    47 
 78   rowCmd = new G4UIcmdWithAnInteger("/vis/rayT     48   rowCmd = new G4UIcmdWithAnInteger("/vis/rayTracer/row",this);
 79   rowCmd->SetGuidance("Define the number of ve <<  49   rowCmd->SetGuidance("Define the number of virtical pixels.");
 80   rowCmd->SetParameterName("nPixel",false);        50   rowCmd->SetParameterName("nPixel",false);
 81   rowCmd->SetRange("nPixel > 0");                  51   rowCmd->SetRange("nPixel > 0");
 82                                                    52 
 83   targetCmd = new G4UIcmdWith3VectorAndUnit("/     53   targetCmd = new G4UIcmdWith3VectorAndUnit("/vis/rayTracer/target",this);
 84   targetCmd->SetGuidance("Define the center po     54   targetCmd->SetGuidance("Define the center position of the target.");
 85   targetCmd->SetParameterName("X","Y","Z",true     55   targetCmd->SetParameterName("X","Y","Z",true);
 86   targetCmd->SetDefaultValue(G4ThreeVector(0.,     56   targetCmd->SetDefaultValue(G4ThreeVector(0.,0.,0.));
 87   targetCmd->SetDefaultUnit("m");                  57   targetCmd->SetDefaultUnit("m");
 88                                                    58 
 89   eyePosCmd = new G4UIcmdWith3VectorAndUnit("/     59   eyePosCmd = new G4UIcmdWith3VectorAndUnit("/vis/rayTracer/eyePosition",this);
 90   eyePosCmd->SetGuidance("Define the eye posit     60   eyePosCmd->SetGuidance("Define the eye position.");
 91   eyePosCmd->SetGuidance("Eye direction is cal <<  61   eyePosCmd->SetGuidance("Eye direction is calsurated from (target - eyePosition).");
 92   eyePosCmd->SetParameterName("X","Y","Z",true     62   eyePosCmd->SetParameterName("X","Y","Z",true);
 93   eyePosCmd->SetDefaultValue(G4ThreeVector(0.,     63   eyePosCmd->SetDefaultValue(G4ThreeVector(0.,0.,0.));
 94   eyePosCmd->SetDefaultUnit("m");                  64   eyePosCmd->SetDefaultUnit("m");
 95                                                    65 
 96   lightCmd = new G4UIcmdWith3Vector("/vis/rayT     66   lightCmd = new G4UIcmdWith3Vector("/vis/rayTracer/lightDirection",this);
 97   lightCmd->SetGuidance("Define the direction      67   lightCmd->SetGuidance("Define the direction of illumination light.");
 98   lightCmd->SetGuidance("The vector needs not      68   lightCmd->SetGuidance("The vector needs not to be a unit vector, but it must not be a zero vector.");
 99   lightCmd->SetParameterName("Px","Py","Pz",tr     69   lightCmd->SetParameterName("Px","Py","Pz",true);
100   lightCmd->SetDefaultValue(G4ThreeVector(0.1,     70   lightCmd->SetDefaultValue(G4ThreeVector(0.1,0.2,0.3));
101   lightCmd->SetRange("Px != 0 || Py != 0 || Pz     71   lightCmd->SetRange("Px != 0 || Py != 0 || Pz != 0");
102                                                    72 
103   spanXCmd = new G4UIcmdWithADoubleAndUnit("/v     73   spanXCmd = new G4UIcmdWithADoubleAndUnit("/vis/rayTracer/span",this);
104   spanXCmd->SetGuidance("Define the angle per      74   spanXCmd->SetGuidance("Define the angle per 100 pixels.");
105   spanXCmd->SetParameterName("span",true);         75   spanXCmd->SetParameterName("span",true);
106   spanXCmd->SetDefaultValue(50.);                  76   spanXCmd->SetDefaultValue(50.);
107   spanXCmd->SetDefaultUnit("deg");                 77   spanXCmd->SetDefaultUnit("deg");
108   spanXCmd->SetRange("span>0.");                   78   spanXCmd->SetRange("span>0.");
109                                                    79 
110   headCmd = new G4UIcmdWithADoubleAndUnit("/vi     80   headCmd = new G4UIcmdWithADoubleAndUnit("/vis/rayTracer/headAngle",this);
111   headCmd->SetGuidance("Define the head direct     81   headCmd->SetGuidance("Define the head direction.");
112   headCmd->SetParameterName("headAngle",true);     82   headCmd->SetParameterName("headAngle",true);
113   headCmd->SetDefaultValue(270.);                  83   headCmd->SetDefaultValue(270.);
114   headCmd->SetDefaultUnit("deg");                  84   headCmd->SetDefaultUnit("deg");
115   headCmd->SetRange("headAngle>=0. && headAngl     85   headCmd->SetRange("headAngle>=0. && headAngle<360.");
116                                                    86 
117   attCmd = new G4UIcmdWithADoubleAndUnit("/vis     87   attCmd = new G4UIcmdWithADoubleAndUnit("/vis/rayTracer/attenuation",this);
118   attCmd->SetGuidance("Define the attenuation      88   attCmd->SetGuidance("Define the attenuation length for transparent material.");
119   attCmd->SetGuidance("Note that this value is     89   attCmd->SetGuidance("Note that this value is independent to the attenuation length for the optical photon processes.");
120   attCmd->SetParameterName("Length",true);         90   attCmd->SetParameterName("Length",true);
121   attCmd->SetDefaultValue(1.0);                    91   attCmd->SetDefaultValue(1.0);
122   attCmd->SetDefaultUnit("m");                     92   attCmd->SetDefaultUnit("m");
123   attCmd->SetRange("Length > 0.");                 93   attCmd->SetRange("Length > 0.");
124                                                    94 
125   distCmd = new G4UIcmdWithABool("/vis/rayTrac     95   distCmd = new G4UIcmdWithABool("/vis/rayTracer/distortion",this);
126   distCmd->SetGuidance("Distortion effect of t     96   distCmd->SetGuidance("Distortion effect of the fish eye lens.");
127   distCmd->SetParameterName("flag",true);          97   distCmd->SetParameterName("flag",true);
128   distCmd->SetDefaultValue(false);                 98   distCmd->SetDefaultValue(false);
129                                                    99 
130   transCmd = new G4UIcmdWithABool("/vis/rayTra    100   transCmd = new G4UIcmdWithABool("/vis/rayTracer/ignoreTransparency",this);
131   transCmd->SetGuidance("Ignore transparency e    101   transCmd->SetGuidance("Ignore transparency even if the alpha of G4Colour < 1.");
132   transCmd->SetParameterName("flag",true);        102   transCmd->SetParameterName("flag",true);
133   transCmd->SetDefaultValue(false);               103   transCmd->SetDefaultValue(false);
134                                                << 
135   bkgColCmd = new G4UIcmdWith3Vector("/vis/ray << 
136   bkgColCmd->SetGuidance("Command has been dep << 
137   bkgColCmd->SetParameterName("red","green","b << 
138   bkgColCmd->SetDefaultValue(G4ThreeVector(1., << 
139 }                                                 104 }
140                                                   105 
141 G4RTMessenger::~G4RTMessenger()                   106 G4RTMessenger::~G4RTMessenger()
142 {                                                 107 {
143   delete columnCmd;                               108   delete columnCmd;
144   delete rowCmd;                                  109   delete rowCmd;
145   delete targetCmd;                               110   delete targetCmd;
146   delete eyePosCmd;                               111   delete eyePosCmd;
147   delete lightCmd;                                112   delete lightCmd;
148   delete spanXCmd;                                113   delete spanXCmd;
149   delete headCmd;                                 114   delete headCmd;
150   delete attCmd;                                  115   delete attCmd;
151   delete distCmd;                                 116   delete distCmd;
152   delete transCmd;                                117   delete transCmd;
153   delete fileCmd;                                 118   delete fileCmd;
154   delete bkgColCmd;                            << 
155   delete rayDirectory;                            119   delete rayDirectory;
156 }                                                 120 }
157                                                   121 
158 G4String G4RTMessenger::GetCurrentValue(G4UIco    122 G4String G4RTMessenger::GetCurrentValue(G4UIcommand * command)
159 {                                                 123 {
160   G4String currentValue;                          124   G4String currentValue;
161   if(command==columnCmd)                          125   if(command==columnCmd)
162   { currentValue = columnCmd->ConvertToString(    126   { currentValue = columnCmd->ConvertToString(theTracer->GetNColumn()); }
163   else if(command==rowCmd)                        127   else if(command==rowCmd)
164   { currentValue = rowCmd->ConvertToString(the    128   { currentValue = rowCmd->ConvertToString(theTracer->GetNRow()); }
165   else if(command==targetCmd)                     129   else if(command==targetCmd)
166   { currentValue = targetCmd->ConvertToString(    130   { currentValue = targetCmd->ConvertToString(theTracer->GetTargetPosition(),"m"); }
167   else if(command==eyePosCmd)                     131   else if(command==eyePosCmd)
168   { currentValue = eyePosCmd->ConvertToString(    132   { currentValue = eyePosCmd->ConvertToString(theTracer->GetEyePosition(),"m"); }
169   else if(command==lightCmd)                      133   else if(command==lightCmd)
170   { currentValue = lightCmd->ConvertToString(t    134   { currentValue = lightCmd->ConvertToString(theTracer->GetLightDirection()); }
171   else if(command==spanXCmd)                      135   else if(command==spanXCmd)
172   { currentValue = spanXCmd->ConvertToString(t    136   { currentValue = spanXCmd->ConvertToString(theTracer->GetViewSpan(),"deg"); }
173   else if(command==headCmd)                       137   else if(command==headCmd)
174   { currentValue = headCmd->ConvertToString(th    138   { currentValue = headCmd->ConvertToString(theTracer->GetHeadAngle(),"deg"); }
175   else if(command==attCmd)                        139   else if(command==attCmd)
176   { currentValue = attCmd->ConvertToString(the    140   { currentValue = attCmd->ConvertToString(theTracer->GetAttenuationLength(),"m");}
177   else if(command==distCmd)                       141   else if(command==distCmd)
178   { currentValue = distCmd->ConvertToString(th    142   { currentValue = distCmd->ConvertToString(theTracer->GetDistortion()); }
179   else if(command==transCmd)                      143   else if(command==transCmd)
180   { currentValue = transCmd->ConvertToString(G << 144   { currentValue = transCmd->ConvertToString(theSteppingAction->GetIgnoreTransparency()); }
181   else if(command==bkgColCmd)                  << 
182   { currentValue = bkgColCmd->ConvertToString( << 
183   return currentValue;                            145   return currentValue;
184 }                                                 146 }
185                                                   147 
186 void G4RTMessenger::SetNewValue(G4UIcommand *     148 void G4RTMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
187 {                                                 149 {
188   G4VisManager* pVisManager = G4VisManager::Ge << 
189                                                << 
190   theTracer = theDefaultTracer;                << 
191                                                << 
192   G4VViewer* pVViewer = pVisManager->GetCurren << 
193   if (pVViewer) {                              << 
194     G4RayTracerViewer* pViewer = dynamic_cast< << 
195     if (pViewer) {                             << 
196       theTracer = pViewer->GetTracer();        << 
197     } else {                                   << 
198       G4warn <<                                << 
199   "G4RTMessenger::SetNewValue: Current viewer  << 
200   "\n  Use \"/vis/viewer/select\" or \"/vis/op << 
201        << G4endl;                              << 
202     }                                          << 
203   }                                            << 
204                                                << 
205   if (theTracer == theDefaultTracer) {         << 
206     G4warn <<                                  << 
207 "G4RTMessenger::SetNewValue: No valid current  << 
208      << G4endl;                                << 
209   }                                            << 
210                                                << 
211   if(command==columnCmd)                          150   if(command==columnCmd)
212   { theTracer->SetNColumn(columnCmd->GetNewInt    151   { theTracer->SetNColumn(columnCmd->GetNewIntValue(newValue)); }
213   else if(command==rowCmd)                        152   else if(command==rowCmd)
214   { theTracer->SetNRow(rowCmd->GetNewIntValue(    153   { theTracer->SetNRow(rowCmd->GetNewIntValue(newValue)); }
215   else if(command==targetCmd)                     154   else if(command==targetCmd)
216   { theTracer->SetTargetPosition(targetCmd->Ge    155   { theTracer->SetTargetPosition(targetCmd->GetNew3VectorValue(newValue)); }
217   else if(command==eyePosCmd)                     156   else if(command==eyePosCmd)
218   { theTracer->SetEyePosition(eyePosCmd->GetNe    157   { theTracer->SetEyePosition(eyePosCmd->GetNew3VectorValue(newValue)); }
219   else if(command==lightCmd)                      158   else if(command==lightCmd)
220   { theTracer->SetLightDirection(lightCmd->Get    159   { theTracer->SetLightDirection(lightCmd->GetNew3VectorValue(newValue)); }
221   else if(command==spanXCmd)                      160   else if(command==spanXCmd)
222   { theTracer->SetViewSpan(spanXCmd->GetNewDou    161   { theTracer->SetViewSpan(spanXCmd->GetNewDoubleValue(newValue)); }
223   else if(command==headCmd)                       162   else if(command==headCmd)
224   { theTracer->SetHeadAngle(headCmd->GetNewDou    163   { theTracer->SetHeadAngle(headCmd->GetNewDoubleValue(newValue)); }
225   else if(command==attCmd)                        164   else if(command==attCmd)
226   { theTracer->SetAttenuationLength(attCmd->Ge    165   { theTracer->SetAttenuationLength(attCmd->GetNewDoubleValue(newValue)); }
227   else if(command==distCmd)                       166   else if(command==distCmd)
228   { theTracer->SetDistortion(distCmd->GetNewBo    167   { theTracer->SetDistortion(distCmd->GetNewBoolValue(newValue)); }
229   else if(command==bkgColCmd)                  << 
230   {                                            << 
231   G4warn << "WARNING: /vis/rayTracer/backgroun << 
232   "\n  Use \"/vis/viewer/set/background\" inst << 
233     << G4endl;                                 << 
234   }                                            << 
235   else if(command==transCmd)                      168   else if(command==transCmd)
236   { G4RTSteppingAction::SetIgnoreTransparency( << 169   { theSteppingAction->SetIgnoreTransparency(transCmd->GetNewBoolValue(newValue)); }
237   else if(command==fileCmd)                       170   else if(command==fileCmd)
238   { theTracer->Trace(newValue); }                 171   { theTracer->Trace(newValue); }
239 }                                                 172 }
240                                                   173 
241                                                   174 
242                                                   175  
243                                                   176 
244                                                   177 
245                                                   178