Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/visualization/OpenGL/src/G4OpenGLViewerMessenger.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 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/OpenGL/src/G4OpenGLViewerMessenger.cc (Version 11.3.0) and /visualization/OpenGL/src/G4OpenGLViewerMessenger.cc (Version 9.0.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 //                                                 26 //
                                                   >>  27 // $Id: G4OpenGLViewerMessenger.cc,v 1.9 2007/06/15 09:52:52 gcosmo Exp $
                                                   >>  28 // GEANT4 tag $Name: geant4-09-00-patch-01 $
 27                                                    29 
 28 #include "G4OpenGLViewerMessenger.hh"              30 #include "G4OpenGLViewerMessenger.hh"
 29                                                    31 
 30 #include "G4OpenGLViewer.hh"                       32 #include "G4OpenGLViewer.hh"
 31 #include "G4OpenGLStoredViewer.hh"                 33 #include "G4OpenGLStoredViewer.hh"
 32 #include "G4OpenGLStoredSceneHandler.hh"       << 
 33 #include "G4UImanager.hh"                          34 #include "G4UImanager.hh"
 34 #include "G4UIcommand.hh"                          35 #include "G4UIcommand.hh"
 35 #include "G4UIdirectory.hh"                        36 #include "G4UIdirectory.hh"
 36 #include "G4UIcmdWithoutParameter.hh"              37 #include "G4UIcmdWithoutParameter.hh"
 37 #include "G4UIcmdWithADouble.hh"                   38 #include "G4UIcmdWithADouble.hh"
 38 #include "G4UIcmdWithABool.hh"                     39 #include "G4UIcmdWithABool.hh"
 39 #include "G4UIcmdWithAString.hh"                   40 #include "G4UIcmdWithAString.hh"
 40 #include "G4UIcmdWithAnInteger.hh"             << 
 41 #include "G4VisManager.hh"                         41 #include "G4VisManager.hh"
 42 #include <sstream>                                 42 #include <sstream>
 43                                                    43 
 44 G4OpenGLViewerMessenger*                           44 G4OpenGLViewerMessenger*
 45 G4OpenGLViewerMessenger::fpInstance = 0;           45 G4OpenGLViewerMessenger::fpInstance = 0;
 46                                                    46 
 47 G4OpenGLViewerMessenger*                           47 G4OpenGLViewerMessenger*
 48 G4OpenGLViewerMessenger::GetInstance()             48 G4OpenGLViewerMessenger::GetInstance()
 49 {                                                  49 {
 50   if (!fpInstance) fpInstance = new G4OpenGLVi     50   if (!fpInstance) fpInstance = new G4OpenGLViewerMessenger;
 51   return fpInstance;                               51   return fpInstance;
 52 }                                                  52 }
 53                                                    53 
 54 G4OpenGLViewerMessenger::G4OpenGLViewerMesseng     54 G4OpenGLViewerMessenger::G4OpenGLViewerMessenger()
 55 {                                                  55 {
 56   G4bool omitable;                                 56   G4bool omitable;
 57                                                    57 
 58   fpDirectory = new G4UIdirectory("/vis/ogl/")     58   fpDirectory = new G4UIdirectory("/vis/ogl/");
 59   fpDirectory->SetGuidance("G4OpenGLViewer com     59   fpDirectory->SetGuidance("G4OpenGLViewer commands.");
 60                                                    60 
 61   fpCommandExport =                            <<  61   fpCommandPrintEPS =
 62   new G4UIcommand("/vis/ogl/export", this);    <<  62     new G4UIcmdWithoutParameter("/vis/ogl/printEPS", this);
 63   fpCommandExport->SetGuidance ("Export a scre <<  63   fpCommandPrintEPS->SetGuidance("Print Encapsulated PostScript file.");
 64   fpCommandExport->SetGuidance                 <<  64   fpCommandPrintEPS->SetGuidance
 65   ("If name is \"\", filename and extension wi <<  65     ("Generates files with names G4OpenGL_n.eps, where n is a sequence"
 66   fpCommandExport->SetGuidance                 <<  66      "\nnumber, starting at 0.");
 67   ("If name is \"toto.png\", set the name to \ << 
 68   fpCommandExport->SetGuidance                 << 
 69   ("If name is \"toto\", set the name to \"tot << 
 70   fpCommandExport->SetGuidance                 << 
 71   ("Will also add an incremented suffix at the << 
 72    "\nthe same as previous it will not reset t << 
 73   fpCommandExport->SetGuidance                 << 
 74   ("Setting size is available only on eps/pdf/ << 
 75   G4UIparameter* parameterExport;              << 
 76   parameterExport = new G4UIparameter ("name", << 
 77   parameterExport->SetDefaultValue("!");       << 
 78   parameterExport->SetGuidance                 << 
 79   ("By default, will take a default value or t << 
 80    " value if set.");                          << 
 81   fpCommandExport->SetParameter(parameterExpor << 
 82   parameterExport = new G4UIparameter ("width" << 
 83   parameterExport->SetGuidance                 << 
 84   ("By default, will take the current width of << 
 85    "\nif set. This parameter is only useful fo << 
 86   parameterExport->SetDefaultValue(-1);        << 
 87   fpCommandExport->SetParameter(parameterExpor << 
 88   parameterExport = new G4UIparameter ("height << 
 89   parameterExport->SetGuidance                 << 
 90   ("By default, will take the current height o << 
 91    "\nif set. This parameter is only useful fo << 
 92   parameterExport->SetDefaultValue(-1);        << 
 93   fpCommandExport->SetParameter(parameterExpor << 
 94                                                << 
 95   fpCommandFlushAt = new G4UIcommand("/vis/ogl << 
 96   fpCommandFlushAt->SetGuidance                << 
 97   ("Controls the rate at which graphics primit << 
 98   fpCommandFlushAt->SetGuidance                << 
 99   ("Flushing to screen is an expensive operati << 
100    "\nan action suitable for your application. << 
101    "\nto screen anyway at end of drawing, and  << 
102    "\nanyway depending on /vis/scene/endOfEven << 
103   fpCommandFlushAt->SetGuidance                << 
104   ("For NthPrimitive and NthEvent the second p << 
105   fpCommandFlushAt->SetGuidance                << 
106   ("For \"never\", detectors and events are st << 
107   G4UIparameter* parameterFlushAt;             << 
108   parameterFlushAt = new G4UIparameter ("actio << 
109   parameterFlushAt->SetParameterCandidates     << 
110   ("endOfEvent endOfRun eachPrimitive NthPrimi << 
111   parameterFlushAt->SetDefaultValue("NthEvent" << 
112   fpCommandFlushAt->SetParameter(parameterFlus << 
113   parameterFlushAt = new G4UIparameter ("N", ' << 
114   parameterFlushAt->SetDefaultValue(100);      << 
115   fpCommandFlushAt->SetParameter(parameterFlus << 
116                                                    67 
117   fpDirectorySet = new G4UIdirectory ("/vis/og     68   fpDirectorySet = new G4UIdirectory ("/vis/ogl/set/");
118   fpDirectorySet->SetGuidance("G4OpenGLViewer      69   fpDirectorySet->SetGuidance("G4OpenGLViewer set commands.");
119                                                    70 
120   fpCommandDisplayListLimit =                  <<  71   G4UIparameter* parameter;
121     new G4UIcmdWithoutParameter("/vis/ogl/set/ <<  72 
122   fpCommandDisplayListLimit->SetGuidance       <<  73   fpCommandDisplayHeadTime =
123   ("This command is no longer relevant. There  <<  74     new G4UIcommand("/vis/ogl/set/displayHeadTime", this);
124    "\nnumber of display lists - except, of cou <<  75   fpCommandDisplayHeadTime->SetGuidance
125    "\nyour computer. Keep an eye on that. Good <<  76     ("Display head time of range in 2D text.");
126                                                <<  77   parameter = new G4UIparameter ("displayHeadTime", 'b', omitable = false);
127   fpCommandExportFormat =                      <<  78   parameter->SetDefaultValue(false);
128   new G4UIcommand("/vis/ogl/set/exportFormat", <<  79   fpCommandDisplayHeadTime->SetParameter(parameter);
129   fpCommandExportFormat->SetGuidance ("Set exp <<  80   parameter = new G4UIparameter ("screenX", 'd', omitable = true);
130   fpCommandExportFormat->SetGuidance ("By defa <<  81   parameter->SetGuidance("-1 < screenX < 1");
131   fpCommandExportFormat->SetGuidance ("Try /vi <<  82   parameter->SetParameterRange("screenX >= -1. && screenX <= 1.");
132   fpCommandExportFormat->SetGuidance ("Changin <<  83   parameter->SetDefaultValue(-0.9);
133   G4UIparameter* parameterExportFormat;        <<  84   fpCommandDisplayHeadTime->SetParameter(parameter);
134   parameterExportFormat = new G4UIparameter (" <<  85   parameter = new G4UIparameter ("screenY", 'd', omitable = true);
135   parameterExportFormat->SetDefaultValue("");  <<  86   parameter->SetGuidance("-1 < screenY < 1");
136   fpCommandExportFormat->SetParameter(paramete <<  87   parameter->SetParameterRange("screenY >= -1. && screenY <= 1.");
137                                                <<  88   parameter->SetDefaultValue(-0.9);
138   fpCommandPrintFilename =                     <<  89   fpCommandDisplayHeadTime->SetParameter(parameter);
139     new G4UIcommand("/vis/ogl/set/printFilenam <<  90   parameter = new G4UIparameter ("screenSize", 'd', omitable = true);
140   fpCommandPrintFilename->SetGuidance ("Set pr <<  91   parameter->SetDefaultValue(24.);
141   fpCommandPrintFilename->SetGuidance ("Settin <<  92   fpCommandDisplayHeadTime->SetParameter(parameter);
142   G4UIparameter* parameterPrintFilename;       <<  93   parameter = new G4UIparameter ("red", 'd', omitable = true);
143   parameterPrintFilename = new G4UIparameter ( <<  94   parameter->SetParameterRange("red >= 0. && red <= 1.");
144   parameterPrintFilename->SetDefaultValue("G4O <<  95   parameter->SetDefaultValue(0.);
145   fpCommandPrintFilename->SetParameter(paramet <<  96   fpCommandDisplayHeadTime->SetParameter(parameter);
146   parameterPrintFilename = new G4UIparameter ( <<  97   parameter = new G4UIparameter ("green", 'd', omitable = true);
147   parameterPrintFilename->SetDefaultValue(1);  <<  98   parameter->SetParameterRange("green >= 0. && green <= 1.");
148   fpCommandPrintFilename->SetParameter(paramet <<  99   parameter->SetDefaultValue(1.);
149                                                << 100   fpCommandDisplayHeadTime->SetParameter(parameter);
150   fpCommandPrintMode = new G4UIcmdWithAString( << 101   parameter = new G4UIparameter ("blue", 'd', omitable = true);
151   fpCommandPrintMode->SetGuidance("Set print m << 102   parameter->SetParameterRange("blue >= 0. && blue <= 1.");
                                                   >> 103   parameter->SetDefaultValue(1.);
                                                   >> 104   fpCommandDisplayHeadTime->SetParameter(parameter);
                                                   >> 105 
                                                   >> 106   fpCommandDisplayLightFront =
                                                   >> 107     new G4UIcommand("/vis/ogl/set/displayLightFront", this);
                                                   >> 108   fpCommandDisplayLightFront->SetGuidance
                                                   >> 109     ("Display the light front at head time.");
                                                   >> 110   fpCommandDisplayLightFront->SetGuidance
                                                   >> 111     ("Tip: The trajectories can appear of jump ahead of the light front"
                                                   >> 112      "\nbecause their time range overlaps the viewer's time range.  To"
                                                   >> 113      "\naverage out this discrete time effect, advance the light front by"
                                                   >> 114      "\nhalf the trajectories interval. E.g., if the trajectory time slice"
                                                   >> 115      "\ninterval is 0.01 ns:"
                                                   >> 116      "\n  /vis/ogl/set/displayLightFront true -90 0 0 mm -0.005 ns"
                                                   >> 117      "\nTo prevent them beating the light front at all:"
                                                   >> 118      "\n  /vis/ogl/set/displayLightFront true -90 0 0 mm -0.01 ns");
                                                   >> 119   parameter = new G4UIparameter ("displayLightFront", 'b', omitable = false);
                                                   >> 120   parameter->SetDefaultValue(false);
                                                   >> 121   fpCommandDisplayLightFront->SetParameter(parameter);
                                                   >> 122   parameter = new G4UIparameter ("originX", 'd', omitable = true);
                                                   >> 123   parameter->SetDefaultValue(0.);
                                                   >> 124   fpCommandDisplayLightFront->SetParameter(parameter);
                                                   >> 125   parameter = new G4UIparameter ("originY", 'd', omitable = true);
                                                   >> 126   parameter->SetDefaultValue(0.);
                                                   >> 127   fpCommandDisplayLightFront->SetParameter(parameter);
                                                   >> 128   parameter = new G4UIparameter ("originZ", 'd', omitable = true);
                                                   >> 129   parameter->SetDefaultValue(0.);
                                                   >> 130   fpCommandDisplayLightFront->SetParameter(parameter);
                                                   >> 131   parameter = new G4UIparameter ("space_unit", 's', omitable = true);
                                                   >> 132   parameter->SetDefaultValue("m");
                                                   >> 133   fpCommandDisplayLightFront->SetParameter(parameter);
                                                   >> 134   parameter = new G4UIparameter ("originT", 'd', omitable = true);
                                                   >> 135   parameter->SetDefaultValue(0.);
                                                   >> 136   fpCommandDisplayLightFront->SetParameter(parameter);
                                                   >> 137   parameter = new G4UIparameter ("time_unit", 's', omitable = true);
                                                   >> 138   parameter->SetDefaultValue("s");
                                                   >> 139   fpCommandDisplayLightFront->SetParameter(parameter);
                                                   >> 140   parameter = new G4UIparameter ("red", 'd', omitable = true);
                                                   >> 141   parameter->SetParameterRange("red >= 0. && red <= 1.");
                                                   >> 142   parameter->SetDefaultValue(0.);
                                                   >> 143   fpCommandDisplayLightFront->SetParameter(parameter);
                                                   >> 144   parameter = new G4UIparameter ("green", 'd', omitable = true);
                                                   >> 145   parameter->SetParameterRange("green >= 0. && green <= 1.");
                                                   >> 146   parameter->SetDefaultValue(1.);
                                                   >> 147   fpCommandDisplayLightFront->SetParameter(parameter);
                                                   >> 148   parameter = new G4UIparameter ("blue", 'd', omitable = true);
                                                   >> 149   parameter->SetParameterRange("blue >= 0. && blue <= 1.");
                                                   >> 150   parameter->SetDefaultValue(0.);
                                                   >> 151   fpCommandDisplayLightFront->SetParameter(parameter);
                                                   >> 152 
                                                   >> 153   fpCommandEndTime =
                                                   >> 154     new G4UIcommand("/vis/ogl/set/endTime", this);
                                                   >> 155   fpCommandEndTime->SetGuidance("Set end and range of track time.");
                                                   >> 156   parameter = new G4UIparameter ("end-time", 'd', omitable = false);
                                                   >> 157   parameter->SetDefaultValue(G4OPENGL_DBL_MAX);
                                                   >> 158   fpCommandEndTime->SetParameter(parameter);
                                                   >> 159   parameter = new G4UIparameter ("end-time-unit", 's', omitable = false);
                                                   >> 160   parameter->SetDefaultValue("ns");
                                                   >> 161   fpCommandEndTime->SetParameter(parameter);
                                                   >> 162   parameter = new G4UIparameter ("time-range", 'd', omitable = true);
                                                   >> 163   parameter->SetDefaultValue(-1.);
                                                   >> 164   fpCommandEndTime->SetParameter(parameter);
                                                   >> 165   parameter = new G4UIparameter ("time-range-unit", 's', omitable = true);
                                                   >> 166   parameter->SetDefaultValue("ns");
                                                   >> 167   fpCommandEndTime->SetParameter(parameter);
                                                   >> 168 
                                                   >> 169   fpCommandFade = new G4UIcmdWithADouble("/vis/ogl/set/fade", this);
                                                   >> 170   fpCommandFade->SetGuidance
                                                   >> 171     ("0: no fade; 1: maximum fade with time within range.");
                                                   >> 172   fpCommandFade->SetParameterName("fadefactor", omitable = false);
                                                   >> 173   fpCommandFade->SetRange("fadefactor>=0.&&fadefactor<=1.");
                                                   >> 174   fpCommandFade->SetDefaultValue(0.);
                                                   >> 175 
                                                   >> 176   fpCommandPrintMode = new G4UIcmdWithAString
                                                   >> 177     ("/vis/ogl/set/printMode",this);
                                                   >> 178   fpCommandPrintMode->SetGuidance("Set print mode");
152   fpCommandPrintMode->SetParameterName("print_    179   fpCommandPrintMode->SetParameterName("print_mode",omitable = true);
153   fpCommandPrintMode->SetCandidates("vectored     180   fpCommandPrintMode->SetCandidates("vectored pixmap");
154   fpCommandPrintMode->SetDefaultValue("vectore    181   fpCommandPrintMode->SetDefaultValue("vectored");
155                                                   182 
156   fpCommandPrintSize =                         << 183   fpCommandStartTime =
157     new G4UIcommand("/vis/ogl/set/printSize",  << 184     new G4UIcommand("/vis/ogl/set/startTime", this);
158   fpCommandPrintSize->SetGuidance ("Set print  << 185   fpCommandStartTime->SetGuidance("Set start and range of track time.");
159   fpCommandPrintSize->SetGuidance ("Tip : -1 w << 186   parameter = new G4UIparameter ("start-time", 'd', omitable = false);
160   fpCommandPrintSize->SetGuidance ("       Set << 187   parameter->SetDefaultValue(-G4OPENGL_DBL_MAX);
161   G4UIparameter* parameterPrintSize;           << 188   fpCommandStartTime->SetParameter(parameter);
162   parameterPrintSize = new G4UIparameter ("wid << 189   parameter = new G4UIparameter ("start-time-unit", 's', omitable = false);
163   parameterPrintSize->SetDefaultValue(-1);     << 190   parameter->SetDefaultValue("ns");
164   fpCommandPrintSize->SetParameter(parameterPr << 191   fpCommandStartTime->SetParameter(parameter);
165   parameterPrintSize = new G4UIparameter ("hei << 192   parameter = new G4UIparameter ("time-range", 'd', omitable = true);
166   parameterPrintSize->SetDefaultValue(-1);     << 193   parameter->SetDefaultValue(-1.);
167   fpCommandPrintSize->SetParameter(parameterPr << 194   fpCommandStartTime->SetParameter(parameter);
                                                   >> 195   parameter = new G4UIparameter ("time-range-unit", 's', omitable = true);
                                                   >> 196   parameter->SetDefaultValue("ns");
                                                   >> 197   fpCommandStartTime->SetParameter(parameter);
168                                                   198 
169   fpCommandTransparency =                         199   fpCommandTransparency =
170     new G4UIcmdWithABool("/vis/ogl/set/transpa    200     new G4UIcmdWithABool("/vis/ogl/set/transparency", this);
171   fpCommandTransparency->SetGuidance              201   fpCommandTransparency->SetGuidance
172     ("True/false to enable/disable rendering o    202     ("True/false to enable/disable rendering of transparent objects.");
173   fpCommandTransparency->SetParameterName         203   fpCommandTransparency->SetParameterName
174     ("transparency-enabled", omitable = true);    204     ("transparency-enabled", omitable = true);
175   fpCommandTransparency->SetDefaultValue(true)    205   fpCommandTransparency->SetDefaultValue(true);
176 }                                                 206 }
177                                                   207 
178 G4OpenGLViewerMessenger::~G4OpenGLViewerMessen    208 G4OpenGLViewerMessenger::~G4OpenGLViewerMessenger ()
179 {                                                 209 {
180   delete fpCommandTransparency;                << 
181   delete fpCommandPrintSize;                   << 
182   delete fpCommandPrintMode;                      210   delete fpCommandPrintMode;
183   delete fpCommandPrintFilename;               << 211   delete fpCommandTransparency;
184   delete fpCommandExportFormat;                << 212   delete fpCommandStartTime;
185   delete fpCommandDisplayListLimit;            << 213   delete fpCommandFade;
                                                   >> 214   delete fpCommandEndTime;
                                                   >> 215   delete fpCommandDisplayLightFront;
                                                   >> 216   delete fpCommandDisplayHeadTime;
186   delete fpDirectorySet;                          217   delete fpDirectorySet;
187   delete fpCommandFlushAt;                     << 218   delete fpCommandPrintEPS;
188   delete fpCommandExport;                      << 
189   delete fpDirectory;                             219   delete fpDirectory;
190                                                   220 
191   delete fpInstance;                              221   delete fpInstance;
192 }                                                 222 }
193                                                   223 
194 void G4OpenGLViewerMessenger::SetNewValue         224 void G4OpenGLViewerMessenger::SetNewValue
195 (G4UIcommand* command, G4String newValue)         225 (G4UIcommand* command, G4String newValue)
196 {                                                 226 {
197   G4VisManager* pVisManager = G4VisManager::Ge    227   G4VisManager* pVisManager = G4VisManager::GetInstance();
198                                                   228 
199   G4VViewer* pViewer = pVisManager->GetCurrent << 229   G4VViewer* pVViewer = pVisManager->GetCurrentViewer();
200   if (!pViewer) {                              << 230 
                                                   >> 231   if (!pVViewer) {
201     G4cout <<                                     232     G4cout <<
202       "G4OpenGLViewerMessenger::SetNewValue: N    233       "G4OpenGLViewerMessenger::SetNewValue: No current viewer."
203       "\n  \"/vis/open\", or similar, to get o    234       "\n  \"/vis/open\", or similar, to get one."
204            << G4endl;                             235            << G4endl;
205     return;                                       236     return;
206   }                                               237   }
207                                                   238 
208   G4VSceneHandler* pSceneHandler = pViewer->Ge << 239   G4OpenGLViewer* pOGLViewer = dynamic_cast<G4OpenGLViewer*>(pVViewer);
209   if (!pSceneHandler) {                        << 240 
210     G4cout <<                                  << 
211     "G4OpenGLViewerMessenger::SetNewValue: Thi << 
212     "\n  Shouldn't happen - please report circ << 
213     "\n  (Viewer is \"" << pViewer->GetName()  << 
214     "\n  Try \"/vis/open\", or similar, to get << 
215     << G4endl;                                 << 
216     return;                                    << 
217   }                                            << 
218                                                << 
219   G4OpenGLViewer* pOGLViewer = dynamic_cast<G4 << 
220   if (!pOGLViewer) {                              241   if (!pOGLViewer) {
221     G4cout <<                                     242     G4cout <<
222       "G4OpenGLViewerMessenger::SetNewValue: C    243       "G4OpenGLViewerMessenger::SetNewValue: Current viewer is not of type"
223       "\n  OGL.  (It is \""                    << 244       "\n  OGL.  Use \"/vis/viewer/select\" or \"/vis/open\"."
224      << pViewer->GetName() <<                  << 
225       "\".)\n  Use \"/vis/viewer/select\" or \ << 
226            << G4endl;                             245            << G4endl;
227     return;                                       246     return;
228   }                                               247   }
229                                                   248 
230   G4OpenGLSceneHandler* pOGLSceneHandler =     << 249   if (command == fpCommandPrintEPS) 
231   dynamic_cast<G4OpenGLSceneHandler*>(pSceneHa << 250     {
232   if (!pOGLSceneHandler) {                     << 251       // Keep copy of print_string to preserve Xm behaviour...
233     G4cout <<                                  << 252       char* tmp_string = new char[50];
234     "G4OpenGLViewerMessenger::SetNewValue: Cur << 253       strcpy (tmp_string, pOGLViewer->print_string);
235     "\n  OGL.  (Viewer is \"" << pViewer->GetN << 254       // Make new print string...
236     "\n  (Scene handler is \"" << pSceneHandle << 255       static G4int file_count = 0;
237     "\n  Use \"/vis/sceneHandler/list\" and \" << 256       std::ostringstream oss;
238     "\n  or \"/vis/open\"."                    << 257       oss << "G4OpenGL_" << file_count++ << ".eps";
239     << G4endl;                                 << 258       strcpy (pOGLViewer->print_string, oss.str().c_str());
240     return;                                    << 259       // Print eps file...
241   }                                            << 260       pOGLViewer->print();
242                                                << 261       // Restore print_string for Xm...
243   if (command == fpCommandExport)              << 262       strcpy (pOGLViewer->print_string, tmp_string);
244   {                                            << 263       delete tmp_string;
245     G4String name;                             << 264       return;
246     G4int width,height;                        << 265     }
247     std::istringstream iss(newValue);          << 
248     iss >> name >> width >> height;            << 
249     pOGLViewer->exportImage(name, width, heigh << 
250                                                << 
251     if (pOGLViewer->fVP.IsAutoRefresh())       << 
252       G4UImanager::GetUIpointer()->ApplyComman << 
253     return;                                    << 
254   }                                            << 
255                                                << 
256   if (command == fpCommandExportFormat)        << 
257   {                                            << 
258     G4String name;                             << 
259     std::istringstream iss(newValue);          << 
260     iss >> name;                               << 
261     pOGLViewer->setExportImageFormat(name);    << 
262                                                   266 
263     return;                                    << 267   G4OpenGLStoredViewer* pViewer =
264   }                                            << 268     dynamic_cast<G4OpenGLStoredViewer*>(pVViewer);
265                                                   269 
266   if (command == fpCommandFlushAt)             << 270   if (!pViewer) {
267   {                                            << 271     G4cout <<
268     static G4bool firstTime = true;            << 272   "G4OpenGLViewerMessenger::SetNewValue: Current viewer is not of type OGLS."
269     static std::map<G4String,G4OpenGLSceneHand << 273   "\n  The time slice viewing feature is only implemented for OGL Stored"
270     if (firstTime) {                           << 274   "\n  viewers at present.  Use \"/vis/viewer/select\" or \"/vis/open\"."
271       actionMap["endOfEvent"]    = G4OpenGLSce << 275            << G4endl;
272       actionMap["endOfRun"]      = G4OpenGLSce << 
273       actionMap["eachPrimitive"] = G4OpenGLSce << 
274       actionMap["NthPrimitive"]  = G4OpenGLSce << 
275       actionMap["NthEvent"]      = G4OpenGLSce << 
276       actionMap["never"]         = G4OpenGLSce << 
277       firstTime = false;                       << 
278     }                                          << 
279     G4String action;                           << 
280     G4int entitiesFlushInterval;               << 
281     std::istringstream iss(newValue);          << 
282     iss >> action >> entitiesFlushInterval;    << 
283     pOGLSceneHandler->SetFlushAction(actionMap << 
284     pOGLSceneHandler->SetEntitiesFlushInterval << 
285     return;                                       276     return;
286   }                                               277   }
287                                                   278 
288   if (command == fpCommandPrintFilename)       << 279   if (command == fpCommandDisplayHeadTime)
289     {                                             280     {
290       G4String name;                           << 281       G4String display;
291       G4bool inc;                              << 282       G4double screenX, screenY, screenSize, red, green, blue;
292       std::istringstream iss(newValue);           283       std::istringstream iss(newValue);
293       iss >> name                              << 284       iss >> display >> screenX >> screenY
294     >> inc;                                    << 285     >> screenSize >> red >> green >> blue;
295       pOGLViewer->setExportFilename(name,inc); << 286       pViewer->fDisplayHeadTime = command->ConvertToBool(display);
296       return;                                  << 287       pViewer->fDisplayHeadTimeX = screenX;
                                                   >> 288       pViewer->fDisplayHeadTimeY = screenY;
                                                   >> 289       pViewer->fDisplayHeadTimeSize = screenSize;
                                                   >> 290       pViewer->fDisplayHeadTimeRed = red;
                                                   >> 291       pViewer->fDisplayHeadTimeGreen = green;
                                                   >> 292       pViewer->fDisplayHeadTimeBlue = blue;
297     }                                             293     }
298                                                   294 
299   if (command == fpCommandPrintMode)           << 295   if (command == fpCommandDisplayLightFront)
300     {                                             296     {
301       if (newValue == "vectored") pOGLViewer-> << 297       G4String display, originX, originY, originZ, unitS, originT, unitT;
302                                                << 298       G4double red, green, blue;
303       if (newValue == "pixmap") pOGLViewer->fV << 299       std::istringstream iss(newValue);
304       return;                                  << 300       iss >> display
                                                   >> 301     >> originX >> originY >> originZ >> unitS
                                                   >> 302     >> originT >> unitT
                                                   >> 303     >> red >> green >> blue;
                                                   >> 304       pViewer->fDisplayLightFront = command->ConvertToBool(display);
                                                   >> 305       pViewer->fDisplayLightFrontX =
                                                   >> 306   command->ConvertToDimensionedDouble(G4String(originX + ' ' + unitS));
                                                   >> 307       pViewer->fDisplayLightFrontY =
                                                   >> 308   command->ConvertToDimensionedDouble(G4String(originY + ' ' + unitS));
                                                   >> 309       pViewer->fDisplayLightFrontZ =
                                                   >> 310   command->ConvertToDimensionedDouble(G4String(originZ + ' ' + unitS));
                                                   >> 311       pViewer->fDisplayLightFrontT =
                                                   >> 312   command->ConvertToDimensionedDouble(G4String(originT + ' ' + unitT));
                                                   >> 313       pViewer->fDisplayLightFrontRed = red;
                                                   >> 314       pViewer->fDisplayLightFrontGreen = green;
                                                   >> 315       pViewer->fDisplayLightFrontBlue = blue;
305     }                                             316     }
306                                                   317 
307   if (command == fpCommandPrintSize)           << 318   if (command == fpCommandEndTime)
308     {                                             319     {
309       G4int width,height;                      << 320       G4String end_time_string, end_time_unit,
                                                   >> 321   time_range_string, time_range_unit;
310       std::istringstream iss(newValue);           322       std::istringstream iss(newValue);
311       iss >> width                             << 323       iss >> end_time_string >> end_time_unit
312     >> height;                                 << 324     >> time_range_string >> time_range_unit;
313       pOGLViewer->setExportSize(width,height); << 325       pViewer->fEndTime = command->ConvertToDimensionedDouble
314       return;                                  << 326   (G4String(end_time_string + ' ' + end_time_unit));
                                                   >> 327       G4double timeRange = command->ConvertToDimensionedDouble
                                                   >> 328   (G4String(time_range_string + ' ' + time_range_unit));
                                                   >> 329       if (timeRange > 0.) {
                                                   >> 330   pViewer->fStartTime = pViewer->fEndTime - timeRange;
                                                   >> 331       }
                                                   >> 332       if (pViewer->fVP.IsAutoRefresh())
                                                   >> 333   G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
315     }                                             334     }
316                                                   335 
317   if (command == fpCommandTransparency)        << 336   if (command == fpCommandFade)
318     {                                             337     {
319       pOGLViewer->transparency_enabled = comma << 338       pViewer->fFadeFactor = command->ConvertToDouble(newValue);
320       if (pOGLViewer->fVP.IsAutoRefresh())     << 339       if (pViewer->fVP.IsAutoRefresh())
321   G4UImanager::GetUIpointer()->ApplyCommand("/ << 340   G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
322       return;                                  << 
323     }                                             341     }
324                                                   342 
325   // Stored viewer commands                    << 343   if (command == fpCommandPrintMode)
326   G4OpenGLStoredViewer* pOGLSViewer =          << 
327     dynamic_cast<G4OpenGLStoredViewer*>(pViewe << 
328                                                << 
329   if (!pOGLSViewer)                            << 
330     {                                             344     {
331       G4cout <<                                << 345       if (newValue == "vectored") pViewer->vectored_ps = true;
332   "G4OpenGLViewerMessenger::SetNewValue: Curre << 346       if (newValue == "pixmap") {
333   "\n  (It is \"" << pViewer->GetName() << "\" << 347   pViewer->vectored_ps = false;
334   "\n  This feature is only implemented for OG << 348   if (pVisManager->GetVerbosity() >= G4VisManager::warnings) {
335   "\n  Use \"/vis/viewer/select\" or \"/vis/op << 349     G4cout <<
336        << G4endl;                              << 350       "WARNING: Only implemented for X Windows at present."
337       return;                                  << 351      << G4endl;
                                                   >> 352   }
                                                   >> 353       }
338     }                                             354     }
339                                                   355 
340   // Scene handler commands                    << 356   if (command == fpCommandStartTime)
341   G4OpenGLStoredSceneHandler* pOGLSSceneHandle << 357     {
342     dynamic_cast<G4OpenGLStoredSceneHandler*>( << 358       G4String start_time_string, start_time_unit,
343                                                << 359   time_range_string, time_range_unit;
344   if (!pOGLSSceneHandler) {                    << 360       std::istringstream iss(newValue);
345     G4cout <<                                  << 361       iss >> start_time_string >> start_time_unit
346   "G4OpenGLViewerMessenger::SetNewValue: Curre << 362     >> time_range_string >> time_range_unit;
347   "\n  OGLS (Stored).  (Viewer is \"" << pView << 363       pViewer->fStartTime = command->ConvertToDimensionedDouble
348   "\n  (Scene handler is \"" << pSceneHandler- << 364   (G4String(start_time_string + ' ' + start_time_unit));
349   "\n  This feature is only implemented for OG << 365       G4double timeRange = command->ConvertToDimensionedDouble
350   "\n  scene handlers.  Use \"/vis/viewer/sele << 366   (G4String(time_range_string + ' ' + time_range_unit));
351            << G4endl;                          << 367       if (timeRange > 0.) {
352     return;                                    << 368   pViewer->fEndTime = pViewer->fStartTime + timeRange;
353   }                                            << 369       }
                                                   >> 370       if (pViewer->fVP.IsAutoRefresh())
                                                   >> 371   G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
                                                   >> 372     }
354                                                   373 
355   if (command == fpCommandDisplayListLimit)    << 374   if (command == fpCommandTransparency)
356     {                                             375     {
357       G4cerr << command->GetGuidanceLine(0) << << 376       pViewer->transparency_enabled = command->ConvertToBool(newValue);
358       return;                                  << 377       if (pViewer->fVP.IsAutoRefresh())
                                                   >> 378   G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
359     }                                             379     }
                                                   >> 380 
360 }                                                 381 }
361                                                   382