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