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