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