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