Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // 26 // 27 27 28 // /vis/set - John Allison 21st March 2012 28 // /vis/set - John Allison 21st March 2012 29 // Set quantities for use in appropriate futur 29 // Set quantities for use in appropriate future commands. 30 30 31 #include "G4VisCommandsSet.hh" 31 #include "G4VisCommandsSet.hh" 32 32 33 #include "G4UIcommand.hh" 33 #include "G4UIcommand.hh" 34 #include "G4UIcmdWithAnInteger.hh" 34 #include "G4UIcmdWithAnInteger.hh" 35 #include "G4UIcmdWithADouble.hh" 35 #include "G4UIcmdWithADouble.hh" 36 #include "G4UIcmdWithAString.hh" 36 #include "G4UIcmdWithAString.hh" 37 #include "G4UIcmdWithABool.hh" 37 #include "G4UIcmdWithABool.hh" 38 #include "G4TouchablePropertiesScene.hh" 38 #include "G4TouchablePropertiesScene.hh" 39 #include "G4TransportationManager.hh" 39 #include "G4TransportationManager.hh" 40 #include "G4BoundingExtentScene.hh" 40 #include "G4BoundingExtentScene.hh" 41 << 42 #include <sstream> 41 #include <sstream> 43 #include <utility> << 44 << 45 #define G4warn G4cout << 46 42 47 ////////////// /vis/set/arrow3DLineSegmentsPer 43 ////////////// /vis/set/arrow3DLineSegmentsPerCircle //////////////////////////////////// 48 44 49 G4VisCommandSetArrow3DLineSegmentsPerCircle::G 45 G4VisCommandSetArrow3DLineSegmentsPerCircle::G4VisCommandSetArrow3DLineSegmentsPerCircle () 50 { 46 { 51 G4bool omitable; 47 G4bool omitable; 52 fpCommand = new G4UIcmdWithAnInteger("/vis/s 48 fpCommand = new G4UIcmdWithAnInteger("/vis/set/arrow3DLineSegmentsPerCircle", this); 53 fpCommand->SetGuidance 49 fpCommand->SetGuidance 54 ("Defines number of line segments per circle 50 ("Defines number of line segments per circle for drawing 3D arrows" 55 " for future \"/vis/scene/add/\" commands." 51 " for future \"/vis/scene/add/\" commands."); 56 fpCommand->SetParameterName ("number", omita 52 fpCommand->SetParameterName ("number", omitable = true); 57 fpCommand->SetDefaultValue (6); 53 fpCommand->SetDefaultValue (6); 58 fpCommand->SetRange("number >= 3"); 54 fpCommand->SetRange("number >= 3"); 59 } 55 } 60 56 61 G4VisCommandSetArrow3DLineSegmentsPerCircle::~ 57 G4VisCommandSetArrow3DLineSegmentsPerCircle::~G4VisCommandSetArrow3DLineSegmentsPerCircle () 62 { 58 { 63 delete fpCommand; 59 delete fpCommand; 64 } 60 } 65 61 66 G4String G4VisCommandSetArrow3DLineSegmentsPer 62 G4String G4VisCommandSetArrow3DLineSegmentsPerCircle::GetCurrentValue (G4UIcommand*) 67 { 63 { 68 return G4String(); 64 return G4String(); 69 } 65 } 70 66 71 void G4VisCommandSetArrow3DLineSegmentsPerCirc 67 void G4VisCommandSetArrow3DLineSegmentsPerCircle::SetNewValue (G4UIcommand*, G4String newValue) 72 { 68 { 73 G4VisManager::Verbosity verbosity = fpVisMan 69 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity(); 74 70 75 fCurrentArrow3DLineSegmentsPerCircle = fpCom 71 fCurrentArrow3DLineSegmentsPerCircle = fpCommand->GetNewIntValue(newValue); 76 72 77 if (verbosity >= G4VisManager::confirmations 73 if (verbosity >= G4VisManager::confirmations) { 78 G4cout << 74 G4cout << 79 "Number of line segments per circle for dr 75 "Number of line segments per circle for drawing 3D arrows for future" 80 "\n \"/vis/scene/add/\" commands has been 76 "\n \"/vis/scene/add/\" commands has been set to " 81 << fCurrentArrow3DLineSegmentsPerCircle 77 << fCurrentArrow3DLineSegmentsPerCircle 82 << G4endl; 78 << G4endl; 83 } 79 } 84 } 80 } 85 81 86 ////////////// /vis/set/colour /////////////// 82 ////////////// /vis/set/colour //////////////////////////////////// 87 83 88 G4VisCommandSetColour::G4VisCommandSetColour ( 84 G4VisCommandSetColour::G4VisCommandSetColour () 89 { 85 { 90 G4bool omitable; 86 G4bool omitable; 91 fpCommand = new G4UIcommand("/vis/set/colour 87 fpCommand = new G4UIcommand("/vis/set/colour", this); 92 fpCommand->SetGuidance 88 fpCommand->SetGuidance 93 ("Defines colour and opacity for future \"/v 89 ("Defines colour and opacity for future \"/vis/scene/add/\" commands."); 94 fpCommand->SetGuidance 90 fpCommand->SetGuidance 95 ("(Except \"/vis/scene/add/text\" commands - 91 ("(Except \"/vis/scene/add/text\" commands - see \"/vis/set/textColour\".)"); 96 fpCommand->SetGuidance(ConvertToColourGuidan 92 fpCommand->SetGuidance(ConvertToColourGuidance()); 97 fpCommand->SetGuidance("Default: white and o 93 fpCommand->SetGuidance("Default: white and opaque."); 98 G4UIparameter* parameter; 94 G4UIparameter* parameter; 99 parameter = new G4UIparameter ("red", 's', o 95 parameter = new G4UIparameter ("red", 's', omitable = true); 100 parameter->SetGuidance 96 parameter->SetGuidance 101 ("Red component or a string, e.g., \"cyan\" 97 ("Red component or a string, e.g., \"cyan\" (green and blue parameters are ignored)."); 102 parameter->SetDefaultValue ("1."); 98 parameter->SetDefaultValue ("1."); 103 fpCommand->SetParameter (parameter); 99 fpCommand->SetParameter (parameter); 104 parameter = new G4UIparameter ("green", 'd', 100 parameter = new G4UIparameter ("green", 'd', omitable = true); 105 parameter->SetDefaultValue (1.); 101 parameter->SetDefaultValue (1.); 106 fpCommand->SetParameter (parameter); 102 fpCommand->SetParameter (parameter); 107 parameter = new G4UIparameter ("blue", 'd', 103 parameter = new G4UIparameter ("blue", 'd', omitable = true); 108 parameter->SetDefaultValue (1.); 104 parameter->SetDefaultValue (1.); 109 fpCommand->SetParameter (parameter); 105 fpCommand->SetParameter (parameter); 110 parameter = new G4UIparameter ("alpha", 'd', 106 parameter = new G4UIparameter ("alpha", 'd', omitable = true); 111 parameter->SetDefaultValue (1.); 107 parameter->SetDefaultValue (1.); 112 parameter->SetGuidance ("Opacity"); 108 parameter->SetGuidance ("Opacity"); 113 fpCommand->SetParameter (parameter); 109 fpCommand->SetParameter (parameter); 114 } 110 } 115 111 116 G4VisCommandSetColour::~G4VisCommandSetColour 112 G4VisCommandSetColour::~G4VisCommandSetColour () 117 { 113 { 118 delete fpCommand; 114 delete fpCommand; 119 } 115 } 120 116 121 G4String G4VisCommandSetColour::GetCurrentValu 117 G4String G4VisCommandSetColour::GetCurrentValue (G4UIcommand*) 122 { 118 { 123 return G4String(); 119 return G4String(); 124 } 120 } 125 121 126 void G4VisCommandSetColour::SetNewValue (G4UIc 122 void G4VisCommandSetColour::SetNewValue (G4UIcommand*, G4String newValue) 127 { 123 { 128 G4VisManager::Verbosity verbosity = fpVisMan 124 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity(); 129 125 130 G4String redOrString; 126 G4String redOrString; 131 G4double green, blue, opacity; 127 G4double green, blue, opacity; 132 std::istringstream iss(newValue); 128 std::istringstream iss(newValue); 133 iss >> redOrString >> green >> blue >> opaci 129 iss >> redOrString >> green >> blue >> opacity; 134 130 135 ConvertToColour(fCurrentColour, redOrString, 131 ConvertToColour(fCurrentColour, redOrString, green, blue, opacity); 136 132 137 if (verbosity >= G4VisManager::confirmations 133 if (verbosity >= G4VisManager::confirmations) { 138 G4cout << 134 G4cout << 139 "Colour for future \"/vis/scene/add/\" com 135 "Colour for future \"/vis/scene/add/\" commands has been set to " 140 << fCurrentColour << 136 << fCurrentColour << 141 ".\n(Except \"/vis/scene/add/text\" comman 137 ".\n(Except \"/vis/scene/add/text\" commands - use \"/vis/set/textColour\".)" 142 << G4endl; 138 << G4endl; 143 } 139 } 144 } 140 } 145 141 146 ////////////// /vis/set/extentForField /////// 142 ////////////// /vis/set/extentForField //////////////////////////////////// 147 143 148 G4VisCommandSetExtentForField::G4VisCommandSet 144 G4VisCommandSetExtentForField::G4VisCommandSetExtentForField () 149 { 145 { 150 G4bool omitable; 146 G4bool omitable; 151 fpCommand = new G4UIcommand("/vis/set/extent 147 fpCommand = new G4UIcommand("/vis/set/extentForField", this); 152 fpCommand->SetGuidance 148 fpCommand->SetGuidance 153 ("Sets an extent for future \"/vis/scene/add 149 ("Sets an extent for future \"/vis/scene/add/*Field\" commands."); 154 fpCommand->SetGuidance 150 fpCommand->SetGuidance 155 ("The default is a null extent, which is int 151 ("The default is a null extent, which is interpreted by the commands as the" 156 "\nextent of the whole scene."); 152 "\nextent of the whole scene."); 157 G4UIparameter* parameter; 153 G4UIparameter* parameter; 158 parameter = new G4UIparameter ("xmin", 'd', << 154 parameter = new G4UIparameter ("xmin", 'd', omitable = true); >> 155 parameter->SetDefaultValue (0.); 159 fpCommand->SetParameter (parameter); 156 fpCommand->SetParameter (parameter); 160 parameter = new G4UIparameter ("xmax", 'd', << 157 parameter = new G4UIparameter ("xmax", 'd', omitable = true); >> 158 parameter->SetDefaultValue (0.); 161 fpCommand->SetParameter (parameter); 159 fpCommand->SetParameter (parameter); 162 parameter = new G4UIparameter ("ymin", 'd', << 160 parameter = new G4UIparameter ("ymin", 'd', omitable = true); >> 161 parameter->SetDefaultValue (0.); 163 fpCommand->SetParameter (parameter); 162 fpCommand->SetParameter (parameter); 164 parameter = new G4UIparameter ("ymax", 'd', << 163 parameter = new G4UIparameter ("ymax", 'd', omitable = true); >> 164 parameter->SetDefaultValue (0.); 165 fpCommand->SetParameter (parameter); 165 fpCommand->SetParameter (parameter); 166 parameter = new G4UIparameter ("zmin", 'd', << 166 parameter = new G4UIparameter ("zmin", 'd', omitable = true); >> 167 parameter->SetDefaultValue (0.); 167 fpCommand->SetParameter (parameter); 168 fpCommand->SetParameter (parameter); 168 parameter = new G4UIparameter ("zmax", 'd', << 169 parameter = new G4UIparameter ("zmax", 'd', omitable = true); >> 170 parameter->SetDefaultValue (0.); 169 fpCommand->SetParameter (parameter); 171 fpCommand->SetParameter (parameter); 170 parameter = new G4UIparameter ("unit", 's', << 172 parameter = new G4UIparameter ("unit", 's', omitable = true); >> 173 parameter->SetDefaultValue ("m"); 171 fpCommand->SetParameter (parameter); 174 fpCommand->SetParameter (parameter); 172 } 175 } 173 176 174 G4VisCommandSetExtentForField::~G4VisCommandSe 177 G4VisCommandSetExtentForField::~G4VisCommandSetExtentForField () 175 { 178 { 176 delete fpCommand; 179 delete fpCommand; 177 } 180 } 178 181 179 G4String G4VisCommandSetExtentForField::GetCur 182 G4String G4VisCommandSetExtentForField::GetCurrentValue (G4UIcommand*) 180 { 183 { 181 return G4String(); 184 return G4String(); 182 } 185 } 183 186 184 void G4VisCommandSetExtentForField::SetNewValu 187 void G4VisCommandSetExtentForField::SetNewValue (G4UIcommand*, G4String newValue) 185 { 188 { 186 G4VisManager::Verbosity verbosity = fpVisMan 189 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity(); 187 190 188 G4double xmin, xmax, ymin, ymax, zmin, zmax; 191 G4double xmin, xmax, ymin, ymax, zmin, zmax; 189 G4String unitString; 192 G4String unitString; 190 std::istringstream iss(newValue); 193 std::istringstream iss(newValue); 191 iss >> xmin >> xmax >> ymin >> ymax >> zmin 194 iss >> xmin >> xmax >> ymin >> ymax >> zmin >> zmax >> unitString; 192 G4double unit = G4UIcommand::ValueOf(unitStr 195 G4double unit = G4UIcommand::ValueOf(unitString); 193 xmin *= unit; xmax *= unit; 196 xmin *= unit; xmax *= unit; 194 ymin *= unit; ymax *= unit; 197 ymin *= unit; ymax *= unit; 195 zmin *= unit; zmax *= unit; 198 zmin *= unit; zmax *= unit; 196 199 197 fCurrentExtentForField = G4VisExtent(xmin,xm 200 fCurrentExtentForField = G4VisExtent(xmin,xmax,ymin,ymax,zmin,zmax); 198 fCurrrentPVFindingsForField.clear(); 201 fCurrrentPVFindingsForField.clear(); 199 202 200 if (verbosity >= G4VisManager::confirmations 203 if (verbosity >= G4VisManager::confirmations) { 201 G4cout << 204 G4cout << 202 "Extent for future \"/vis/scene/add/*Field 205 "Extent for future \"/vis/scene/add/*Field\" commands has been set to " 203 << fCurrentExtentForField 206 << fCurrentExtentForField 204 << "\nVolume for field has been cleared." 207 << "\nVolume for field has been cleared." 205 << G4endl; 208 << G4endl; 206 } 209 } 207 } 210 } 208 211 209 ////////////// /vis/set/lineWidth //////////// 212 ////////////// /vis/set/lineWidth //////////////////////////////////// 210 213 211 G4VisCommandSetLineWidth::G4VisCommandSetLineW 214 G4VisCommandSetLineWidth::G4VisCommandSetLineWidth () 212 { 215 { 213 G4bool omitable; 216 G4bool omitable; 214 fpCommand = new G4UIcmdWithADouble("/vis/set 217 fpCommand = new G4UIcmdWithADouble("/vis/set/lineWidth", this); 215 fpCommand->SetGuidance 218 fpCommand->SetGuidance 216 ("Defines line width for future \"/vis/scene << 219 ("Defines line width for future \"/vis/scene/add/\" commands."); 217 "\nSee \"/vis/viewer/set/lineWidth\" for mo << 218 fpCommand->SetParameterName ("lineWidth", om 220 fpCommand->SetParameterName ("lineWidth", omitable = true); 219 fpCommand->SetDefaultValue (1.); 221 fpCommand->SetDefaultValue (1.); 220 fpCommand->SetRange("lineWidth >= 1."); 222 fpCommand->SetRange("lineWidth >= 1."); 221 } 223 } 222 224 223 G4VisCommandSetLineWidth::~G4VisCommandSetLine 225 G4VisCommandSetLineWidth::~G4VisCommandSetLineWidth () 224 { 226 { 225 delete fpCommand; 227 delete fpCommand; 226 } 228 } 227 229 228 G4String G4VisCommandSetLineWidth::GetCurrentV 230 G4String G4VisCommandSetLineWidth::GetCurrentValue (G4UIcommand*) 229 { 231 { 230 return G4String(); 232 return G4String(); 231 } 233 } 232 234 233 void G4VisCommandSetLineWidth::SetNewValue (G4 235 void G4VisCommandSetLineWidth::SetNewValue (G4UIcommand*, G4String newValue) 234 { 236 { 235 G4VisManager::Verbosity verbosity = fpVisMan 237 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity(); 236 238 237 fCurrentLineWidth = fpCommand->GetNewDoubleV 239 fCurrentLineWidth = fpCommand->GetNewDoubleValue(newValue); 238 240 239 if (verbosity >= G4VisManager::warnings) { << 241 if (verbosity >= G4VisManager::confirmations) { 240 G4warn << << 242 G4cout << 241 "Line width for *future* \"/vis/scene/add/ << 243 "Line width for future \"/vis/scene/add/\" commands has been set to " 242 << fCurrentLineWidth << << 244 << fCurrentLineWidth 243 "\nSee \"/vis/viewer/set/lineWidth\" for m << 245 << G4endl; 244 << G4endl; << 245 } 246 } 246 } 247 } 247 248 248 ////////////// /vis/set/textColour /////////// 249 ////////////// /vis/set/textColour //////////////////////////////////// 249 250 250 G4VisCommandSetTextColour::G4VisCommandSetText 251 G4VisCommandSetTextColour::G4VisCommandSetTextColour () 251 { 252 { 252 G4bool omitable; 253 G4bool omitable; 253 fpCommand = new G4UIcommand("/vis/set/textCo 254 fpCommand = new G4UIcommand("/vis/set/textColour", this); 254 fpCommand->SetGuidance 255 fpCommand->SetGuidance 255 ("Defines colour and opacity for future \" 256 ("Defines colour and opacity for future \"/vis/scene/add/text\" commands."); 256 fpCommand->SetGuidance(ConvertToColourGuidan 257 fpCommand->SetGuidance(ConvertToColourGuidance()); 257 fpCommand->SetGuidance("Default: blue and op 258 fpCommand->SetGuidance("Default: blue and opaque."); 258 G4UIparameter* parameter; 259 G4UIparameter* parameter; 259 parameter = new G4UIparameter ("red", 's', o 260 parameter = new G4UIparameter ("red", 's', omitable = true); 260 parameter->SetGuidance 261 parameter->SetGuidance 261 ("Red component or a string, e.g., \"cyan\ 262 ("Red component or a string, e.g., \"cyan\" (green and blue parameters are ignored)."); 262 parameter->SetDefaultValue ("0."); 263 parameter->SetDefaultValue ("0."); 263 fpCommand->SetParameter (parameter); 264 fpCommand->SetParameter (parameter); 264 parameter = new G4UIparameter ("green", 'd', 265 parameter = new G4UIparameter ("green", 'd', omitable = true); 265 parameter->SetDefaultValue (0.); 266 parameter->SetDefaultValue (0.); 266 fpCommand->SetParameter (parameter); 267 fpCommand->SetParameter (parameter); 267 parameter = new G4UIparameter ("blue", 'd', 268 parameter = new G4UIparameter ("blue", 'd', omitable = true); 268 parameter->SetDefaultValue (1.); 269 parameter->SetDefaultValue (1.); 269 fpCommand->SetParameter (parameter); 270 fpCommand->SetParameter (parameter); 270 parameter = new G4UIparameter ("alpha", 'd', 271 parameter = new G4UIparameter ("alpha", 'd', omitable = true); 271 parameter->SetDefaultValue (1.); 272 parameter->SetDefaultValue (1.); 272 parameter->SetGuidance ("Opacity"); 273 parameter->SetGuidance ("Opacity"); 273 fpCommand->SetParameter (parameter); 274 fpCommand->SetParameter (parameter); 274 } 275 } 275 276 276 G4VisCommandSetTextColour::~G4VisCommandSetTex 277 G4VisCommandSetTextColour::~G4VisCommandSetTextColour () 277 { 278 { 278 delete fpCommand; 279 delete fpCommand; 279 } 280 } 280 281 281 G4String G4VisCommandSetTextColour::GetCurrent 282 G4String G4VisCommandSetTextColour::GetCurrentValue (G4UIcommand*) 282 { 283 { 283 return G4String(); 284 return G4String(); 284 } 285 } 285 286 286 void G4VisCommandSetTextColour::SetNewValue (G 287 void G4VisCommandSetTextColour::SetNewValue (G4UIcommand*, G4String newValue) 287 { 288 { 288 G4VisManager::Verbosity verbosity = fpVisMan 289 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity(); 289 290 290 G4String redOrString; 291 G4String redOrString; 291 G4double green, blue, opacity; 292 G4double green, blue, opacity; 292 std::istringstream iss(newValue); 293 std::istringstream iss(newValue); 293 iss >> redOrString >> green >> blue >> opaci 294 iss >> redOrString >> green >> blue >> opacity; 294 295 295 ConvertToColour(fCurrentTextColour, redOrStr 296 ConvertToColour(fCurrentTextColour, redOrString, green, blue, opacity); 296 297 297 if (verbosity >= G4VisManager::confirmations 298 if (verbosity >= G4VisManager::confirmations) { 298 G4cout << 299 G4cout << 299 "Colour for future \"/vis/scene/add/text 300 "Colour for future \"/vis/scene/add/text\" commands has been set to " 300 << fCurrentTextColour << '.' 301 << fCurrentTextColour << '.' 301 << G4endl; 302 << G4endl; 302 } 303 } 303 } 304 } 304 305 305 ////////////// /vis/set/textLayout /////////// 306 ////////////// /vis/set/textLayout //////////////////////////////////// 306 307 307 G4VisCommandSetTextLayout::G4VisCommandSetText 308 G4VisCommandSetTextLayout::G4VisCommandSetTextLayout () 308 { 309 { 309 G4bool omitable; 310 G4bool omitable; 310 fpCommand = new G4UIcmdWithAString("/vis/set 311 fpCommand = new G4UIcmdWithAString("/vis/set/textLayout", this); 311 fpCommand->SetGuidance 312 fpCommand->SetGuidance 312 ("Defines layout future \"/vis/scene/add/t 313 ("Defines layout future \"/vis/scene/add/text\" commands."); 313 fpCommand->SetGuidance 314 fpCommand->SetGuidance 314 ("\"left\" (default) for left justificatio 315 ("\"left\" (default) for left justification to provided coordinate."); 315 fpCommand->SetGuidance 316 fpCommand->SetGuidance 316 ("\"centre\" or \"center\" for text center 317 ("\"centre\" or \"center\" for text centered on provided coordinate."); 317 fpCommand->SetGuidance 318 fpCommand->SetGuidance 318 ("\"right\" for right justification to pro 319 ("\"right\" for right justification to provided coordinate."); 319 fpCommand->SetGuidance("Default: left."); 320 fpCommand->SetGuidance("Default: left."); 320 fpCommand->SetParameterName("layout", omitab 321 fpCommand->SetParameterName("layout", omitable = true); 321 fpCommand->SetCandidates ("left centre cente 322 fpCommand->SetCandidates ("left centre center right"); 322 fpCommand->SetDefaultValue ("left"); 323 fpCommand->SetDefaultValue ("left"); 323 } 324 } 324 325 325 G4VisCommandSetTextLayout::~G4VisCommandSetTex 326 G4VisCommandSetTextLayout::~G4VisCommandSetTextLayout () 326 { 327 { 327 delete fpCommand; 328 delete fpCommand; 328 } 329 } 329 330 330 G4String G4VisCommandSetTextLayout::GetCurrent 331 G4String G4VisCommandSetTextLayout::GetCurrentValue (G4UIcommand*) 331 { 332 { 332 return G4String(); 333 return G4String(); 333 } 334 } 334 335 335 void G4VisCommandSetTextLayout::SetNewValue (G 336 void G4VisCommandSetTextLayout::SetNewValue (G4UIcommand*, G4String newValue) 336 { 337 { 337 G4Text::Layout layout = G4Text::left; 338 G4Text::Layout layout = G4Text::left; 338 if (newValue == "left") layout = G4Text::lef 339 if (newValue == "left") layout = G4Text::left; 339 else if (newValue == "centre" || newValue == 340 else if (newValue == "centre" || newValue == "center") 340 layout = G4Text::centre; 341 layout = G4Text::centre; 341 else if (newValue == "right") layout = G4Tex 342 else if (newValue == "right") layout = G4Text::right; 342 343 343 fCurrentTextLayout = layout; 344 fCurrentTextLayout = layout; 344 345 345 G4VisManager::Verbosity verbosity = fpVisMan 346 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity(); 346 if (verbosity >= G4VisManager::confirmations 347 if (verbosity >= G4VisManager::confirmations) { 347 G4cout << "Text layout (for future \"text\ 348 G4cout << "Text layout (for future \"text\" commands) has been set to \"" 348 << fCurrentTextLayout << "\"." 349 << fCurrentTextLayout << "\"." 349 << G4endl; 350 << G4endl; 350 } 351 } 351 } 352 } 352 353 353 ////////////// /vis/set/textSize ///////////// 354 ////////////// /vis/set/textSize //////////////////////////////////// 354 355 355 G4VisCommandSetTextSize::G4VisCommandSetTextSi 356 G4VisCommandSetTextSize::G4VisCommandSetTextSize () 356 { 357 { 357 G4bool omitable; 358 G4bool omitable; 358 fpCommand = new G4UIcmdWithADouble("/vis/set 359 fpCommand = new G4UIcmdWithADouble("/vis/set/textSize", this); 359 fpCommand->SetGuidance 360 fpCommand->SetGuidance 360 ("Defines text size (pixels) for future \"/v 361 ("Defines text size (pixels) for future \"/vis/scene/add/\" commands."); 361 fpCommand->SetParameterName ("textSize", omi 362 fpCommand->SetParameterName ("textSize", omitable = true); 362 fpCommand->SetDefaultValue (12.); // pixels 363 fpCommand->SetDefaultValue (12.); // pixels 363 fpCommand->SetRange("textSize >= 8."); 364 fpCommand->SetRange("textSize >= 8."); 364 } 365 } 365 366 366 G4VisCommandSetTextSize::~G4VisCommandSetTextS 367 G4VisCommandSetTextSize::~G4VisCommandSetTextSize () 367 { 368 { 368 delete fpCommand; 369 delete fpCommand; 369 } 370 } 370 371 371 G4String G4VisCommandSetTextSize::GetCurrentVa 372 G4String G4VisCommandSetTextSize::GetCurrentValue (G4UIcommand*) 372 { 373 { 373 return G4String(); 374 return G4String(); 374 } 375 } 375 376 376 void G4VisCommandSetTextSize::SetNewValue (G4U 377 void G4VisCommandSetTextSize::SetNewValue (G4UIcommand*, G4String newValue) 377 { 378 { 378 G4VisManager::Verbosity verbosity = fpVisMan 379 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity(); 379 380 380 fCurrentTextSize = fpCommand->GetNewDoubleVa 381 fCurrentTextSize = fpCommand->GetNewDoubleValue(newValue); 381 382 382 if (verbosity >= G4VisManager::confirmations 383 if (verbosity >= G4VisManager::confirmations) { 383 G4cout << 384 G4cout << 384 "Text size for future \"/vis/scene/add/\" 385 "Text size for future \"/vis/scene/add/\" commands has been set to " 385 << fCurrentTextSize 386 << fCurrentTextSize 386 << G4endl; 387 << G4endl; 387 } 388 } 388 } 389 } 389 390 390 ////////////// /vis/set/touchable //////////// 391 ////////////// /vis/set/touchable //////////////////////////////////// 391 392 392 G4VisCommandSetTouchable::G4VisCommandSetTouch 393 G4VisCommandSetTouchable::G4VisCommandSetTouchable () 393 { 394 { 394 G4bool omitable; 395 G4bool omitable; 395 G4UIparameter* parameter; 396 G4UIparameter* parameter; 396 fpCommand = new G4UIcommand("/vis/set/toucha 397 fpCommand = new G4UIcommand("/vis/set/touchable", this); 397 fpCommand->SetGuidance 398 fpCommand->SetGuidance 398 ("Defines touchable for future \"/vis/toucha 399 ("Defines touchable for future \"/vis/touchable/set/\" commands."); 399 fpCommand->SetGuidance 400 fpCommand->SetGuidance 400 ("Please provide a list of space-separated p 401 ("Please provide a list of space-separated physical volume names and" 401 "\ncopy number pairs starting at the world 402 "\ncopy number pairs starting at the world volume, e.g:" 402 "\n /vis/set/touchable World 0 Envelope 0 403 "\n /vis/set/touchable World 0 Envelope 0 Shape1 0" 403 "\n(To get list of touchables, use \"/vis/d 404 "\n(To get list of touchables, use \"/vis/drawTree\")" 404 "\n(To save, use \"/vis/viewer/save\")"); 405 "\n(To save, use \"/vis/viewer/save\")"); 405 parameter = new G4UIparameter ("list", 's', 406 parameter = new G4UIparameter ("list", 's', omitable = true); 406 parameter->SetGuidance 407 parameter->SetGuidance 407 ("List of physical volume names and copy num 408 ("List of physical volume names and copy number pairs"); 408 fpCommand->SetParameter (parameter); 409 fpCommand->SetParameter (parameter); 409 } 410 } 410 411 411 G4VisCommandSetTouchable::~G4VisCommandSetTouc 412 G4VisCommandSetTouchable::~G4VisCommandSetTouchable () 412 { 413 { 413 delete fpCommand; 414 delete fpCommand; 414 } 415 } 415 416 416 G4String G4VisCommandSetTouchable::GetCurrentV 417 G4String G4VisCommandSetTouchable::GetCurrentValue (G4UIcommand*) 417 { 418 { 418 return G4String(); 419 return G4String(); 419 } 420 } 420 421 421 void G4VisCommandSetTouchable::SetNewValue (G4 422 void G4VisCommandSetTouchable::SetNewValue (G4UIcommand*, G4String newValue) 422 { 423 { 423 G4VisManager::Verbosity verbosity = fpVisMan 424 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity(); 424 425 425 if (newValue.empty()) { << 426 if (newValue.isNull()) { 426 fCurrentTouchableProperties = G4PhysicalVo 427 fCurrentTouchableProperties = G4PhysicalVolumeModel::TouchableProperties(); 427 if (verbosity >= G4VisManager::confirmatio 428 if (verbosity >= G4VisManager::confirmations) { 428 G4cout << 429 G4cout << 429 "Current touchable reset to: " << fCurre 430 "Current touchable reset to: " << fCurrentTouchableProperties.fTouchablePath 430 << G4endl; 431 << G4endl; 431 } 432 } 432 return; 433 return; 433 } 434 } 434 435 435 G4ModelingParameters::PVNameCopyNoPath curre 436 G4ModelingParameters::PVNameCopyNoPath currentTouchablePath; 436 437 437 // Algorithm from Josuttis p.476. 438 // Algorithm from Josuttis p.476. 438 G4String::size_type iBegin, iEnd; 439 G4String::size_type iBegin, iEnd; 439 iBegin = newValue.find_first_not_of(' '); 440 iBegin = newValue.find_first_not_of(' '); 440 while (iBegin != G4String::npos) { 441 while (iBegin != G4String::npos) { 441 iEnd = newValue.find_first_of(' ',iBegin); 442 iEnd = newValue.find_first_of(' ',iBegin); 442 if (iEnd == G4String::npos) { 443 if (iEnd == G4String::npos) { 443 iEnd = newValue.length(); 444 iEnd = newValue.length(); 444 } 445 } 445 const G4String& name(newValue.substr(iBegi << 446 G4String name(newValue.substr(iBegin,iEnd-iBegin)); 446 iBegin = newValue.find_first_not_of(' ',iE 447 iBegin = newValue.find_first_not_of(' ',iEnd); 447 if (iBegin == G4String::npos) { 448 if (iBegin == G4String::npos) { 448 if (verbosity >= G4VisManager::warnings) 449 if (verbosity >= G4VisManager::warnings) { 449 G4warn << << 450 G4cout << 450 "WARNING: G4VisCommandSetTouchable::Se 451 "WARNING: G4VisCommandSetTouchable::SetNewValue" 451 "\n A pair not found. (There should be an << 452 "\n A pair not found. (Did you have an even number of parameters?)" 452 "\n Command ignored." 453 "\n Command ignored." 453 << G4endl; 454 << G4endl; 454 return; 455 return; 455 } 456 } 456 } 457 } 457 iEnd = newValue.find_first_of(' ',iBegin); 458 iEnd = newValue.find_first_of(' ',iBegin); 458 if (iEnd == G4String::npos) { 459 if (iEnd == G4String::npos) { 459 iEnd = newValue.length(); 460 iEnd = newValue.length(); 460 } 461 } 461 G4int copyNo; 462 G4int copyNo; 462 std::istringstream iss(newValue.substr(iBe 463 std::istringstream iss(newValue.substr(iBegin,iEnd-iBegin)); 463 if (!(iss >> copyNo)) { 464 if (!(iss >> copyNo)) { 464 if (verbosity >= G4VisManager::warnings) 465 if (verbosity >= G4VisManager::warnings) { 465 G4warn << << 466 G4cout << 466 "WARNING: G4VisCommandSetTouchable::Se 467 "WARNING: G4VisCommandSetTouchable::SetNewValue" 467 "\n Error reading copy number - it wa 468 "\n Error reading copy number - it was not numeric?" 468 "\n Command ignored." 469 "\n Command ignored." 469 << G4endl; 470 << G4endl; 470 return; 471 return; 471 } 472 } 472 } 473 } 473 currentTouchablePath.push_back 474 currentTouchablePath.push_back 474 (G4ModelingParameters::PVNameCopyNo(name,c 475 (G4ModelingParameters::PVNameCopyNo(name,copyNo)); 475 iBegin = newValue.find_first_not_of(' ',iE 476 iBegin = newValue.find_first_not_of(' ',iEnd); 476 } 477 } 477 478 478 // Check validity 479 // Check validity 479 G4bool successful = false; 480 G4bool successful = false; 480 G4TransportationManager* transportationManag 481 G4TransportationManager* transportationManager = 481 G4TransportationManager::GetTransportationMa 482 G4TransportationManager::GetTransportationManager (); 482 size_t nWorlds = transportationManager->GetN 483 size_t nWorlds = transportationManager->GetNoWorlds(); 483 std::vector<G4VPhysicalVolume*>::iterator it 484 std::vector<G4VPhysicalVolume*>::iterator iterWorld = 484 transportationManager->GetWorldsIterator(); 485 transportationManager->GetWorldsIterator(); 485 for (size_t i = 0; i < nWorlds; ++i, ++iterW 486 for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) { 486 G4PhysicalVolumeModel pvModel (*iterWorld) 487 G4PhysicalVolumeModel pvModel (*iterWorld); // Unlimited depth. 487 G4ModelingParameters mp; // Default - no 488 G4ModelingParameters mp; // Default - no culling. 488 pvModel.SetModelingParameters (&mp); 489 pvModel.SetModelingParameters (&mp); 489 G4TouchablePropertiesScene scene (&pvModel 490 G4TouchablePropertiesScene scene (&pvModel,currentTouchablePath); 490 pvModel.DescribeYourselfTo (scene); // In 491 pvModel.DescribeYourselfTo (scene); // Initiate geometry tree traversal. 491 if (scene.GetFoundTouchableProperties().fp 492 if (scene.GetFoundTouchableProperties().fpTouchablePV) { 492 successful = true; 493 successful = true; 493 fCurrentTouchableProperties = scene.GetF 494 fCurrentTouchableProperties = scene.GetFoundTouchableProperties(); 494 break; // Found, so no need to scan mor 495 break; // Found, so no need to scan more worlds. 495 } 496 } 496 } 497 } 497 498 498 if (successful) { 499 if (successful) { 499 if (verbosity >= G4VisManager::confirmatio 500 if (verbosity >= G4VisManager::confirmations) { 500 G4cout << 501 G4cout << 501 "Current touchable: " << fCurrentTouchab 502 "Current touchable: " << fCurrentTouchableProperties.fTouchablePath 502 << G4endl; 503 << G4endl; 503 return; 504 return; 504 } 505 } 505 } else { 506 } else { 506 if (verbosity >= G4VisManager::warnings) { 507 if (verbosity >= G4VisManager::warnings) { 507 G4warn << << 508 G4cout << 508 "WARNING: G4VisCommandSetTouchable::SetN 509 "WARNING: G4VisCommandSetTouchable::SetNewValue" 509 "\n Touchable not found." 510 "\n Touchable not found." 510 << G4endl; 511 << G4endl; 511 return; 512 return; 512 } 513 } 513 } 514 } 514 } 515 } 515 516 516 ////////////// /vis/set/volumeForField /////// 517 ////////////// /vis/set/volumeForField //////////////////////////////////// 517 518 518 G4VisCommandSetVolumeForField::G4VisCommandSet 519 G4VisCommandSetVolumeForField::G4VisCommandSetVolumeForField () 519 { 520 { 520 G4bool omitable; 521 G4bool omitable; 521 G4UIparameter* parameter; 522 G4UIparameter* parameter; 522 fpCommand = new G4UIcommand("/vis/set/volume 523 fpCommand = new G4UIcommand("/vis/set/volumeForField", this); 523 fpCommand->SetGuidance 524 fpCommand->SetGuidance 524 ("Sets a volume for \"/vis/scene/add/*Field\ 525 ("Sets a volume for \"/vis/scene/add/*Field\" commands."); 525 fpCommand->SetGuidance 526 fpCommand->SetGuidance 526 ("Takes a volume name or a /regular expressi 527 ("Takes a volume name or a /regular expression/ -- see guidance for" 527 "\n\"/vis/drawVolume\""); 528 "\n\"/vis/drawVolume\""); 528 parameter = new G4UIparameter ("physical-vol << 529 parameter = new G4UIparameter ("physical-volume-name", 's', omitable = true); >> 530 parameter -> SetDefaultValue ("none"); 529 fpCommand -> SetParameter (parameter); 531 fpCommand -> SetParameter (parameter); 530 parameter = new G4UIparameter ("copy-no", 'i 532 parameter = new G4UIparameter ("copy-no", 'i', omitable = true); 531 parameter -> SetGuidance ("If negative, matc 533 parameter -> SetGuidance ("If negative, matches any copy no."); 532 parameter -> SetDefaultValue (-1); 534 parameter -> SetDefaultValue (-1); 533 fpCommand -> SetParameter (parameter); 535 fpCommand -> SetParameter (parameter); 534 parameter = new G4UIparameter ("draw", 'b', 536 parameter = new G4UIparameter ("draw", 'b', omitable = true); 535 parameter -> SetGuidance ("If true, draw ext 537 parameter -> SetGuidance ("If true, draw extent of found volumes."); 536 parameter -> SetDefaultValue (false); 538 parameter -> SetDefaultValue (false); 537 fpCommand -> SetParameter (parameter); 539 fpCommand -> SetParameter (parameter); 538 } 540 } 539 541 540 G4VisCommandSetVolumeForField::~G4VisCommandSe 542 G4VisCommandSetVolumeForField::~G4VisCommandSetVolumeForField () 541 { 543 { 542 delete fpCommand; 544 delete fpCommand; 543 } 545 } 544 546 545 G4String G4VisCommandSetVolumeForField::GetCur 547 G4String G4VisCommandSetVolumeForField::GetCurrentValue (G4UIcommand*) 546 { 548 { 547 return G4String(); 549 return G4String(); 548 } 550 } 549 551 550 void G4VisCommandSetVolumeForField::SetNewValu 552 void G4VisCommandSetVolumeForField::SetNewValue (G4UIcommand*, G4String newValue) 551 { 553 { 552 G4VisManager::Verbosity verbosity = fpVisMan 554 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity(); 553 555 554 G4String name, drawString; 556 G4String name, drawString; 555 G4int copyNo; 557 G4int copyNo; 556 std::istringstream is (newValue); 558 std::istringstream is (newValue); 557 is >> name >> copyNo >> drawString; 559 is >> name >> copyNo >> drawString; 558 G4bool draw = G4UIcmdWithABool::ConvertToBoo 560 G4bool draw = G4UIcmdWithABool::ConvertToBool(drawString); 559 561 >> 562 if (name == "none") { >> 563 fCurrrentPVFindingsForField.clear(); >> 564 fCurrentExtentForField = G4VisExtent(); >> 565 if (verbosity >= G4VisManager::warnings) { >> 566 G4cout << "Volume for field cleared" << G4endl; >> 567 } >> 568 return; >> 569 } >> 570 560 G4TransportationManager* transportationManag 571 G4TransportationManager* transportationManager = 561 G4TransportationManager::GetTransportationMa 572 G4TransportationManager::GetTransportationManager (); 562 size_t nWorlds = transportationManager->GetN 573 size_t nWorlds = transportationManager->GetNoWorlds(); 563 std::vector<G4VPhysicalVolume*>::iterator it 574 std::vector<G4VPhysicalVolume*>::iterator iterWorld = 564 transportationManager->GetWorldsIterator(); 575 transportationManager->GetWorldsIterator(); 565 fCurrrentPVFindingsForField.clear(); 576 fCurrrentPVFindingsForField.clear(); 566 G4BoundingExtentScene extentScene; 577 G4BoundingExtentScene extentScene; 567 for (size_t i = 0; i < nWorlds; ++i, ++iterW 578 for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) { 568 G4PhysicalVolumeModel searchModel (*iterWo 579 G4PhysicalVolumeModel searchModel (*iterWorld); // Unlimited depth. 569 G4ModelingParameters mp; // Default - no 580 G4ModelingParameters mp; // Default - no culling. 570 searchModel.SetModelingParameters (&mp); 581 searchModel.SetModelingParameters (&mp); 571 // Find all instances at any position in t << 572 G4PhysicalVolumesSearchScene searchScene ( 582 G4PhysicalVolumesSearchScene searchScene (&searchModel, name, copyNo); 573 searchModel.DescribeYourselfTo (searchScen 583 searchModel.DescribeYourselfTo (searchScene); // Initiate search. 574 for (const auto& findings: searchScene.Get 584 for (const auto& findings: searchScene.GetFindings()) { 575 fCurrrentPVFindingsForField.push_back(fi 585 fCurrrentPVFindingsForField.push_back(findings); 576 G4VisExtent extent = findings.fpFoundPV- 586 G4VisExtent extent = findings.fpFoundPV->GetLogicalVolume()->GetSolid()->GetExtent(); 577 extent.Transform(findings.fFoundObjectTr 587 extent.Transform(findings.fFoundObjectTransformation); 578 extentScene.AccrueBoundingExtent(extent) 588 extentScene.AccrueBoundingExtent(extent); 579 } 589 } 580 } 590 } 581 591 582 if (fCurrrentPVFindingsForField.empty()) { 592 if (fCurrrentPVFindingsForField.empty()) { 583 if (verbosity >= G4VisManager::errors) { 593 if (verbosity >= G4VisManager::errors) { 584 G4warn << "ERROR: Volume \"" << name << << 594 G4cerr << "ERROR: Volume \"" << name << "\""; 585 if (copyNo >= 0) { 595 if (copyNo >= 0) { 586 G4warn << ", copy no. " << copyNo << " << 596 G4cerr << ", copy no. " << copyNo << ","; 587 } 597 } 588 G4warn << " not found." << G4endl; << 598 G4cerr << " not found." << G4endl; 589 } 599 } 590 return; 600 return; 591 } 601 } 592 602 593 fCurrentExtentForField = extentScene.GetExte 603 fCurrentExtentForField = extentScene.GetExtent(); 594 604 595 if (draw) DrawExtent(fCurrentExtentForField) 605 if (draw) DrawExtent(fCurrentExtentForField); 596 606 597 if (verbosity >= G4VisManager::confirmations 607 if (verbosity >= G4VisManager::confirmations) { 598 for (const auto& findings: fCurrrentPVFind 608 for (const auto& findings: fCurrrentPVFindingsForField) { 599 G4cout 609 G4cout 600 << "\"" << findings.fpFoundPV->GetName() 610 << "\"" << findings.fpFoundPV->GetName() 601 << "\", copy no. " << findings.fFoundPVC 611 << "\", copy no. " << findings.fFoundPVCopyNo 602 << ", found\nin searched volume \"" 612 << ", found\nin searched volume \"" 603 << findings.fpSearchPV->GetName() 613 << findings.fpSearchPV->GetName() 604 << "\" at depth " << findings.fFoundDept 614 << "\" at depth " << findings.fFoundDepth 605 << ",\nbase path: \"" << findings.fFound 615 << ",\nbase path: \"" << findings.fFoundBasePVPath 606 << "\",\nand has been set as volume for 616 << "\",\nand has been set as volume for field." 607 << G4endl; 617 << G4endl; 608 } 618 } 609 } 619 } 610 } 620 } 611 621