Geant4 Cross Reference |
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 101105 2016-11-07 08:09:26Z gcosmo $ >> 28 >> 29 #ifdef G4VIS_BUILD_OPENGL_DRIVER 27 30 28 #include "G4OpenGLViewerMessenger.hh" 31 #include "G4OpenGLViewerMessenger.hh" 29 32 30 #include "G4OpenGLViewer.hh" 33 #include "G4OpenGLViewer.hh" 31 #include "G4OpenGLStoredViewer.hh" 34 #include "G4OpenGLStoredViewer.hh" 32 #include "G4OpenGLStoredSceneHandler.hh" 35 #include "G4OpenGLStoredSceneHandler.hh" 33 #include "G4UImanager.hh" 36 #include "G4UImanager.hh" 34 #include "G4UIcommand.hh" 37 #include "G4UIcommand.hh" 35 #include "G4UIdirectory.hh" 38 #include "G4UIdirectory.hh" 36 #include "G4UIcmdWithoutParameter.hh" 39 #include "G4UIcmdWithoutParameter.hh" 37 #include "G4UIcmdWithADouble.hh" 40 #include "G4UIcmdWithADouble.hh" 38 #include "G4UIcmdWithABool.hh" 41 #include "G4UIcmdWithABool.hh" 39 #include "G4UIcmdWithAString.hh" 42 #include "G4UIcmdWithAString.hh" 40 #include "G4UIcmdWithAnInteger.hh" 43 #include "G4UIcmdWithAnInteger.hh" 41 #include "G4VisManager.hh" 44 #include "G4VisManager.hh" 42 #include <sstream> 45 #include <sstream> 43 46 44 G4OpenGLViewerMessenger* 47 G4OpenGLViewerMessenger* 45 G4OpenGLViewerMessenger::fpInstance = 0; 48 G4OpenGLViewerMessenger::fpInstance = 0; 46 49 47 G4OpenGLViewerMessenger* 50 G4OpenGLViewerMessenger* 48 G4OpenGLViewerMessenger::GetInstance() 51 G4OpenGLViewerMessenger::GetInstance() 49 { 52 { 50 if (!fpInstance) fpInstance = new G4OpenGLVi 53 if (!fpInstance) fpInstance = new G4OpenGLViewerMessenger; 51 return fpInstance; 54 return fpInstance; 52 } 55 } 53 56 54 G4OpenGLViewerMessenger::G4OpenGLViewerMesseng 57 G4OpenGLViewerMessenger::G4OpenGLViewerMessenger() 55 { 58 { 56 G4bool omitable; 59 G4bool omitable; 57 60 58 fpDirectory = new G4UIdirectory("/vis/ogl/") 61 fpDirectory = new G4UIdirectory("/vis/ogl/"); 59 fpDirectory->SetGuidance("G4OpenGLViewer com 62 fpDirectory->SetGuidance("G4OpenGLViewer commands."); 60 63 61 fpCommandExport = 64 fpCommandExport = 62 new G4UIcommand("/vis/ogl/export", this); 65 new G4UIcommand("/vis/ogl/export", this); 63 fpCommandExport->SetGuidance ("Export a scre << 66 fpCommandExport->SetGuidance ("export a screenshot of current OpenGL viewer"); 64 fpCommandExport->SetGuidance << 67 fpCommandExport->SetGuidance ("If name is \"\", filename and extension will have the default value"); 65 ("If name is \"\", filename and extension wi << 68 fpCommandExport->SetGuidance ("If name is \"toto.png\", set the name to \"toto\" and the format to \"png\". No incremented suffix is added."); 66 fpCommandExport->SetGuidance << 69 fpCommandExport->SetGuidance ("If name is \"toto\", set the name to \"toto\" and the format to default (or current format if specify). Will also add an incremented suffix at the end of the file, except if name is the same as previous it will not reset incremented suffix."); 67 ("If name is \"toto.png\", set the name to \ << 70 fpCommandExport->SetGuidance ("Setting size is available only on eps/pdf/svg/ps formats"); 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; 71 G4UIparameter* parameterExport; 76 parameterExport = new G4UIparameter ("name", 72 parameterExport = new G4UIparameter ("name", 's', omitable = true); 77 parameterExport->SetDefaultValue("!"); 73 parameterExport->SetDefaultValue("!"); 78 parameterExport->SetGuidance << 74 parameterExport->SetGuidance("by default, will take a default value or the last /vis/ogl/set/printFilename value if set"); 79 ("By default, will take a default value or t << 80 " value if set."); << 81 fpCommandExport->SetParameter(parameterExpor 75 fpCommandExport->SetParameter(parameterExport); 82 parameterExport = new G4UIparameter ("width" 76 parameterExport = new G4UIparameter ("width", 'd', omitable = true); 83 parameterExport->SetGuidance << 77 parameterExport->SetGuidance("By default, will take the current width of the viewer or /vis/ogl/set/printSize if set"); 84 ("By default, will take the current width of << 78 parameterExport->SetGuidance("This parameter is only useful for eps/pdf/svg/ps formats !"); 85 "\nif set. This parameter is only useful fo << 86 parameterExport->SetDefaultValue(-1); 79 parameterExport->SetDefaultValue(-1); 87 fpCommandExport->SetParameter(parameterExpor 80 fpCommandExport->SetParameter(parameterExport); 88 parameterExport = new G4UIparameter ("height 81 parameterExport = new G4UIparameter ("height", 'd', omitable = true); 89 parameterExport->SetGuidance << 82 parameterExport->SetGuidance("By default, will take the current height of the viewer or /vis/ogl/set/printSize if set"); 90 ("By default, will take the current height o << 83 parameterExport->SetGuidance("This parameter is only useful for eps/pdf/svg/ps formats !"); 91 "\nif set. This parameter is only useful fo << 92 parameterExport->SetDefaultValue(-1); 84 parameterExport->SetDefaultValue(-1); 93 fpCommandExport->SetParameter(parameterExpor 85 fpCommandExport->SetParameter(parameterExport); 94 86 95 fpCommandFlushAt = new G4UIcommand("/vis/ogl 87 fpCommandFlushAt = new G4UIcommand("/vis/ogl/flushAt", this); 96 fpCommandFlushAt->SetGuidance 88 fpCommandFlushAt->SetGuidance 97 ("Controls the rate at which graphics primit 89 ("Controls the rate at which graphics primitives are flushed to screen."); 98 fpCommandFlushAt->SetGuidance 90 fpCommandFlushAt->SetGuidance 99 ("Flushing to screen is an expensive operati 91 ("Flushing to screen is an expensive operation so to speed drawing choose" 100 "\nan action suitable for your application. 92 "\nan action suitable for your application. Note that detectors are flushed" 101 "\nto screen anyway at end of drawing, and 93 "\nto screen anyway at end of drawing, and events are flushed to screen" 102 "\nanyway depending on /vis/scene/endOfEven 94 "\nanyway depending on /vis/scene/endOfEventAction and endOfRunAction."); 103 fpCommandFlushAt->SetGuidance 95 fpCommandFlushAt->SetGuidance 104 ("For NthPrimitive and NthEvent the second p 96 ("For NthPrimitive and NthEvent the second parameter N is operative."); 105 fpCommandFlushAt->SetGuidance 97 fpCommandFlushAt->SetGuidance 106 ("For \"never\", detectors and events are st 98 ("For \"never\", detectors and events are still flushed as described above."); 107 G4UIparameter* parameterFlushAt; 99 G4UIparameter* parameterFlushAt; 108 parameterFlushAt = new G4UIparameter ("actio 100 parameterFlushAt = new G4UIparameter ("action", 's', omitable = true); 109 parameterFlushAt->SetParameterCandidates 101 parameterFlushAt->SetParameterCandidates 110 ("endOfEvent endOfRun eachPrimitive NthPrimi 102 ("endOfEvent endOfRun eachPrimitive NthPrimitive NthEvent never"); 111 parameterFlushAt->SetDefaultValue("NthEvent" 103 parameterFlushAt->SetDefaultValue("NthEvent"); 112 fpCommandFlushAt->SetParameter(parameterFlus 104 fpCommandFlushAt->SetParameter(parameterFlushAt); 113 parameterFlushAt = new G4UIparameter ("N", ' 105 parameterFlushAt = new G4UIparameter ("N", 'i', omitable = true); 114 parameterFlushAt->SetDefaultValue(100); 106 parameterFlushAt->SetDefaultValue(100); 115 fpCommandFlushAt->SetParameter(parameterFlus 107 fpCommandFlushAt->SetParameter(parameterFlushAt); 116 108 >> 109 fpCommandPrintEPS = >> 110 new G4UIcmdWithoutParameter("/vis/ogl/printEPS", this); >> 111 fpCommandPrintEPS->SetGuidance("Print Encapsulated PostScript file."); >> 112 fpCommandPrintEPS->SetGuidance >> 113 ("Generates files with names G4OpenGL_n.eps, where n is a sequence" >> 114 "\nnumber, starting at 0." >> 115 "\nCan be \"vectored\" or \"pixmap\" - see \"/vis/ogl/set/printMode\"."); >> 116 117 fpDirectorySet = new G4UIdirectory ("/vis/og 117 fpDirectorySet = new G4UIdirectory ("/vis/ogl/set/"); 118 fpDirectorySet->SetGuidance("G4OpenGLViewer 118 fpDirectorySet->SetGuidance("G4OpenGLViewer set commands."); 119 119 >> 120 G4UIparameter* parameter; >> 121 >> 122 fpCommandDisplayHeadTime = >> 123 new G4UIcommand("/vis/ogl/set/displayHeadTime", this); >> 124 fpCommandDisplayHeadTime->SetGuidance >> 125 ("Display head time of range in 2D text."); >> 126 parameter = new G4UIparameter ("displayHeadTime", 'b', omitable = false); >> 127 parameter->SetDefaultValue(false); >> 128 fpCommandDisplayHeadTime->SetParameter(parameter); >> 129 parameter = new G4UIparameter ("screenX", 'd', omitable = true); >> 130 parameter->SetGuidance("-1 < screenX < 1"); >> 131 parameter->SetParameterRange("screenX >= -1. && screenX <= 1."); >> 132 parameter->SetDefaultValue(-0.9); >> 133 fpCommandDisplayHeadTime->SetParameter(parameter); >> 134 parameter = new G4UIparameter ("screenY", 'd', omitable = true); >> 135 parameter->SetGuidance("-1 < screenY < 1"); >> 136 parameter->SetParameterRange("screenY >= -1. && screenY <= 1."); >> 137 parameter->SetDefaultValue(-0.9); >> 138 fpCommandDisplayHeadTime->SetParameter(parameter); >> 139 parameter = new G4UIparameter ("screenSize", 'd', omitable = true); >> 140 parameter->SetDefaultValue(24.); >> 141 fpCommandDisplayHeadTime->SetParameter(parameter); >> 142 parameter = new G4UIparameter ("red", 'd', omitable = true); >> 143 parameter->SetParameterRange("red >= 0. && red <= 1."); >> 144 parameter->SetDefaultValue(0.); >> 145 fpCommandDisplayHeadTime->SetParameter(parameter); >> 146 parameter = new G4UIparameter ("green", 'd', omitable = true); >> 147 parameter->SetParameterRange("green >= 0. && green <= 1."); >> 148 parameter->SetDefaultValue(1.); >> 149 fpCommandDisplayHeadTime->SetParameter(parameter); >> 150 parameter = new G4UIparameter ("blue", 'd', omitable = true); >> 151 parameter->SetParameterRange("blue >= 0. && blue <= 1."); >> 152 parameter->SetDefaultValue(1.); >> 153 fpCommandDisplayHeadTime->SetParameter(parameter); >> 154 >> 155 fpCommandDisplayLightFront = >> 156 new G4UIcommand("/vis/ogl/set/displayLightFront", this); >> 157 fpCommandDisplayLightFront->SetGuidance >> 158 ("Display the light front at head time."); >> 159 fpCommandDisplayLightFront->SetGuidance >> 160 ("Tip: The trajectories can appear of jump ahead of the light front" >> 161 "\nbecause their time range overlaps the viewer's time range. To" >> 162 "\naverage out this discrete time effect, advance the light front by" >> 163 "\nhalf the trajectories interval. E.g., if the trajectory time slice" >> 164 "\ninterval is 0.01 ns:" >> 165 "\n /vis/ogl/set/displayLightFront true -90 0 0 mm -0.005 ns" >> 166 "\nTo prevent them beating the light front at all:" >> 167 "\n /vis/ogl/set/displayLightFront true -90 0 0 mm -0.01 ns"); >> 168 parameter = new G4UIparameter ("displayLightFront", 'b', omitable = false); >> 169 parameter->SetDefaultValue(false); >> 170 fpCommandDisplayLightFront->SetParameter(parameter); >> 171 parameter = new G4UIparameter ("originX", 'd', omitable = true); >> 172 parameter->SetDefaultValue(0.); >> 173 fpCommandDisplayLightFront->SetParameter(parameter); >> 174 parameter = new G4UIparameter ("originY", 'd', omitable = true); >> 175 parameter->SetDefaultValue(0.); >> 176 fpCommandDisplayLightFront->SetParameter(parameter); >> 177 parameter = new G4UIparameter ("originZ", 'd', omitable = true); >> 178 parameter->SetDefaultValue(0.); >> 179 fpCommandDisplayLightFront->SetParameter(parameter); >> 180 parameter = new G4UIparameter ("space_unit", 's', omitable = true); >> 181 parameter->SetDefaultValue("m"); >> 182 fpCommandDisplayLightFront->SetParameter(parameter); >> 183 parameter = new G4UIparameter ("originT", 'd', omitable = true); >> 184 parameter->SetDefaultValue(0.); >> 185 fpCommandDisplayLightFront->SetParameter(parameter); >> 186 parameter = new G4UIparameter ("time_unit", 's', omitable = true); >> 187 parameter->SetDefaultValue("s"); >> 188 fpCommandDisplayLightFront->SetParameter(parameter); >> 189 parameter = new G4UIparameter ("red", 'd', omitable = true); >> 190 parameter->SetParameterRange("red >= 0. && red <= 1."); >> 191 parameter->SetDefaultValue(0.); >> 192 fpCommandDisplayLightFront->SetParameter(parameter); >> 193 parameter = new G4UIparameter ("green", 'd', omitable = true); >> 194 parameter->SetParameterRange("green >= 0. && green <= 1."); >> 195 parameter->SetDefaultValue(1.); >> 196 fpCommandDisplayLightFront->SetParameter(parameter); >> 197 parameter = new G4UIparameter ("blue", 'd', omitable = true); >> 198 parameter->SetParameterRange("blue >= 0. && blue <= 1."); >> 199 parameter->SetDefaultValue(0.); >> 200 fpCommandDisplayLightFront->SetParameter(parameter); >> 201 120 fpCommandDisplayListLimit = 202 fpCommandDisplayListLimit = 121 new G4UIcmdWithoutParameter("/vis/ogl/set/ << 203 new G4UIcmdWithAnInteger("/vis/ogl/set/displayListLimit", this); 122 fpCommandDisplayListLimit->SetGuidance 204 fpCommandDisplayListLimit->SetGuidance 123 ("This command is no longer relevant. There << 205 ("Set/reset display list limit (to avoid memory exhaustion)."); 124 "\nnumber of display lists - except, of cou << 206 fpCommandDisplayListLimit->SetParameterName("limit", omitable = true); 125 "\nyour computer. Keep an eye on that. Good << 207 fpCommandDisplayListLimit->SetDefaultValue(50000); 126 << 208 fpCommandDisplayListLimit->SetRange("limit>=10000"); 127 fpCommandExportFormat = << 209 128 new G4UIcommand("/vis/ogl/set/exportFormat", << 210 fpCommandEndTime = 129 fpCommandExportFormat->SetGuidance ("Set exp << 211 new G4UIcommand("/vis/ogl/set/endTime", this); 130 fpCommandExportFormat->SetGuidance ("By defa << 212 fpCommandEndTime->SetGuidance("Set end and range of track time."); 131 fpCommandExportFormat->SetGuidance ("Try /vi << 213 parameter = new G4UIparameter ("end-time", 'd', omitable = false); 132 fpCommandExportFormat->SetGuidance ("Changin << 214 parameter->SetDefaultValue(DBL_MAX); 133 G4UIparameter* parameterExportFormat; << 215 fpCommandEndTime->SetParameter(parameter); 134 parameterExportFormat = new G4UIparameter (" << 216 parameter = new G4UIparameter ("end-time-unit", 's', omitable = false); 135 parameterExportFormat->SetDefaultValue(""); << 217 parameter->SetDefaultValue("ns"); 136 fpCommandExportFormat->SetParameter(paramete << 218 fpCommandEndTime->SetParameter(parameter); >> 219 parameter = new G4UIparameter ("time-range", 'd', omitable = true); >> 220 parameter->SetDefaultValue(-1.); >> 221 fpCommandEndTime->SetParameter(parameter); >> 222 parameter = new G4UIparameter ("time-range-unit", 's', omitable = true); >> 223 parameter->SetDefaultValue("ns"); >> 224 fpCommandEndTime->SetParameter(parameter); >> 225 >> 226 fpCommandEventsDrawInterval = >> 227 new G4UIcmdWithAnInteger("/vis/ogl/set/eventsDrawInterval", this); >> 228 fpCommandEventsDrawInterval->SetGuidance >> 229 ("Deprecated. Use /vis/ogl/flushAt."); >> 230 fpCommandEventsDrawInterval->SetGuidance >> 231 ("(This is equivalent to \"/vis/ogl/flushAt NthPrimitive N\""); >> 232 fpCommandEventsDrawInterval->SetParameterName("N", omitable = true); >> 233 fpCommandEventsDrawInterval->SetDefaultValue(1); >> 234 >> 235 fpCommandFade = new G4UIcmdWithADouble("/vis/ogl/set/fade", this); >> 236 fpCommandFade->SetGuidance >> 237 ("0: no fade; 1: maximum fade with time within range."); >> 238 fpCommandFade->SetParameterName("fadefactor", omitable = false); >> 239 fpCommandFade->SetRange("fadefactor>=0.&&fadefactor<=1."); >> 240 fpCommandFade->SetDefaultValue(0.); 137 241 138 fpCommandPrintFilename = 242 fpCommandPrintFilename = 139 new G4UIcommand("/vis/ogl/set/printFilenam 243 new G4UIcommand("/vis/ogl/set/printFilename", this); 140 fpCommandPrintFilename->SetGuidance ("Set pr 244 fpCommandPrintFilename->SetGuidance ("Set print filename"); 141 fpCommandPrintFilename->SetGuidance ("Settin 245 fpCommandPrintFilename->SetGuidance ("Setting 'incremental' will increment filename by one at each new print, starting at 0"); 142 G4UIparameter* parameterPrintFilename; 246 G4UIparameter* parameterPrintFilename; 143 parameterPrintFilename = new G4UIparameter ( 247 parameterPrintFilename = new G4UIparameter ("name", 's', omitable = true); 144 parameterPrintFilename->SetDefaultValue("G4O 248 parameterPrintFilename->SetDefaultValue("G4OpenGL"); 145 fpCommandPrintFilename->SetParameter(paramet 249 fpCommandPrintFilename->SetParameter(parameterPrintFilename); 146 parameterPrintFilename = new G4UIparameter ( 250 parameterPrintFilename = new G4UIparameter ("incremental", 'b', omitable = true); 147 parameterPrintFilename->SetDefaultValue(1); 251 parameterPrintFilename->SetDefaultValue(1); 148 fpCommandPrintFilename->SetParameter(paramet 252 fpCommandPrintFilename->SetParameter(parameterPrintFilename); 149 253 150 fpCommandPrintMode = new G4UIcmdWithAString( << 254 fpCommandExportFormat = >> 255 new G4UIcommand("/vis/ogl/set/exportFormat", this); >> 256 fpCommandExportFormat->SetGuidance ("Set export format"); >> 257 fpCommandExportFormat->SetGuidance ("By default, pdf/eps/svg/ps are available. Depending of viewers several other format are available."); >> 258 fpCommandExportFormat->SetGuidance ("Try /vis/ogl/set/exportFormat without parameters to see them."); >> 259 fpCommandExportFormat->SetGuidance ("Changing format will reset the incremental suffix to 0."); >> 260 G4UIparameter* parameterExportFormat; >> 261 parameterExportFormat = new G4UIparameter ("format", 's', omitable = true); >> 262 parameterExportFormat->SetDefaultValue(""); >> 263 fpCommandExportFormat->SetParameter(parameterExportFormat); >> 264 >> 265 fpCommandPrintMode = new G4UIcmdWithAString >> 266 ("/vis/ogl/set/printMode",this); 151 fpCommandPrintMode->SetGuidance("Set print m 267 fpCommandPrintMode->SetGuidance("Set print mode, only available for \"ps\" format"); 152 fpCommandPrintMode->SetParameterName("print_ 268 fpCommandPrintMode->SetParameterName("print_mode",omitable = true); 153 fpCommandPrintMode->SetCandidates("vectored 269 fpCommandPrintMode->SetCandidates("vectored pixmap"); 154 fpCommandPrintMode->SetDefaultValue("vectore 270 fpCommandPrintMode->SetDefaultValue("vectored"); 155 271 156 fpCommandPrintSize = 272 fpCommandPrintSize = 157 new G4UIcommand("/vis/ogl/set/printSize", 273 new G4UIcommand("/vis/ogl/set/printSize", this); 158 fpCommandPrintSize->SetGuidance ("Set print 274 fpCommandPrintSize->SetGuidance ("Set print size"); 159 fpCommandPrintSize->SetGuidance ("Tip : -1 w 275 fpCommandPrintSize->SetGuidance ("Tip : -1 will mean 'print size' = 'window size'"); 160 fpCommandPrintSize->SetGuidance (" Set << 276 fpCommandPrintSize->SetGuidance (" Setting size greatter than your maximum graphic card capacity , will set the size to maximum size."); 161 G4UIparameter* parameterPrintSize; 277 G4UIparameter* parameterPrintSize; 162 parameterPrintSize = new G4UIparameter ("wid 278 parameterPrintSize = new G4UIparameter ("width", 'd', omitable = false); 163 parameterPrintSize->SetDefaultValue(-1); 279 parameterPrintSize->SetDefaultValue(-1); 164 fpCommandPrintSize->SetParameter(parameterPr 280 fpCommandPrintSize->SetParameter(parameterPrintSize); 165 parameterPrintSize = new G4UIparameter ("hei 281 parameterPrintSize = new G4UIparameter ("height", 'd', omitable = false); 166 parameterPrintSize->SetDefaultValue(-1); 282 parameterPrintSize->SetDefaultValue(-1); 167 fpCommandPrintSize->SetParameter(parameterPr 283 fpCommandPrintSize->SetParameter(parameterPrintSize); 168 284 >> 285 fpCommandStartTime = >> 286 new G4UIcommand("/vis/ogl/set/startTime", this); >> 287 fpCommandStartTime->SetGuidance("Set start and range of track time."); >> 288 parameter = new G4UIparameter ("start-time", 'd', omitable = false); >> 289 parameter->SetDefaultValue(-DBL_MAX); >> 290 fpCommandStartTime->SetParameter(parameter); >> 291 parameter = new G4UIparameter ("start-time-unit", 's', omitable = false); >> 292 parameter->SetDefaultValue("ns"); >> 293 fpCommandStartTime->SetParameter(parameter); >> 294 parameter = new G4UIparameter ("time-range", 'd', omitable = true); >> 295 parameter->SetDefaultValue(-1.); >> 296 fpCommandStartTime->SetParameter(parameter); >> 297 parameter = new G4UIparameter ("time-range-unit", 's', omitable = true); >> 298 parameter->SetDefaultValue("ns"); >> 299 fpCommandStartTime->SetParameter(parameter); >> 300 169 fpCommandTransparency = 301 fpCommandTransparency = 170 new G4UIcmdWithABool("/vis/ogl/set/transpa 302 new G4UIcmdWithABool("/vis/ogl/set/transparency", this); 171 fpCommandTransparency->SetGuidance 303 fpCommandTransparency->SetGuidance 172 ("True/false to enable/disable rendering o 304 ("True/false to enable/disable rendering of transparent objects."); 173 fpCommandTransparency->SetParameterName 305 fpCommandTransparency->SetParameterName 174 ("transparency-enabled", omitable = true); 306 ("transparency-enabled", omitable = true); 175 fpCommandTransparency->SetDefaultValue(true) 307 fpCommandTransparency->SetDefaultValue(true); 176 } 308 } 177 309 178 G4OpenGLViewerMessenger::~G4OpenGLViewerMessen 310 G4OpenGLViewerMessenger::~G4OpenGLViewerMessenger () 179 { 311 { 180 delete fpCommandTransparency; 312 delete fpCommandTransparency; >> 313 delete fpCommandStartTime; 181 delete fpCommandPrintSize; 314 delete fpCommandPrintSize; 182 delete fpCommandPrintMode; 315 delete fpCommandPrintMode; 183 delete fpCommandPrintFilename; 316 delete fpCommandPrintFilename; >> 317 delete fpCommandFade; 184 delete fpCommandExportFormat; 318 delete fpCommandExportFormat; >> 319 delete fpCommandEventsDrawInterval; >> 320 delete fpCommandEndTime; 185 delete fpCommandDisplayListLimit; 321 delete fpCommandDisplayListLimit; >> 322 delete fpCommandDisplayLightFront; >> 323 delete fpCommandDisplayHeadTime; 186 delete fpDirectorySet; 324 delete fpDirectorySet; >> 325 delete fpCommandPrintEPS; 187 delete fpCommandFlushAt; 326 delete fpCommandFlushAt; 188 delete fpCommandExport; 327 delete fpCommandExport; 189 delete fpDirectory; 328 delete fpDirectory; 190 329 191 delete fpInstance; 330 delete fpInstance; 192 } 331 } 193 332 194 void G4OpenGLViewerMessenger::SetNewValue 333 void G4OpenGLViewerMessenger::SetNewValue 195 (G4UIcommand* command, G4String newValue) 334 (G4UIcommand* command, G4String newValue) 196 { 335 { 197 G4VisManager* pVisManager = G4VisManager::Ge 336 G4VisManager* pVisManager = G4VisManager::GetInstance(); 198 337 199 G4VViewer* pViewer = pVisManager->GetCurrent 338 G4VViewer* pViewer = pVisManager->GetCurrentViewer(); 200 if (!pViewer) { 339 if (!pViewer) { 201 G4cout << 340 G4cout << 202 "G4OpenGLViewerMessenger::SetNewValue: N 341 "G4OpenGLViewerMessenger::SetNewValue: No current viewer." 203 "\n \"/vis/open\", or similar, to get o 342 "\n \"/vis/open\", or similar, to get one." 204 << G4endl; 343 << G4endl; 205 return; 344 return; 206 } 345 } 207 346 208 G4VSceneHandler* pSceneHandler = pViewer->Ge 347 G4VSceneHandler* pSceneHandler = pViewer->GetSceneHandler(); 209 if (!pSceneHandler) { 348 if (!pSceneHandler) { 210 G4cout << 349 G4cout << 211 "G4OpenGLViewerMessenger::SetNewValue: Thi 350 "G4OpenGLViewerMessenger::SetNewValue: This viewer has no scene handler." 212 "\n Shouldn't happen - please report circ 351 "\n Shouldn't happen - please report circumstances." 213 "\n (Viewer is \"" << pViewer->GetName() 352 "\n (Viewer is \"" << pViewer->GetName() << "\".)" 214 "\n Try \"/vis/open\", or similar, to get 353 "\n Try \"/vis/open\", or similar, to get one." 215 << G4endl; 354 << G4endl; 216 return; 355 return; 217 } 356 } 218 357 219 G4OpenGLViewer* pOGLViewer = dynamic_cast<G4 358 G4OpenGLViewer* pOGLViewer = dynamic_cast<G4OpenGLViewer*>(pViewer); 220 if (!pOGLViewer) { 359 if (!pOGLViewer) { 221 G4cout << 360 G4cout << 222 "G4OpenGLViewerMessenger::SetNewValue: C 361 "G4OpenGLViewerMessenger::SetNewValue: Current viewer is not of type" 223 "\n OGL. (It is \"" 362 "\n OGL. (It is \"" 224 << pViewer->GetName() << 363 << pViewer->GetName() << 225 "\".)\n Use \"/vis/viewer/select\" or \ 364 "\".)\n Use \"/vis/viewer/select\" or \"/vis/open\"." 226 << G4endl; 365 << G4endl; 227 return; 366 return; 228 } 367 } 229 368 230 G4OpenGLSceneHandler* pOGLSceneHandler = 369 G4OpenGLSceneHandler* pOGLSceneHandler = 231 dynamic_cast<G4OpenGLSceneHandler*>(pSceneHa 370 dynamic_cast<G4OpenGLSceneHandler*>(pSceneHandler); 232 if (!pOGLSceneHandler) { 371 if (!pOGLSceneHandler) { 233 G4cout << 372 G4cout << 234 "G4OpenGLViewerMessenger::SetNewValue: Cur 373 "G4OpenGLViewerMessenger::SetNewValue: Current scene handler is not of type" 235 "\n OGL. (Viewer is \"" << pViewer->GetN 374 "\n OGL. (Viewer is \"" << pViewer->GetName() << "\".)" 236 "\n (Scene handler is \"" << pSceneHandle 375 "\n (Scene handler is \"" << pSceneHandler->GetName() << "\".)" 237 "\n Use \"/vis/sceneHandler/list\" and \" 376 "\n Use \"/vis/sceneHandler/list\" and \"/vis/sceneHandler/select\"" 238 "\n or \"/vis/open\"." 377 "\n or \"/vis/open\"." 239 << G4endl; 378 << G4endl; 240 return; 379 return; 241 } 380 } 242 << 381 243 if (command == fpCommandExport) << 382 if (command == fpCommandPrintEPS) 244 { 383 { 245 G4String name; << 384 pOGLViewer->setExportImageFormat("eps",true); 246 G4int width,height; << 385 pOGLViewer->exportImage(); 247 std::istringstream iss(newValue); << 248 iss >> name >> width >> height; << 249 pOGLViewer->exportImage(name, width, heigh << 250 386 251 if (pOGLViewer->fVP.IsAutoRefresh()) 387 if (pOGLViewer->fVP.IsAutoRefresh()) 252 G4UImanager::GetUIpointer()->ApplyComman 388 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh"); 253 return; 389 return; 254 } 390 } 255 391 256 if (command == fpCommandExportFormat) 392 if (command == fpCommandExportFormat) 257 { 393 { 258 G4String name; 394 G4String name; 259 std::istringstream iss(newValue); 395 std::istringstream iss(newValue); 260 iss >> name; 396 iss >> name; 261 pOGLViewer->setExportImageFormat(name); 397 pOGLViewer->setExportImageFormat(name); 262 << 398 263 return; 399 return; 264 } 400 } 265 << 401 266 if (command == fpCommandFlushAt) << 402 if (command == fpCommandExport) 267 { 403 { 268 static G4bool firstTime = true; << 404 G4String name; 269 static std::map<G4String,G4OpenGLSceneHand << 405 G4int width,height; 270 if (firstTime) { << 271 actionMap["endOfEvent"] = G4OpenGLSce << 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); 406 std::istringstream iss(newValue); 282 iss >> action >> entitiesFlushInterval; << 407 iss >> name >> width >> height; 283 pOGLSceneHandler->SetFlushAction(actionMap << 408 pOGLViewer->exportImage(name, width, height); 284 pOGLSceneHandler->SetEntitiesFlushInterval << 409 >> 410 if (pOGLViewer->fVP.IsAutoRefresh()) >> 411 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh"); 285 return; 412 return; 286 } 413 } >> 414 >> 415 if (command == fpCommandPrintSize) >> 416 { >> 417 G4int width,height; >> 418 std::istringstream iss(newValue); >> 419 iss >> width >> 420 >> height; >> 421 pOGLViewer->setExportSize(width,height); >> 422 return; >> 423 } 287 424 288 if (command == fpCommandPrintFilename) << 425 if (command == fpCommandPrintFilename) 289 { 426 { 290 G4String name; 427 G4String name; 291 G4bool inc; 428 G4bool inc; 292 std::istringstream iss(newValue); 429 std::istringstream iss(newValue); 293 iss >> name 430 iss >> name 294 >> inc; << 431 >> inc; 295 pOGLViewer->setExportFilename(name,inc); 432 pOGLViewer->setExportFilename(name,inc); 296 return; 433 return; 297 } 434 } 298 435 299 if (command == fpCommandPrintMode) 436 if (command == fpCommandPrintMode) 300 { 437 { 301 if (newValue == "vectored") pOGLViewer-> 438 if (newValue == "vectored") pOGLViewer->fVectoredPs = true; 302 << 303 if (newValue == "pixmap") pOGLViewer->fV 439 if (newValue == "pixmap") pOGLViewer->fVectoredPs = false; 304 return; 440 return; 305 } 441 } 306 442 307 if (command == fpCommandPrintSize) << 308 { << 309 G4int width,height; << 310 std::istringstream iss(newValue); << 311 iss >> width << 312 >> height; << 313 pOGLViewer->setExportSize(width,height); << 314 return; << 315 } << 316 << 317 if (command == fpCommandTransparency) 443 if (command == fpCommandTransparency) 318 { 444 { 319 pOGLViewer->transparency_enabled = comma 445 pOGLViewer->transparency_enabled = command->ConvertToBool(newValue); 320 if (pOGLViewer->fVP.IsAutoRefresh()) 446 if (pOGLViewer->fVP.IsAutoRefresh()) 321 G4UImanager::GetUIpointer()->ApplyCommand("/ << 447 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh"); 322 return; 448 return; 323 } 449 } 324 450 325 // Stored viewer commands << 451 if (command == fpCommandEventsDrawInterval) >> 452 { >> 453 G4int entitiesFlushInterval = >> 454 fpCommandEventsDrawInterval->GetNewIntValue(newValue); >> 455 pOGLSceneHandler->SetFlushAction(G4OpenGLSceneHandler::NthPrimitive); >> 456 pOGLSceneHandler->SetEntitiesFlushInterval(entitiesFlushInterval); >> 457 return; >> 458 } >> 459 >> 460 if (command == fpCommandFlushAt) >> 461 { >> 462 // G4bool firstTime = true; >> 463 std::map<G4String,G4OpenGLSceneHandler::FlushAction> actionMap; >> 464 // if (firstTime) { >> 465 actionMap["endOfEvent"] = G4OpenGLSceneHandler::endOfEvent; >> 466 actionMap["endOfRun"] = G4OpenGLSceneHandler::endOfRun; >> 467 actionMap["eachPrimitive"] = G4OpenGLSceneHandler::eachPrimitive; >> 468 actionMap["NthPrimitive"] = G4OpenGLSceneHandler::NthPrimitive; >> 469 actionMap["NthEvent"] = G4OpenGLSceneHandler::NthEvent; >> 470 actionMap["never"] = G4OpenGLSceneHandler::never; >> 471 // firstTime = false; >> 472 // } >> 473 G4String action; >> 474 G4int entitiesFlushInterval; >> 475 std::istringstream iss(newValue); >> 476 iss >> action >> entitiesFlushInterval; >> 477 pOGLSceneHandler->SetFlushAction(actionMap[action]); >> 478 pOGLSceneHandler->SetEntitiesFlushInterval(entitiesFlushInterval); >> 479 return; >> 480 } >> 481 326 G4OpenGLStoredViewer* pOGLSViewer = 482 G4OpenGLStoredViewer* pOGLSViewer = 327 dynamic_cast<G4OpenGLStoredViewer*>(pViewe 483 dynamic_cast<G4OpenGLStoredViewer*>(pViewer); 328 484 329 if (!pOGLSViewer) 485 if (!pOGLSViewer) 330 { 486 { 331 G4cout << 487 G4cout << 332 "G4OpenGLViewerMessenger::SetNewValue: Curre 488 "G4OpenGLViewerMessenger::SetNewValue: Current viewer is not of type OGLS." 333 "\n (It is \"" << pViewer->GetName() << "\" 489 "\n (It is \"" << pViewer->GetName() << "\".)" 334 "\n This feature is only implemented for OG 490 "\n This feature is only implemented for OGL Stored viewers." 335 "\n Use \"/vis/viewer/select\" or \"/vis/op 491 "\n Use \"/vis/viewer/select\" or \"/vis/open OGLS...\"." 336 << G4endl; 492 << G4endl; 337 return; 493 return; 338 } 494 } 339 495 340 // Scene handler commands << 496 if (command == fpCommandDisplayHeadTime) >> 497 { >> 498 G4String display; >> 499 G4double screenX, screenY, screenSize, red, green, blue; >> 500 std::istringstream iss(newValue); >> 501 iss >> display >> screenX >> screenY >> 502 >> screenSize >> red >> green >> blue; >> 503 pOGLSViewer->fDisplayHeadTime = command->ConvertToBool(display); >> 504 pOGLSViewer->fDisplayHeadTimeX = screenX; >> 505 pOGLSViewer->fDisplayHeadTimeY = screenY; >> 506 pOGLSViewer->fDisplayHeadTimeSize = screenSize; >> 507 pOGLSViewer->fDisplayHeadTimeRed = red; >> 508 pOGLSViewer->fDisplayHeadTimeGreen = green; >> 509 pOGLSViewer->fDisplayHeadTimeBlue = blue; >> 510 return; >> 511 } >> 512 >> 513 if (command == fpCommandDisplayLightFront) >> 514 { >> 515 G4String display, originX, originY, originZ, unitS, originT, unitT; >> 516 G4double red, green, blue; >> 517 std::istringstream iss(newValue); >> 518 iss >> display >> 519 >> originX >> originY >> originZ >> unitS >> 520 >> originT >> unitT >> 521 >> red >> green >> blue; >> 522 pOGLSViewer->fDisplayLightFront = command->ConvertToBool(display); >> 523 pOGLSViewer->fDisplayLightFrontX = >> 524 command->ConvertToDimensionedDouble(G4String(originX + ' ' + unitS)); >> 525 pOGLSViewer->fDisplayLightFrontY = >> 526 command->ConvertToDimensionedDouble(G4String(originY + ' ' + unitS)); >> 527 pOGLSViewer->fDisplayLightFrontZ = >> 528 command->ConvertToDimensionedDouble(G4String(originZ + ' ' + unitS)); >> 529 pOGLSViewer->fDisplayLightFrontT = >> 530 command->ConvertToDimensionedDouble(G4String(originT + ' ' + unitT)); >> 531 pOGLSViewer->fDisplayLightFrontRed = red; >> 532 pOGLSViewer->fDisplayLightFrontGreen = green; >> 533 pOGLSViewer->fDisplayLightFrontBlue = blue; >> 534 return; >> 535 } >> 536 >> 537 if (command == fpCommandEndTime) >> 538 { >> 539 G4String end_time_string, end_time_unit, >> 540 time_range_string, time_range_unit; >> 541 std::istringstream iss(newValue); >> 542 iss >> end_time_string >> end_time_unit >> 543 >> time_range_string >> time_range_unit; >> 544 pOGLSViewer->fEndTime = command->ConvertToDimensionedDouble >> 545 (G4String(end_time_string + ' ' + end_time_unit)); >> 546 G4double timeRange = command->ConvertToDimensionedDouble >> 547 (G4String(time_range_string + ' ' + time_range_unit)); >> 548 if (timeRange > 0.) { >> 549 pOGLSViewer->fStartTime = pOGLSViewer->fEndTime - timeRange; >> 550 } >> 551 if (pOGLSViewer->fVP.IsAutoRefresh()) >> 552 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh"); >> 553 return; >> 554 } >> 555 >> 556 if (command == fpCommandFade) >> 557 { >> 558 pOGLSViewer->fFadeFactor = command->ConvertToDouble(newValue); >> 559 if (pOGLSViewer->fVP.IsAutoRefresh()) >> 560 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh"); >> 561 return; >> 562 } >> 563 >> 564 if (command == fpCommandStartTime) >> 565 { >> 566 G4String start_time_string, start_time_unit, >> 567 time_range_string, time_range_unit; >> 568 std::istringstream iss(newValue); >> 569 iss >> start_time_string >> start_time_unit >> 570 >> time_range_string >> time_range_unit; >> 571 pOGLSViewer->fStartTime = command->ConvertToDimensionedDouble >> 572 (G4String(start_time_string + ' ' + start_time_unit)); >> 573 G4double timeRange = command->ConvertToDimensionedDouble >> 574 (G4String(time_range_string + ' ' + time_range_unit)); >> 575 if (timeRange > 0.) { >> 576 pOGLSViewer->fEndTime = pOGLSViewer->fStartTime + timeRange; >> 577 } >> 578 if (pOGLSViewer->fVP.IsAutoRefresh()) >> 579 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh"); >> 580 return; >> 581 } >> 582 341 G4OpenGLStoredSceneHandler* pOGLSSceneHandle 583 G4OpenGLStoredSceneHandler* pOGLSSceneHandler = 342 dynamic_cast<G4OpenGLStoredSceneHandler*>( 584 dynamic_cast<G4OpenGLStoredSceneHandler*>(pViewer->GetSceneHandler()); 343 585 344 if (!pOGLSSceneHandler) { 586 if (!pOGLSSceneHandler) { 345 G4cout << 587 G4cout << 346 "G4OpenGLViewerMessenger::SetNewValue: Curre 588 "G4OpenGLViewerMessenger::SetNewValue: Current scene handler is not of type" 347 "\n OGLS (Stored). (Viewer is \"" << pView 589 "\n OGLS (Stored). (Viewer is \"" << pViewer->GetName() << "\".)" 348 "\n (Scene handler is \"" << pSceneHandler- 590 "\n (Scene handler is \"" << pSceneHandler->GetName() << "\".)" 349 "\n This feature is only implemented for OG 591 "\n This feature is only implemented for OGL Stored" 350 "\n scene handlers. Use \"/vis/viewer/sele 592 "\n scene handlers. Use \"/vis/viewer/select\" or \"/vis/open OGLS...\"." 351 << G4endl; 593 << G4endl; 352 return; 594 return; 353 } 595 } 354 596 355 if (command == fpCommandDisplayListLimit) 597 if (command == fpCommandDisplayListLimit) 356 { 598 { 357 G4cerr << command->GetGuidanceLine(0) << << 599 G4int displayListLimit = >> 600 fpCommandDisplayListLimit->GetNewIntValue(newValue); >> 601 pOGLSSceneHandler->SetDisplayListLimit(displayListLimit); 358 return; 602 return; 359 } 603 } 360 } 604 } >> 605 >> 606 #endif 361 607