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.6 2007/02/08 14:01:55 allison Exp $ >> 28 // GEANT4 tag $Name: geant4-08-03 $ 27 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" << 33 #include "G4UImanager.hh" 34 #include "G4UImanager.hh" 34 #include "G4UIcommand.hh" 35 #include "G4UIcommand.hh" 35 #include "G4UIdirectory.hh" 36 #include "G4UIdirectory.hh" 36 #include "G4UIcmdWithoutParameter.hh" << 37 #include "G4UIcmdWithADouble.hh" 37 #include "G4UIcmdWithADouble.hh" 38 #include "G4UIcmdWithABool.hh" 38 #include "G4UIcmdWithABool.hh" 39 #include "G4UIcmdWithAString.hh" << 40 #include "G4UIcmdWithAnInteger.hh" << 41 #include "G4VisManager.hh" 39 #include "G4VisManager.hh" 42 #include <sstream> 40 #include <sstream> 43 41 44 G4OpenGLViewerMessenger* 42 G4OpenGLViewerMessenger* 45 G4OpenGLViewerMessenger::fpInstance = 0; 43 G4OpenGLViewerMessenger::fpInstance = 0; 46 44 47 G4OpenGLViewerMessenger* 45 G4OpenGLViewerMessenger* 48 G4OpenGLViewerMessenger::GetInstance() 46 G4OpenGLViewerMessenger::GetInstance() 49 { 47 { 50 if (!fpInstance) fpInstance = new G4OpenGLVi 48 if (!fpInstance) fpInstance = new G4OpenGLViewerMessenger; 51 return fpInstance; 49 return fpInstance; 52 } 50 } 53 51 54 G4OpenGLViewerMessenger::G4OpenGLViewerMesseng 52 G4OpenGLViewerMessenger::G4OpenGLViewerMessenger() 55 { 53 { 56 G4bool omitable; 54 G4bool omitable; 57 55 58 fpDirectory = new G4UIdirectory("/vis/ogl/") 56 fpDirectory = new G4UIdirectory("/vis/ogl/"); 59 fpDirectory->SetGuidance("G4OpenGLViewer com 57 fpDirectory->SetGuidance("G4OpenGLViewer commands."); 60 58 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 59 fpDirectorySet = new G4UIdirectory ("/vis/ogl/set/"); 118 fpDirectorySet->SetGuidance("G4OpenGLViewer 60 fpDirectorySet->SetGuidance("G4OpenGLViewer set commands."); 119 61 120 fpCommandDisplayListLimit = << 62 G4UIparameter* parameter; 121 new G4UIcmdWithoutParameter("/vis/ogl/set/ << 63 122 fpCommandDisplayListLimit->SetGuidance << 64 fpCommandDisplayHeadTime = 123 ("This command is no longer relevant. There << 65 new G4UIcommand("/vis/ogl/set/displayHeadTime", this); 124 "\nnumber of display lists - except, of cou << 66 fpCommandDisplayHeadTime->SetGuidance 125 "\nyour computer. Keep an eye on that. Good << 67 ("Display head time of range in 2D text."); 126 << 68 parameter = new G4UIparameter ("displayHeadTime", 'b', omitable = false); 127 fpCommandExportFormat = << 69 parameter->SetDefaultValue(false); 128 new G4UIcommand("/vis/ogl/set/exportFormat", << 70 fpCommandDisplayHeadTime->SetParameter(parameter); 129 fpCommandExportFormat->SetGuidance ("Set exp << 71 parameter = new G4UIparameter ("screenX", 'd', omitable = true); 130 fpCommandExportFormat->SetGuidance ("By defa << 72 parameter->SetGuidance("-1 < screenX < 1"); 131 fpCommandExportFormat->SetGuidance ("Try /vi << 73 parameter->SetParameterRange("screenX >= -1. && screenX <= 1."); 132 fpCommandExportFormat->SetGuidance ("Changin << 74 parameter->SetDefaultValue(-0.9); 133 G4UIparameter* parameterExportFormat; << 75 fpCommandDisplayHeadTime->SetParameter(parameter); 134 parameterExportFormat = new G4UIparameter (" << 76 parameter = new G4UIparameter ("screenY", 'd', omitable = true); 135 parameterExportFormat->SetDefaultValue(""); << 77 parameter->SetGuidance("-1 < screenY < 1"); 136 fpCommandExportFormat->SetParameter(paramete << 78 parameter->SetParameterRange("screenY >= -1. && screenY <= 1."); 137 << 79 parameter->SetDefaultValue(-0.9); 138 fpCommandPrintFilename = << 80 fpCommandDisplayHeadTime->SetParameter(parameter); 139 new G4UIcommand("/vis/ogl/set/printFilenam << 81 parameter = new G4UIparameter ("screenSize", 'd', omitable = true); 140 fpCommandPrintFilename->SetGuidance ("Set pr << 82 parameter->SetDefaultValue(24.); 141 fpCommandPrintFilename->SetGuidance ("Settin << 83 fpCommandDisplayHeadTime->SetParameter(parameter); 142 G4UIparameter* parameterPrintFilename; << 84 parameter = new G4UIparameter ("red", 'd', omitable = true); 143 parameterPrintFilename = new G4UIparameter ( << 85 parameter->SetParameterRange("red >= 0. && red <= 1."); 144 parameterPrintFilename->SetDefaultValue("G4O << 86 parameter->SetDefaultValue(0.); 145 fpCommandPrintFilename->SetParameter(paramet << 87 fpCommandDisplayHeadTime->SetParameter(parameter); 146 parameterPrintFilename = new G4UIparameter ( << 88 parameter = new G4UIparameter ("green", 'd', omitable = true); 147 parameterPrintFilename->SetDefaultValue(1); << 89 parameter->SetParameterRange("green >= 0. && green <= 1."); 148 fpCommandPrintFilename->SetParameter(paramet << 90 parameter->SetDefaultValue(1.); 149 << 91 fpCommandDisplayHeadTime->SetParameter(parameter); 150 fpCommandPrintMode = new G4UIcmdWithAString( << 92 parameter = new G4UIparameter ("blue", 'd', omitable = true); 151 fpCommandPrintMode->SetGuidance("Set print m << 93 parameter->SetParameterRange("blue >= 0. && blue <= 1."); 152 fpCommandPrintMode->SetParameterName("print_ << 94 parameter->SetDefaultValue(1.); 153 fpCommandPrintMode->SetCandidates("vectored << 95 fpCommandDisplayHeadTime->SetParameter(parameter); 154 fpCommandPrintMode->SetDefaultValue("vectore << 96 155 << 97 fpCommandDisplayLightFront = 156 fpCommandPrintSize = << 98 new G4UIcommand("/vis/ogl/set/displayLightFront", this); 157 new G4UIcommand("/vis/ogl/set/printSize", << 99 fpCommandDisplayLightFront->SetGuidance 158 fpCommandPrintSize->SetGuidance ("Set print << 100 ("Display the light front at head time."); 159 fpCommandPrintSize->SetGuidance ("Tip : -1 w << 101 fpCommandDisplayLightFront->SetGuidance 160 fpCommandPrintSize->SetGuidance (" Set << 102 ("Tip: The trajectories can appear of jump ahead of the light front" 161 G4UIparameter* parameterPrintSize; << 103 "\nbecause their time range overlaps the viewer's time range. To" 162 parameterPrintSize = new G4UIparameter ("wid << 104 "\naverage out this discrete time effect, advance the light front by" 163 parameterPrintSize->SetDefaultValue(-1); << 105 "\nhalf the trajectories interval. E.g., if the trajectory time slice" 164 fpCommandPrintSize->SetParameter(parameterPr << 106 "\ninterval is 0.01 ns:" 165 parameterPrintSize = new G4UIparameter ("hei << 107 "\n /vis/ogl/set/displayLightFront true -90 0 0 mm -0.005 ns" 166 parameterPrintSize->SetDefaultValue(-1); << 108 "\nTo prevent them beating the light front at all:" 167 fpCommandPrintSize->SetParameter(parameterPr << 109 "\n /vis/ogl/set/displayLightFront true -90 0 0 mm -0.01 ns"); >> 110 parameter = new G4UIparameter ("displayLightFront", 'b', omitable = false); >> 111 parameter->SetDefaultValue(false); >> 112 fpCommandDisplayLightFront->SetParameter(parameter); >> 113 parameter = new G4UIparameter ("originX", 'd', omitable = true); >> 114 parameter->SetDefaultValue(0.); >> 115 fpCommandDisplayLightFront->SetParameter(parameter); >> 116 parameter = new G4UIparameter ("originY", 'd', omitable = true); >> 117 parameter->SetDefaultValue(0.); >> 118 fpCommandDisplayLightFront->SetParameter(parameter); >> 119 parameter = new G4UIparameter ("originZ", 'd', omitable = true); >> 120 parameter->SetDefaultValue(0.); >> 121 fpCommandDisplayLightFront->SetParameter(parameter); >> 122 parameter = new G4UIparameter ("space_unit", 's', omitable = true); >> 123 parameter->SetDefaultValue("m"); >> 124 fpCommandDisplayLightFront->SetParameter(parameter); >> 125 parameter = new G4UIparameter ("originT", 'd', omitable = true); >> 126 parameter->SetDefaultValue(0.); >> 127 fpCommandDisplayLightFront->SetParameter(parameter); >> 128 parameter = new G4UIparameter ("time_unit", 's', omitable = true); >> 129 parameter->SetDefaultValue("s"); >> 130 fpCommandDisplayLightFront->SetParameter(parameter); >> 131 parameter = new G4UIparameter ("red", 'd', omitable = true); >> 132 parameter->SetParameterRange("red >= 0. && red <= 1."); >> 133 parameter->SetDefaultValue(0.); >> 134 fpCommandDisplayLightFront->SetParameter(parameter); >> 135 parameter = new G4UIparameter ("green", 'd', omitable = true); >> 136 parameter->SetParameterRange("green >= 0. && green <= 1."); >> 137 parameter->SetDefaultValue(1.); >> 138 fpCommandDisplayLightFront->SetParameter(parameter); >> 139 parameter = new G4UIparameter ("blue", 'd', omitable = true); >> 140 parameter->SetParameterRange("blue >= 0. && blue <= 1."); >> 141 parameter->SetDefaultValue(0.); >> 142 fpCommandDisplayLightFront->SetParameter(parameter); >> 143 >> 144 fpCommandEndTime = >> 145 new G4UIcommand("/vis/ogl/set/endTime", this); >> 146 fpCommandEndTime->SetGuidance("Set end and range of track time."); >> 147 parameter = new G4UIparameter ("end-time", 'd', omitable = false); >> 148 parameter->SetDefaultValue(G4OPENGL_DBL_MAX); >> 149 fpCommandEndTime->SetParameter(parameter); >> 150 parameter = new G4UIparameter ("end-time-unit", 's', omitable = false); >> 151 parameter->SetDefaultValue("ns"); >> 152 fpCommandEndTime->SetParameter(parameter); >> 153 parameter = new G4UIparameter ("time-range", 'd', omitable = true); >> 154 parameter->SetDefaultValue(-1.); >> 155 fpCommandEndTime->SetParameter(parameter); >> 156 parameter = new G4UIparameter ("time-range-unit", 's', omitable = true); >> 157 parameter->SetDefaultValue("ns"); >> 158 fpCommandEndTime->SetParameter(parameter); >> 159 >> 160 fpCommandFade = new G4UIcmdWithADouble("/vis/ogl/set/fade", this); >> 161 fpCommandFade->SetGuidance >> 162 ("0: no fade; 1: maximum fade with time within range."); >> 163 fpCommandFade->SetParameterName("fadefactor", omitable = false); >> 164 fpCommandFade->SetRange("fadefactor>=0.&&fadefactor<=1."); >> 165 fpCommandFade->SetDefaultValue(0.); >> 166 >> 167 fpCommandStartTime = >> 168 new G4UIcommand("/vis/ogl/set/startTime", this); >> 169 fpCommandStartTime->SetGuidance("Set start and range of track time."); >> 170 parameter = new G4UIparameter ("start-time", 'd', omitable = false); >> 171 parameter->SetDefaultValue(-G4OPENGL_DBL_MAX); >> 172 fpCommandStartTime->SetParameter(parameter); >> 173 parameter = new G4UIparameter ("start-time-unit", 's', omitable = false); >> 174 parameter->SetDefaultValue("ns"); >> 175 fpCommandStartTime->SetParameter(parameter); >> 176 parameter = new G4UIparameter ("time-range", 'd', omitable = true); >> 177 parameter->SetDefaultValue(-1.); >> 178 fpCommandStartTime->SetParameter(parameter); >> 179 parameter = new G4UIparameter ("time-range-unit", 's', omitable = true); >> 180 parameter->SetDefaultValue("ns"); >> 181 fpCommandStartTime->SetParameter(parameter); 168 182 169 fpCommandTransparency = 183 fpCommandTransparency = 170 new G4UIcmdWithABool("/vis/ogl/set/transpa 184 new G4UIcmdWithABool("/vis/ogl/set/transparency", this); 171 fpCommandTransparency->SetGuidance 185 fpCommandTransparency->SetGuidance 172 ("True/false to enable/disable rendering o 186 ("True/false to enable/disable rendering of transparent objects."); 173 fpCommandTransparency->SetParameterName 187 fpCommandTransparency->SetParameterName 174 ("transparency-enabled", omitable = true); 188 ("transparency-enabled", omitable = true); 175 fpCommandTransparency->SetDefaultValue(true) 189 fpCommandTransparency->SetDefaultValue(true); 176 } 190 } 177 191 178 G4OpenGLViewerMessenger::~G4OpenGLViewerMessen 192 G4OpenGLViewerMessenger::~G4OpenGLViewerMessenger () 179 { 193 { 180 delete fpCommandTransparency; 194 delete fpCommandTransparency; 181 delete fpCommandPrintSize; << 195 delete fpCommandStartTime; 182 delete fpCommandPrintMode; << 196 delete fpCommandFade; 183 delete fpCommandPrintFilename; << 197 delete fpCommandEndTime; 184 delete fpCommandExportFormat; << 198 delete fpCommandDisplayLightFront; 185 delete fpCommandDisplayListLimit; << 199 delete fpCommandDisplayHeadTime; 186 delete fpDirectorySet; 200 delete fpDirectorySet; 187 delete fpCommandFlushAt; << 188 delete fpCommandExport; << 189 delete fpDirectory; 201 delete fpDirectory; 190 << 191 delete fpInstance; << 192 } 202 } 193 203 194 void G4OpenGLViewerMessenger::SetNewValue 204 void G4OpenGLViewerMessenger::SetNewValue 195 (G4UIcommand* command, G4String newValue) 205 (G4UIcommand* command, G4String newValue) 196 { 206 { 197 G4VisManager* pVisManager = G4VisManager::Ge 207 G4VisManager* pVisManager = G4VisManager::GetInstance(); 198 208 199 G4VViewer* pViewer = pVisManager->GetCurrent << 209 G4VViewer* pVViewer = pVisManager->GetCurrentViewer(); 200 if (!pViewer) { << 210 >> 211 if (!pVViewer) { 201 G4cout << 212 G4cout << 202 "G4OpenGLViewerMessenger::SetNewValue: N 213 "G4OpenGLViewerMessenger::SetNewValue: No current viewer." 203 "\n \"/vis/open\", or similar, to get o 214 "\n \"/vis/open\", or similar, to get one." 204 << G4endl; 215 << G4endl; 205 return; 216 return; 206 } 217 } 207 218 208 G4VSceneHandler* pSceneHandler = pViewer->Ge << 219 G4OpenGLViewer* pOGLViewer = dynamic_cast<G4OpenGLViewer*>(pVViewer); 209 if (!pSceneHandler) { << 220 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 << 220 if (!pOGLViewer) { 221 if (!pOGLViewer) { 221 G4cout << 222 G4cout << 222 "G4OpenGLViewerMessenger::SetNewValue: C 223 "G4OpenGLViewerMessenger::SetNewValue: Current viewer is not of type" 223 "\n OGL. (It is \"" << 224 "\n OGL. Use \"/vis/viewer/select\" or \"/vis/open\"." 224 << pViewer->GetName() << << 225 "\".)\n Use \"/vis/viewer/select\" or \ << 226 << G4endl; 225 << G4endl; 227 return; 226 return; 228 } 227 } 229 228 230 G4OpenGLSceneHandler* pOGLSceneHandler = << 229 G4OpenGLStoredViewer* pViewer = 231 dynamic_cast<G4OpenGLSceneHandler*>(pSceneHa << 230 dynamic_cast<G4OpenGLStoredViewer*>(pVViewer); 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 { << 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 231 >> 232 if (!pViewer) { >> 233 G4cout << >> 234 "G4OpenGLViewerMessenger::SetNewValue: Current viewer is not of type OGLS." >> 235 "\n The time slice viewing feature is only implemented for OGL Stored" >> 236 "\n viewers at present. Use \"/vis/viewer/select\" or \"/vis/open\"." >> 237 << G4endl; 263 return; 238 return; 264 } 239 } 265 240 266 if (command == fpCommandFlushAt) << 241 if (command == fpCommandDisplayHeadTime) 267 { << 268 static G4bool firstTime = true; << 269 static std::map<G4String,G4OpenGLSceneHand << 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); << 282 iss >> action >> entitiesFlushInterval; << 283 pOGLSceneHandler->SetFlushAction(actionMap << 284 pOGLSceneHandler->SetEntitiesFlushInterval << 285 return; << 286 } << 287 << 288 if (command == fpCommandPrintFilename) << 289 { 242 { 290 G4String name; << 243 G4String display; 291 G4bool inc; << 244 G4double screenX, screenY, screenSize, red, green, blue; 292 std::istringstream iss(newValue); 245 std::istringstream iss(newValue); 293 iss >> name << 246 iss >> display >> screenX >> screenY 294 >> inc; << 247 >> screenSize >> red >> green >> blue; 295 pOGLViewer->setExportFilename(name,inc); << 248 pViewer->fDisplayHeadTime = command->ConvertToBool(display); 296 return; << 249 pViewer->fDisplayHeadTimeX = screenX; >> 250 pViewer->fDisplayHeadTimeY = screenY; >> 251 pViewer->fDisplayHeadTimeSize = screenSize; >> 252 pViewer->fDisplayHeadTimeRed = red; >> 253 pViewer->fDisplayHeadTimeGreen = green; >> 254 pViewer->fDisplayHeadTimeBlue = blue; 297 } 255 } 298 256 299 if (command == fpCommandPrintMode) << 257 if (command == fpCommandDisplayLightFront) 300 { 258 { 301 if (newValue == "vectored") pOGLViewer-> << 259 G4String display, originX, originY, originZ, unitS, originT, unitT; 302 << 260 G4double red, green, blue; 303 if (newValue == "pixmap") pOGLViewer->fV << 261 std::istringstream iss(newValue); 304 return; << 262 iss >> display >> 263 >> originX >> originY >> originZ >> unitS >> 264 >> originT >> unitT >> 265 >> red >> green >> blue; >> 266 pViewer->fDisplayLightFront = command->ConvertToBool(display); >> 267 pViewer->fDisplayLightFrontX = >> 268 command->ConvertToDimensionedDouble(G4String(originX + ' ' + unitS)); >> 269 pViewer->fDisplayLightFrontY = >> 270 command->ConvertToDimensionedDouble(G4String(originY + ' ' + unitS)); >> 271 pViewer->fDisplayLightFrontZ = >> 272 command->ConvertToDimensionedDouble(G4String(originZ + ' ' + unitS)); >> 273 pViewer->fDisplayLightFrontT = >> 274 command->ConvertToDimensionedDouble(G4String(originT + ' ' + unitT)); >> 275 pViewer->fDisplayLightFrontRed = red; >> 276 pViewer->fDisplayLightFrontGreen = green; >> 277 pViewer->fDisplayLightFrontBlue = blue; 305 } 278 } 306 279 307 if (command == fpCommandPrintSize) << 280 if (command == fpCommandEndTime) 308 { 281 { 309 G4int width,height; << 282 G4String end_time_string, end_time_unit, >> 283 time_range_string, time_range_unit; 310 std::istringstream iss(newValue); 284 std::istringstream iss(newValue); 311 iss >> width << 285 iss >> end_time_string >> end_time_unit 312 >> height; << 286 >> time_range_string >> time_range_unit; 313 pOGLViewer->setExportSize(width,height); << 287 pViewer->fEndTime = command->ConvertToDimensionedDouble 314 return; << 288 (G4String(end_time_string + ' ' + end_time_unit)); >> 289 G4double timeRange = command->ConvertToDimensionedDouble >> 290 (G4String(time_range_string + ' ' + time_range_unit)); >> 291 if (timeRange > 0.) { >> 292 pViewer->fStartTime = pViewer->fEndTime - timeRange; >> 293 } >> 294 if (pViewer->fVP.IsAutoRefresh()) >> 295 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh"); 315 } 296 } 316 297 317 if (command == fpCommandTransparency) << 298 if (command == fpCommandFade) 318 { 299 { 319 pOGLViewer->transparency_enabled = comma << 300 pViewer->fFadeFactor = command->ConvertToDouble(newValue); 320 if (pOGLViewer->fVP.IsAutoRefresh()) << 301 if (pViewer->fVP.IsAutoRefresh()) 321 G4UImanager::GetUIpointer()->ApplyCommand("/ << 302 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh"); 322 return; << 323 } 303 } 324 304 325 // Stored viewer commands << 305 if (command == fpCommandStartTime) 326 G4OpenGLStoredViewer* pOGLSViewer = << 327 dynamic_cast<G4OpenGLStoredViewer*>(pViewe << 328 << 329 if (!pOGLSViewer) << 330 { 306 { 331 G4cout << << 307 G4String start_time_string, start_time_unit, 332 "G4OpenGLViewerMessenger::SetNewValue: Curre << 308 time_range_string, time_range_unit; 333 "\n (It is \"" << pViewer->GetName() << "\" << 309 std::istringstream iss(newValue); 334 "\n This feature is only implemented for OG << 310 iss >> start_time_string >> start_time_unit 335 "\n Use \"/vis/viewer/select\" or \"/vis/op << 311 >> time_range_string >> time_range_unit; 336 << G4endl; << 312 pViewer->fStartTime = command->ConvertToDimensionedDouble 337 return; << 313 (G4String(start_time_string + ' ' + start_time_unit)); >> 314 G4double timeRange = command->ConvertToDimensionedDouble >> 315 (G4String(time_range_string + ' ' + time_range_unit)); >> 316 if (timeRange > 0.) { >> 317 pViewer->fEndTime = pViewer->fStartTime + timeRange; >> 318 } >> 319 if (pViewer->fVP.IsAutoRefresh()) >> 320 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh"); 338 } 321 } 339 322 340 // Scene handler commands << 323 if (command == fpCommandTransparency) 341 G4OpenGLStoredSceneHandler* pOGLSSceneHandle << 342 dynamic_cast<G4OpenGLStoredSceneHandler*>( << 343 << 344 if (!pOGLSSceneHandler) { << 345 G4cout << << 346 "G4OpenGLViewerMessenger::SetNewValue: Curre << 347 "\n OGLS (Stored). (Viewer is \"" << pView << 348 "\n (Scene handler is \"" << pSceneHandler- << 349 "\n This feature is only implemented for OG << 350 "\n scene handlers. Use \"/vis/viewer/sele << 351 << G4endl; << 352 return; << 353 } << 354 << 355 if (command == fpCommandDisplayListLimit) << 356 { 324 { 357 G4cerr << command->GetGuidanceLine(0) << << 325 pViewer->transparency_enabled = command->ConvertToBool(newValue); 358 return; << 326 if (pViewer->fVP.IsAutoRefresh()) >> 327 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh"); 359 } 328 } >> 329 360 } 330 } 361 331