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,v 1.21 2010-11-07 10:31:26 allison Exp $ >> 28 // GEANT4 tag $Name: geant4-09-04-patch-02 $ >> 29 >> 30 #ifdef G4VIS_BUILD_OPENGL_DRIVER 27 31 28 #include "G4OpenGLViewerMessenger.hh" 32 #include "G4OpenGLViewerMessenger.hh" 29 33 30 #include "G4OpenGLViewer.hh" 34 #include "G4OpenGLViewer.hh" 31 #include "G4OpenGLStoredViewer.hh" 35 #include "G4OpenGLStoredViewer.hh" 32 #include "G4OpenGLStoredSceneHandler.hh" << 33 #include "G4UImanager.hh" 36 #include "G4UImanager.hh" 34 #include "G4UIcommand.hh" 37 #include "G4UIcommand.hh" 35 #include "G4UIdirectory.hh" 38 #include "G4UIdirectory.hh" 36 #include "G4UIcmdWithoutParameter.hh" 39 #include "G4UIcmdWithoutParameter.hh" 37 #include "G4UIcmdWithADouble.hh" 40 #include "G4UIcmdWithADouble.hh" 38 #include "G4UIcmdWithABool.hh" 41 #include "G4UIcmdWithABool.hh" 39 #include "G4UIcmdWithAString.hh" 42 #include "G4UIcmdWithAString.hh" 40 #include "G4UIcmdWithAnInteger.hh" 43 #include "G4UIcmdWithAnInteger.hh" 41 #include "G4VisManager.hh" 44 #include "G4VisManager.hh" 42 #include <sstream> 45 #include <sstream> 43 46 44 G4OpenGLViewerMessenger* 47 G4OpenGLViewerMessenger* 45 G4OpenGLViewerMessenger::fpInstance = 0; 48 G4OpenGLViewerMessenger::fpInstance = 0; 46 49 47 G4OpenGLViewerMessenger* 50 G4OpenGLViewerMessenger* 48 G4OpenGLViewerMessenger::GetInstance() 51 G4OpenGLViewerMessenger::GetInstance() 49 { 52 { 50 if (!fpInstance) fpInstance = new G4OpenGLVi 53 if (!fpInstance) fpInstance = new G4OpenGLViewerMessenger; 51 return fpInstance; 54 return fpInstance; 52 } 55 } 53 56 54 G4OpenGLViewerMessenger::G4OpenGLViewerMesseng 57 G4OpenGLViewerMessenger::G4OpenGLViewerMessenger() 55 { 58 { 56 G4bool omitable; 59 G4bool omitable; 57 60 58 fpDirectory = new G4UIdirectory("/vis/ogl/") 61 fpDirectory = new G4UIdirectory("/vis/ogl/"); 59 fpDirectory->SetGuidance("G4OpenGLViewer com 62 fpDirectory->SetGuidance("G4OpenGLViewer commands."); 60 63 61 fpCommandExport = << 64 fpCommandPrintEPS = 62 new G4UIcommand("/vis/ogl/export", this); << 65 new G4UIcmdWithoutParameter("/vis/ogl/printEPS", this); 63 fpCommandExport->SetGuidance ("Export a scre << 66 fpCommandPrintEPS->SetGuidance("Print Encapsulated PostScript file."); 64 fpCommandExport->SetGuidance << 67 fpCommandPrintEPS->SetGuidance 65 ("If name is \"\", filename and extension wi << 68 ("Generates files with names G4OpenGL_n.eps, where n is a sequence" 66 fpCommandExport->SetGuidance << 69 "\nnumber, starting at 0." 67 ("If name is \"toto.png\", set the name to \ << 70 "\nCan be \"vectored\" or \"pixmap\" - see \"/vis/ogl/set/printMode\"."); 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 << 118 fpDirectorySet->SetGuidance("G4OpenGLViewer << 119 71 120 fpCommandDisplayListLimit = << 72 fpCommandPrintSize = 121 new G4UIcmdWithoutParameter("/vis/ogl/set/ << 73 new G4UIcommand("/vis/ogl/set/printSize", this); 122 fpCommandDisplayListLimit->SetGuidance << 74 fpCommandPrintSize->SetGuidance ("Set print size"); 123 ("This command is no longer relevant. There << 75 fpCommandPrintSize->SetGuidance ("Tip : -1 will mean 'print size' = 'window size'"); 124 "\nnumber of display lists - except, of cou << 76 fpCommandPrintSize->SetGuidance (" Setting size greatter than your maximum graphic card capacity , will set the size to maximum size."); 125 "\nyour computer. Keep an eye on that. Good << 77 G4UIparameter* parameterPrintSize; 126 << 78 parameterPrintSize = new G4UIparameter ("width", 'd', omitable = false); 127 fpCommandExportFormat = << 79 parameterPrintSize->SetDefaultValue(-1); 128 new G4UIcommand("/vis/ogl/set/exportFormat", << 80 fpCommandPrintSize->SetParameter(parameterPrintSize); 129 fpCommandExportFormat->SetGuidance ("Set exp << 81 parameterPrintSize = new G4UIparameter ("height", 'd', omitable = false); 130 fpCommandExportFormat->SetGuidance ("By defa << 82 parameterPrintSize->SetDefaultValue(-1); 131 fpCommandExportFormat->SetGuidance ("Try /vi << 83 fpCommandPrintSize->SetParameter(parameterPrintSize); 132 fpCommandExportFormat->SetGuidance ("Changin << 133 G4UIparameter* parameterExportFormat; << 134 parameterExportFormat = new G4UIparameter (" << 135 parameterExportFormat->SetDefaultValue(""); << 136 fpCommandExportFormat->SetParameter(paramete << 137 84 138 fpCommandPrintFilename = 85 fpCommandPrintFilename = 139 new G4UIcommand("/vis/ogl/set/printFilenam 86 new G4UIcommand("/vis/ogl/set/printFilename", this); 140 fpCommandPrintFilename->SetGuidance ("Set pr 87 fpCommandPrintFilename->SetGuidance ("Set print filename"); 141 fpCommandPrintFilename->SetGuidance ("Settin 88 fpCommandPrintFilename->SetGuidance ("Setting 'incremental' will increment filename by one at each new print, starting at 0"); 142 G4UIparameter* parameterPrintFilename; 89 G4UIparameter* parameterPrintFilename; 143 parameterPrintFilename = new G4UIparameter ( 90 parameterPrintFilename = new G4UIparameter ("name", 's', omitable = true); 144 parameterPrintFilename->SetDefaultValue("G4O 91 parameterPrintFilename->SetDefaultValue("G4OpenGL"); 145 fpCommandPrintFilename->SetParameter(paramet 92 fpCommandPrintFilename->SetParameter(parameterPrintFilename); 146 parameterPrintFilename = new G4UIparameter ( 93 parameterPrintFilename = new G4UIparameter ("incremental", 'b', omitable = true); 147 parameterPrintFilename->SetDefaultValue(1); 94 parameterPrintFilename->SetDefaultValue(1); 148 fpCommandPrintFilename->SetParameter(paramet 95 fpCommandPrintFilename->SetParameter(parameterPrintFilename); 149 << 96 150 fpCommandPrintMode = new G4UIcmdWithAString( << 97 fpDirectorySet = new G4UIdirectory ("/vis/ogl/set/"); 151 fpCommandPrintMode->SetGuidance("Set print m << 98 fpDirectorySet->SetGuidance("G4OpenGLViewer set commands."); >> 99 >> 100 G4UIparameter* parameter; >> 101 >> 102 fpCommandDisplayHeadTime = >> 103 new G4UIcommand("/vis/ogl/set/displayHeadTime", this); >> 104 fpCommandDisplayHeadTime->SetGuidance >> 105 ("Display head time of range in 2D text."); >> 106 parameter = new G4UIparameter ("displayHeadTime", 'b', omitable = false); >> 107 parameter->SetDefaultValue(false); >> 108 fpCommandDisplayHeadTime->SetParameter(parameter); >> 109 parameter = new G4UIparameter ("screenX", 'd', omitable = true); >> 110 parameter->SetGuidance("-1 < screenX < 1"); >> 111 parameter->SetParameterRange("screenX >= -1. && screenX <= 1."); >> 112 parameter->SetDefaultValue(-0.9); >> 113 fpCommandDisplayHeadTime->SetParameter(parameter); >> 114 parameter = new G4UIparameter ("screenY", 'd', omitable = true); >> 115 parameter->SetGuidance("-1 < screenY < 1"); >> 116 parameter->SetParameterRange("screenY >= -1. && screenY <= 1."); >> 117 parameter->SetDefaultValue(-0.9); >> 118 fpCommandDisplayHeadTime->SetParameter(parameter); >> 119 parameter = new G4UIparameter ("screenSize", 'd', omitable = true); >> 120 parameter->SetDefaultValue(24.); >> 121 fpCommandDisplayHeadTime->SetParameter(parameter); >> 122 parameter = new G4UIparameter ("red", 'd', omitable = true); >> 123 parameter->SetParameterRange("red >= 0. && red <= 1."); >> 124 parameter->SetDefaultValue(0.); >> 125 fpCommandDisplayHeadTime->SetParameter(parameter); >> 126 parameter = new G4UIparameter ("green", 'd', omitable = true); >> 127 parameter->SetParameterRange("green >= 0. && green <= 1."); >> 128 parameter->SetDefaultValue(1.); >> 129 fpCommandDisplayHeadTime->SetParameter(parameter); >> 130 parameter = new G4UIparameter ("blue", 'd', omitable = true); >> 131 parameter->SetParameterRange("blue >= 0. && blue <= 1."); >> 132 parameter->SetDefaultValue(1.); >> 133 fpCommandDisplayHeadTime->SetParameter(parameter); >> 134 >> 135 fpCommandDisplayLightFront = >> 136 new G4UIcommand("/vis/ogl/set/displayLightFront", this); >> 137 fpCommandDisplayLightFront->SetGuidance >> 138 ("Display the light front at head time."); >> 139 fpCommandDisplayLightFront->SetGuidance >> 140 ("Tip: The trajectories can appear of jump ahead of the light front" >> 141 "\nbecause their time range overlaps the viewer's time range. To" >> 142 "\naverage out this discrete time effect, advance the light front by" >> 143 "\nhalf the trajectories interval. E.g., if the trajectory time slice" >> 144 "\ninterval is 0.01 ns:" >> 145 "\n /vis/ogl/set/displayLightFront true -90 0 0 mm -0.005 ns" >> 146 "\nTo prevent them beating the light front at all:" >> 147 "\n /vis/ogl/set/displayLightFront true -90 0 0 mm -0.01 ns"); >> 148 parameter = new G4UIparameter ("displayLightFront", 'b', omitable = false); >> 149 parameter->SetDefaultValue(false); >> 150 fpCommandDisplayLightFront->SetParameter(parameter); >> 151 parameter = new G4UIparameter ("originX", 'd', omitable = true); >> 152 parameter->SetDefaultValue(0.); >> 153 fpCommandDisplayLightFront->SetParameter(parameter); >> 154 parameter = new G4UIparameter ("originY", 'd', omitable = true); >> 155 parameter->SetDefaultValue(0.); >> 156 fpCommandDisplayLightFront->SetParameter(parameter); >> 157 parameter = new G4UIparameter ("originZ", 'd', omitable = true); >> 158 parameter->SetDefaultValue(0.); >> 159 fpCommandDisplayLightFront->SetParameter(parameter); >> 160 parameter = new G4UIparameter ("space_unit", 's', omitable = true); >> 161 parameter->SetDefaultValue("m"); >> 162 fpCommandDisplayLightFront->SetParameter(parameter); >> 163 parameter = new G4UIparameter ("originT", 'd', omitable = true); >> 164 parameter->SetDefaultValue(0.); >> 165 fpCommandDisplayLightFront->SetParameter(parameter); >> 166 parameter = new G4UIparameter ("time_unit", 's', omitable = true); >> 167 parameter->SetDefaultValue("s"); >> 168 fpCommandDisplayLightFront->SetParameter(parameter); >> 169 parameter = new G4UIparameter ("red", 'd', omitable = true); >> 170 parameter->SetParameterRange("red >= 0. && red <= 1."); >> 171 parameter->SetDefaultValue(0.); >> 172 fpCommandDisplayLightFront->SetParameter(parameter); >> 173 parameter = new G4UIparameter ("green", 'd', omitable = true); >> 174 parameter->SetParameterRange("green >= 0. && green <= 1."); >> 175 parameter->SetDefaultValue(1.); >> 176 fpCommandDisplayLightFront->SetParameter(parameter); >> 177 parameter = new G4UIparameter ("blue", 'd', omitable = true); >> 178 parameter->SetParameterRange("blue >= 0. && blue <= 1."); >> 179 parameter->SetDefaultValue(0.); >> 180 fpCommandDisplayLightFront->SetParameter(parameter); >> 181 >> 182 fpCommandDisplayListLimit = >> 183 new G4UIcmdWithAnInteger("/vis/ogl/set/displayListLimit", this); >> 184 fpCommandDisplayListLimit->SetGuidance >> 185 ("Set/reset display list limit (to avoid memory exhaustion)."); >> 186 fpCommandDisplayListLimit->SetParameterName("limit", omitable = true); >> 187 fpCommandDisplayListLimit->SetDefaultValue(50000); >> 188 fpCommandDisplayListLimit->SetRange("limit>=10000"); >> 189 >> 190 fpCommandEndTime = >> 191 new G4UIcommand("/vis/ogl/set/endTime", this); >> 192 fpCommandEndTime->SetGuidance("Set end and range of track time."); >> 193 parameter = new G4UIparameter ("end-time", 'd', omitable = false); >> 194 parameter->SetDefaultValue(DBL_MAX); >> 195 fpCommandEndTime->SetParameter(parameter); >> 196 parameter = new G4UIparameter ("end-time-unit", 's', omitable = false); >> 197 parameter->SetDefaultValue("ns"); >> 198 fpCommandEndTime->SetParameter(parameter); >> 199 parameter = new G4UIparameter ("time-range", 'd', omitable = true); >> 200 parameter->SetDefaultValue(-1.); >> 201 fpCommandEndTime->SetParameter(parameter); >> 202 parameter = new G4UIparameter ("time-range-unit", 's', omitable = true); >> 203 parameter->SetDefaultValue("ns"); >> 204 fpCommandEndTime->SetParameter(parameter); >> 205 >> 206 fpCommandFade = new G4UIcmdWithADouble("/vis/ogl/set/fade", this); >> 207 fpCommandFade->SetGuidance >> 208 ("0: no fade; 1: maximum fade with time within range."); >> 209 fpCommandFade->SetParameterName("fadefactor", omitable = false); >> 210 fpCommandFade->SetRange("fadefactor>=0.&&fadefactor<=1."); >> 211 fpCommandFade->SetDefaultValue(0.); >> 212 >> 213 fpCommandPrintMode = new G4UIcmdWithAString >> 214 ("/vis/ogl/set/printMode",this); >> 215 fpCommandPrintMode->SetGuidance("Set print mode"); 152 fpCommandPrintMode->SetParameterName("print_ 216 fpCommandPrintMode->SetParameterName("print_mode",omitable = true); 153 fpCommandPrintMode->SetCandidates("vectored 217 fpCommandPrintMode->SetCandidates("vectored pixmap"); 154 fpCommandPrintMode->SetDefaultValue("vectore 218 fpCommandPrintMode->SetDefaultValue("vectored"); 155 219 156 fpCommandPrintSize = << 220 fpCommandStartTime = 157 new G4UIcommand("/vis/ogl/set/printSize", << 221 new G4UIcommand("/vis/ogl/set/startTime", this); 158 fpCommandPrintSize->SetGuidance ("Set print << 222 fpCommandStartTime->SetGuidance("Set start and range of track time."); 159 fpCommandPrintSize->SetGuidance ("Tip : -1 w << 223 parameter = new G4UIparameter ("start-time", 'd', omitable = false); 160 fpCommandPrintSize->SetGuidance (" Set << 224 parameter->SetDefaultValue(-DBL_MAX); 161 G4UIparameter* parameterPrintSize; << 225 fpCommandStartTime->SetParameter(parameter); 162 parameterPrintSize = new G4UIparameter ("wid << 226 parameter = new G4UIparameter ("start-time-unit", 's', omitable = false); 163 parameterPrintSize->SetDefaultValue(-1); << 227 parameter->SetDefaultValue("ns"); 164 fpCommandPrintSize->SetParameter(parameterPr << 228 fpCommandStartTime->SetParameter(parameter); 165 parameterPrintSize = new G4UIparameter ("hei << 229 parameter = new G4UIparameter ("time-range", 'd', omitable = true); 166 parameterPrintSize->SetDefaultValue(-1); << 230 parameter->SetDefaultValue(-1.); 167 fpCommandPrintSize->SetParameter(parameterPr << 231 fpCommandStartTime->SetParameter(parameter); >> 232 parameter = new G4UIparameter ("time-range-unit", 's', omitable = true); >> 233 parameter->SetDefaultValue("ns"); >> 234 fpCommandStartTime->SetParameter(parameter); 168 235 169 fpCommandTransparency = 236 fpCommandTransparency = 170 new G4UIcmdWithABool("/vis/ogl/set/transpa 237 new G4UIcmdWithABool("/vis/ogl/set/transparency", this); 171 fpCommandTransparency->SetGuidance 238 fpCommandTransparency->SetGuidance 172 ("True/false to enable/disable rendering o 239 ("True/false to enable/disable rendering of transparent objects."); 173 fpCommandTransparency->SetParameterName 240 fpCommandTransparency->SetParameterName 174 ("transparency-enabled", omitable = true); 241 ("transparency-enabled", omitable = true); 175 fpCommandTransparency->SetDefaultValue(true) 242 fpCommandTransparency->SetDefaultValue(true); 176 } 243 } 177 244 178 G4OpenGLViewerMessenger::~G4OpenGLViewerMessen 245 G4OpenGLViewerMessenger::~G4OpenGLViewerMessenger () 179 { 246 { 180 delete fpCommandTransparency; << 181 delete fpCommandPrintSize; << 182 delete fpCommandPrintMode; 247 delete fpCommandPrintMode; 183 delete fpCommandPrintFilename; << 248 delete fpCommandTransparency; 184 delete fpCommandExportFormat; << 249 delete fpCommandStartTime; >> 250 delete fpCommandFade; >> 251 delete fpCommandEndTime; 185 delete fpCommandDisplayListLimit; 252 delete fpCommandDisplayListLimit; >> 253 delete fpCommandDisplayLightFront; >> 254 delete fpCommandDisplayHeadTime; 186 delete fpDirectorySet; 255 delete fpDirectorySet; 187 delete fpCommandFlushAt; << 256 delete fpCommandPrintEPS; 188 delete fpCommandExport; << 189 delete fpDirectory; 257 delete fpDirectory; 190 258 191 delete fpInstance; 259 delete fpInstance; 192 } 260 } 193 261 194 void G4OpenGLViewerMessenger::SetNewValue 262 void G4OpenGLViewerMessenger::SetNewValue 195 (G4UIcommand* command, G4String newValue) 263 (G4UIcommand* command, G4String newValue) 196 { 264 { 197 G4VisManager* pVisManager = G4VisManager::Ge 265 G4VisManager* pVisManager = G4VisManager::GetInstance(); 198 266 199 G4VViewer* pViewer = pVisManager->GetCurrent 267 G4VViewer* pViewer = pVisManager->GetCurrentViewer(); >> 268 200 if (!pViewer) { 269 if (!pViewer) { 201 G4cout << 270 G4cout << 202 "G4OpenGLViewerMessenger::SetNewValue: N 271 "G4OpenGLViewerMessenger::SetNewValue: No current viewer." 203 "\n \"/vis/open\", or similar, to get o 272 "\n \"/vis/open\", or similar, to get one." 204 << G4endl; 273 << G4endl; 205 return; 274 return; 206 } 275 } 207 276 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 277 G4OpenGLViewer* pOGLViewer = dynamic_cast<G4OpenGLViewer*>(pViewer); >> 278 220 if (!pOGLViewer) { 279 if (!pOGLViewer) { 221 G4cout << 280 G4cout << 222 "G4OpenGLViewerMessenger::SetNewValue: C 281 "G4OpenGLViewerMessenger::SetNewValue: Current viewer is not of type" 223 "\n OGL. (It is \"" 282 "\n OGL. (It is \"" 224 << pViewer->GetName() << 283 << pViewer->GetName() << 225 "\".)\n Use \"/vis/viewer/select\" or \ 284 "\".)\n Use \"/vis/viewer/select\" or \"/vis/open\"." 226 << G4endl; 285 << G4endl; 227 return; 286 return; 228 } 287 } 229 288 230 G4OpenGLSceneHandler* pOGLSceneHandler = << 289 if (command == fpCommandPrintEPS) 231 dynamic_cast<G4OpenGLSceneHandler*>(pSceneHa << 290 { 232 if (!pOGLSceneHandler) { << 291 pOGLViewer->printEPS(); 233 G4cout << << 292 return; 234 "G4OpenGLViewerMessenger::SetNewValue: Cur << 293 } 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 { << 245 G4String name; << 246 G4int width,height; << 247 std::istringstream iss(newValue); << 248 iss >> name >> width >> height; << 249 pOGLViewer->exportImage(name, width, heigh << 250 << 251 if (pOGLViewer->fVP.IsAutoRefresh()) << 252 G4UImanager::GetUIpointer()->ApplyComman << 253 return; << 254 } << 255 << 256 if (command == fpCommandExportFormat) << 257 { << 258 G4String name; << 259 std::istringstream iss(newValue); << 260 iss >> name; << 261 pOGLViewer->setExportImageFormat(name); << 262 << 263 return; << 264 } << 265 294 266 if (command == fpCommandFlushAt) << 295 if (command == fpCommandPrintSize) 267 { << 296 { 268 static G4bool firstTime = true; << 297 G4int width,height; 269 static std::map<G4String,G4OpenGLSceneHand << 298 std::istringstream iss(newValue); 270 if (firstTime) { << 299 iss >> width 271 actionMap["endOfEvent"] = G4OpenGLSce << 300 >> height; 272 actionMap["endOfRun"] = G4OpenGLSce << 301 pOGLViewer->setPrintSize(width,height); 273 actionMap["eachPrimitive"] = G4OpenGLSce << 302 } 274 actionMap["NthPrimitive"] = G4OpenGLSce << 275 actionMap["NthEvent"] = G4OpenGLSce << 276 actionMap["never"] = G4OpenGLSce << 277 firstTime = false; << 278 } << 279 G4String action; << 280 G4int entitiesFlushInterval; << 281 std::istringstream iss(newValue); << 282 iss >> action >> entitiesFlushInterval; << 283 pOGLSceneHandler->SetFlushAction(actionMap << 284 pOGLSceneHandler->SetEntitiesFlushInterval << 285 return; << 286 } << 287 303 288 if (command == fpCommandPrintFilename) << 304 if (command == fpCommandPrintFilename) 289 { 305 { 290 G4String name; 306 G4String name; 291 G4bool inc; 307 G4bool inc; 292 std::istringstream iss(newValue); 308 std::istringstream iss(newValue); 293 iss >> name 309 iss >> name 294 >> inc; << 310 >> inc; 295 pOGLViewer->setExportFilename(name,inc); << 311 pOGLViewer->setPrintFilename(name,inc); 296 return; << 297 } 312 } 298 313 299 if (command == fpCommandPrintMode) 314 if (command == fpCommandPrintMode) 300 { 315 { 301 if (newValue == "vectored") pOGLViewer-> 316 if (newValue == "vectored") pOGLViewer->fVectoredPs = true; 302 << 303 if (newValue == "pixmap") pOGLViewer->fV 317 if (newValue == "pixmap") pOGLViewer->fVectoredPs = false; 304 return; 318 return; 305 } 319 } 306 320 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) 321 if (command == fpCommandTransparency) 318 { 322 { 319 pOGLViewer->transparency_enabled = comma 323 pOGLViewer->transparency_enabled = command->ConvertToBool(newValue); 320 if (pOGLViewer->fVP.IsAutoRefresh()) 324 if (pOGLViewer->fVP.IsAutoRefresh()) 321 G4UImanager::GetUIpointer()->ApplyCommand("/ << 325 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh"); 322 return; 326 return; 323 } 327 } 324 328 325 // Stored viewer commands << 326 G4OpenGLStoredViewer* pOGLSViewer = 329 G4OpenGLStoredViewer* pOGLSViewer = 327 dynamic_cast<G4OpenGLStoredViewer*>(pViewe 330 dynamic_cast<G4OpenGLStoredViewer*>(pViewer); 328 331 329 if (!pOGLSViewer) 332 if (!pOGLSViewer) 330 { 333 { 331 G4cout << 334 G4cout << 332 "G4OpenGLViewerMessenger::SetNewValue: Curre 335 "G4OpenGLViewerMessenger::SetNewValue: Current viewer is not of type OGLS." 333 "\n (It is \"" << pViewer->GetName() << "\" 336 "\n (It is \"" << pViewer->GetName() << "\".)" 334 "\n This feature is only implemented for OG 337 "\n This feature is only implemented for OGL Stored viewers." 335 "\n Use \"/vis/viewer/select\" or \"/vis/op 338 "\n Use \"/vis/viewer/select\" or \"/vis/open OGLS...\"." 336 << G4endl; 339 << G4endl; 337 return; 340 return; 338 } 341 } 339 342 340 // Scene handler commands << 343 if (command == fpCommandDisplayHeadTime) >> 344 { >> 345 G4String display; >> 346 G4double screenX, screenY, screenSize, red, green, blue; >> 347 std::istringstream iss(newValue); >> 348 iss >> display >> screenX >> screenY >> 349 >> screenSize >> red >> green >> blue; >> 350 pOGLSViewer->fDisplayHeadTime = command->ConvertToBool(display); >> 351 pOGLSViewer->fDisplayHeadTimeX = screenX; >> 352 pOGLSViewer->fDisplayHeadTimeY = screenY; >> 353 pOGLSViewer->fDisplayHeadTimeSize = screenSize; >> 354 pOGLSViewer->fDisplayHeadTimeRed = red; >> 355 pOGLSViewer->fDisplayHeadTimeGreen = green; >> 356 pOGLSViewer->fDisplayHeadTimeBlue = blue; >> 357 return; >> 358 } >> 359 >> 360 if (command == fpCommandDisplayLightFront) >> 361 { >> 362 G4String display, originX, originY, originZ, unitS, originT, unitT; >> 363 G4double red, green, blue; >> 364 std::istringstream iss(newValue); >> 365 iss >> display >> 366 >> originX >> originY >> originZ >> unitS >> 367 >> originT >> unitT >> 368 >> red >> green >> blue; >> 369 pOGLSViewer->fDisplayLightFront = command->ConvertToBool(display); >> 370 pOGLSViewer->fDisplayLightFrontX = >> 371 command->ConvertToDimensionedDouble(G4String(originX + ' ' + unitS)); >> 372 pOGLSViewer->fDisplayLightFrontY = >> 373 command->ConvertToDimensionedDouble(G4String(originY + ' ' + unitS)); >> 374 pOGLSViewer->fDisplayLightFrontZ = >> 375 command->ConvertToDimensionedDouble(G4String(originZ + ' ' + unitS)); >> 376 pOGLSViewer->fDisplayLightFrontT = >> 377 command->ConvertToDimensionedDouble(G4String(originT + ' ' + unitT)); >> 378 pOGLSViewer->fDisplayLightFrontRed = red; >> 379 pOGLSViewer->fDisplayLightFrontGreen = green; >> 380 pOGLSViewer->fDisplayLightFrontBlue = blue; >> 381 return; >> 382 } >> 383 >> 384 if (command == fpCommandEndTime) >> 385 { >> 386 G4String end_time_string, end_time_unit, >> 387 time_range_string, time_range_unit; >> 388 std::istringstream iss(newValue); >> 389 iss >> end_time_string >> end_time_unit >> 390 >> time_range_string >> time_range_unit; >> 391 pOGLSViewer->fEndTime = command->ConvertToDimensionedDouble >> 392 (G4String(end_time_string + ' ' + end_time_unit)); >> 393 G4double timeRange = command->ConvertToDimensionedDouble >> 394 (G4String(time_range_string + ' ' + time_range_unit)); >> 395 if (timeRange > 0.) { >> 396 pOGLSViewer->fStartTime = pOGLSViewer->fEndTime - timeRange; >> 397 } >> 398 if (pOGLSViewer->fVP.IsAutoRefresh()) >> 399 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh"); >> 400 return; >> 401 } >> 402 >> 403 if (command == fpCommandFade) >> 404 { >> 405 pOGLSViewer->fFadeFactor = command->ConvertToDouble(newValue); >> 406 if (pOGLSViewer->fVP.IsAutoRefresh()) >> 407 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh"); >> 408 } >> 409 >> 410 if (command == fpCommandStartTime) >> 411 { >> 412 G4String start_time_string, start_time_unit, >> 413 time_range_string, time_range_unit; >> 414 std::istringstream iss(newValue); >> 415 iss >> start_time_string >> start_time_unit >> 416 >> time_range_string >> time_range_unit; >> 417 pOGLSViewer->fStartTime = command->ConvertToDimensionedDouble >> 418 (G4String(start_time_string + ' ' + start_time_unit)); >> 419 G4double timeRange = command->ConvertToDimensionedDouble >> 420 (G4String(time_range_string + ' ' + time_range_unit)); >> 421 if (timeRange > 0.) { >> 422 pOGLSViewer->fEndTime = pOGLSViewer->fStartTime + timeRange; >> 423 } >> 424 if (pOGLSViewer->fVP.IsAutoRefresh()) >> 425 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh"); >> 426 return; >> 427 } >> 428 >> 429 G4VSceneHandler* pSceneHandler = pViewer->GetSceneHandler(); >> 430 >> 431 if (!pSceneHandler) { >> 432 G4cout << >> 433 "G4OpenGLViewerMessenger::SetNewValue: This viewer has no scene handler." >> 434 "\n Shouldn't happen - please report circumstances." >> 435 "\n (Viewer is \"" << pViewer->GetName() << "\".)" >> 436 "\n Try \"/vis/open\", or similar, to get one." >> 437 << G4endl; >> 438 return; >> 439 } >> 440 >> 441 G4OpenGLSceneHandler* pOGLSceneHandler = >> 442 dynamic_cast<G4OpenGLSceneHandler*>(pSceneHandler); >> 443 >> 444 if (!pOGLSceneHandler) { >> 445 G4cout << >> 446 "G4OpenGLViewerMessenger::SetNewValue: Current scene handler is not of type" >> 447 "\n OGL. (Viewer is \"" << pViewer->GetName() << "\".)" >> 448 "\n (Scene handler is \"" << pSceneHandler->GetName() << "\".)" >> 449 "\n Use \"/vis/sceneHandler/list\" and \"/vis/sceneHandler/select\"" >> 450 "\n or \"/vis/open\"." >> 451 << G4endl; >> 452 return; >> 453 } >> 454 341 G4OpenGLStoredSceneHandler* pOGLSSceneHandle 455 G4OpenGLStoredSceneHandler* pOGLSSceneHandler = 342 dynamic_cast<G4OpenGLStoredSceneHandler*>( 456 dynamic_cast<G4OpenGLStoredSceneHandler*>(pViewer->GetSceneHandler()); 343 457 344 if (!pOGLSSceneHandler) { 458 if (!pOGLSSceneHandler) { 345 G4cout << 459 G4cout << 346 "G4OpenGLViewerMessenger::SetNewValue: Curre 460 "G4OpenGLViewerMessenger::SetNewValue: Current scene handler is not of type" 347 "\n OGLS (Stored). (Viewer is \"" << pView 461 "\n OGLS (Stored). (Viewer is \"" << pViewer->GetName() << "\".)" 348 "\n (Scene handler is \"" << pSceneHandler- 462 "\n (Scene handler is \"" << pSceneHandler->GetName() << "\".)" 349 "\n This feature is only implemented for OG 463 "\n This feature is only implemented for OGL Stored" 350 "\n scene handlers. Use \"/vis/viewer/sele 464 "\n scene handlers. Use \"/vis/viewer/select\" or \"/vis/open OGLS...\"." 351 << G4endl; 465 << G4endl; 352 return; 466 return; 353 } 467 } 354 468 355 if (command == fpCommandDisplayListLimit) 469 if (command == fpCommandDisplayListLimit) 356 { 470 { 357 G4cerr << command->GetGuidanceLine(0) << << 471 G4int displayListLimit = 358 return; << 472 fpCommandDisplayListLimit->GetNewIntValue(newValue); >> 473 pOGLSSceneHandler->SetDisplayListLimit(displayListLimit); 359 } 474 } 360 } 475 } >> 476 >> 477 #endif 361 478