Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 // 23 // >> 24 // $Id: G4VisCommandsCompound.cc,v 1.12.2.1 2001/06/28 19:16:15 gunter Exp $ >> 25 // GEANT4 tag $Name: $ 27 26 28 // Compound /vis/ commands - John Allison 15t 27 // Compound /vis/ commands - John Allison 15th May 2000 29 28 30 #include "G4VisCommandsCompound.hh" 29 #include "G4VisCommandsCompound.hh" 31 30 32 #include "G4VisManager.hh" 31 #include "G4VisManager.hh" 33 #include "G4UImanager.hh" 32 #include "G4UImanager.hh" 34 #include "G4UIcommandTree.hh" << 35 #include "G4UIcmdWithAString.hh" 33 #include "G4UIcmdWithAString.hh" 36 34 37 #include <sstream> << 38 #include <set> << 39 << 40 #define G4warn G4cout << 41 << 42 ////////////// /vis/drawTree ///////////////// 35 ////////////// /vis/drawTree /////////////////////////////////////// 43 36 44 G4VisCommandDrawTree::G4VisCommandDrawTree() { 37 G4VisCommandDrawTree::G4VisCommandDrawTree() { 45 G4bool omitable; 38 G4bool omitable; 46 fpCommand = new G4UIcommand("/vis/drawTree", 39 fpCommand = new G4UIcommand("/vis/drawTree", this); >> 40 fpCommand->SetGuidance("/vis/drawTree [<physical-volume-name>] [<system>]"); >> 41 fpCommand->SetGuidance("Default: world ATree"); 47 fpCommand->SetGuidance 42 fpCommand->SetGuidance 48 ("Produces a representation of the geometr << 43 ("(DTREE) Creates a scene consisting of this physical volume and" 49 "\nguidance is given on running the comma << 44 "\n produces a represntation of the geometry hieracrhy."); 50 "\nfor \"/vis/ASCIITree/verbose\"."); << 45 fpCommand->SetGuidance("The scene becomes current."); 51 fpCommand->SetGuidance("The pre-existing sce << 52 G4UIparameter* parameter; 46 G4UIparameter* parameter; 53 parameter = new G4UIparameter("physical-volu << 47 parameter = new G4UIparameter("PVname", 's', omitable = true); 54 parameter -> SetDefaultValue("world"); 48 parameter -> SetDefaultValue("world"); 55 fpCommand -> SetParameter (parameter); 49 fpCommand -> SetParameter (parameter); 56 parameter = new G4UIparameter("system", 's', 50 parameter = new G4UIparameter("system", 's', omitable = true); 57 parameter -> SetDefaultValue("ATree"); 51 parameter -> SetDefaultValue("ATree"); 58 fpCommand -> SetParameter (parameter); 52 fpCommand -> SetParameter (parameter); 59 } 53 } 60 54 61 G4VisCommandDrawTree::~G4VisCommandDrawTree() 55 G4VisCommandDrawTree::~G4VisCommandDrawTree() { 62 delete fpCommand; 56 delete fpCommand; 63 } 57 } 64 58 65 void G4VisCommandDrawTree::SetNewValue(G4UIcom << 59 void G4VisCommandDrawTree::SetNewValue >> 60 (G4UIcommand* command, G4String newValue) { 66 61 67 G4String pvname, system; 62 G4String pvname, system; 68 std::istringstream is(newValue); << 63 const char* t = newValue; >> 64 G4std::istrstream is((char*)t); 69 is >> pvname >> system; 65 is >> pvname >> system; 70 66 71 // Note: The second parameter, "system", is << 72 // a choice of dedicated tree printing/displ << 73 // the only such dedicated system is ASCIITr << 74 // specify OGLSX, for example. So to avoid << 75 // feature to systems that have "Tree" in th << 76 << 77 // Of course, some other systems, such as OG << 78 // built-in. The HepRApp offline browser al << 79 // built in. << 80 << 81 if (!G4StrUtil::contains(system, "Tree")) { << 82 system = "ATree"; << 83 } << 84 << 85 G4VGraphicsSystem* keepSystem = fpVisManager << 86 G4Scene* keepScene = fpVisManager->GetCurren << 87 G4VSceneHandler* keepSceneHandler = fpVisMan << 88 G4VViewer* keepViewer = fpVisManager->GetCur << 89 G4VisManager::Verbosity keepVisVerbosity = f << 90 G4bool keepAbleness = fpVisManager->GetConcr << 91 << 92 G4UImanager* UImanager = G4UImanager::GetUIp 67 G4UImanager* UImanager = G4UImanager::GetUIpointer(); 93 G4int keepUIVerbose = UImanager->GetVerboseL << 68 G4int keepVerbose = UImanager->GetVerboseLevel(); 94 G4int newVerbose(0); << 69 UImanager->SetVerboseLevel(2); 95 if (keepUIVerbose >= 2 || << 70 UImanager->ApplyCommand("/vis/open " + system); 96 fpVisManager->GetVerbosity() >= G4VisMan << 71 UImanager->ApplyCommand("/vis/drawVolume " + pvname); 97 newVerbose = 2; << 72 UImanager->SetVerboseLevel(keepVerbose); 98 UImanager->SetVerboseLevel(newVerbose); << 99 << 100 auto errorCode = UImanager->ApplyCommand(G4S << 101 if (errorCode == 0) { << 102 if (!keepAbleness) { // Enable temporaril << 103 fpVisManager->SetVerboseLevel("Quiet"); << 104 UImanager->ApplyCommand("/vis/enable"); << 105 fpVisManager->SetVerboseLevel(keepVisVer << 106 } << 107 UImanager->ApplyCommand("/vis/viewer/reset << 108 UImanager->ApplyCommand(G4String("/vis/dra << 109 UImanager->ApplyCommand("/vis/viewer/flush << 110 if (!keepAbleness) { // Disable again << 111 fpVisManager->SetVerboseLevel("Quiet"); << 112 UImanager->ApplyCommand("/vis/disable"); << 113 fpVisManager->SetVerboseLevel(keepVisVer << 114 } << 115 if (keepViewer) { << 116 if (fpVisManager->GetVerbosity() >= G4Vi << 117 G4warn << "Reverting to " << keepViewe << 118 } << 119 fpVisManager->SetCurrentGraphicsSystem(k << 120 fpVisManager->SetCurrentScene(keepScene) << 121 fpVisManager->SetCurrentSceneHandler(kee << 122 fpVisManager->SetCurrentViewer(keepViewe << 123 } << 124 } << 125 UImanager->SetVerboseLevel(keepUIVerbose); << 126 } 73 } 127 74 128 ////////////// /vis/drawView ///////////////// 75 ////////////// /vis/drawView /////////////////////////////////////// 129 76 130 G4VisCommandDrawView::G4VisCommandDrawView() { 77 G4VisCommandDrawView::G4VisCommandDrawView() { 131 G4bool omitable; 78 G4bool omitable; 132 fpCommand = new G4UIcommand("/vis/drawView", 79 fpCommand = new G4UIcommand("/vis/drawView", this); 133 fpCommand->SetGuidance 80 fpCommand->SetGuidance 134 ("Draw view from this angle, etc."); << 81 ("/vis/drawView [<theta-deg>] [<phi-deg>] [<pan-right>] [<pan-up>]" >> 82 " [<pan-unit>] [<zoom-factor>] [<dolly>] [<dolly-unit>]"); >> 83 fpCommand->SetGuidance("Default: 0 0 0 0 cm 1 0 cm"); 135 G4UIparameter* parameter; 84 G4UIparameter* parameter; 136 parameter = new G4UIparameter("theta-degrees << 85 parameter = new G4UIparameter("theta-deg", 'd', omitable = true); 137 parameter -> SetDefaultValue(0.); 86 parameter -> SetDefaultValue(0.); 138 fpCommand -> SetParameter (parameter); 87 fpCommand -> SetParameter (parameter); 139 parameter = new G4UIparameter("phi-degrees", << 88 parameter = new G4UIparameter("phi-deg", 'd', omitable = true); 140 parameter -> SetDefaultValue(0.); 89 parameter -> SetDefaultValue(0.); 141 fpCommand -> SetParameter (parameter); 90 fpCommand -> SetParameter (parameter); 142 parameter = new G4UIparameter("pan-right", ' 91 parameter = new G4UIparameter("pan-right", 'd', omitable = true); 143 parameter -> SetDefaultValue(0.); 92 parameter -> SetDefaultValue(0.); 144 fpCommand -> SetParameter (parameter); 93 fpCommand -> SetParameter (parameter); 145 parameter = new G4UIparameter("pan-up", 'd', 94 parameter = new G4UIparameter("pan-up", 'd', omitable = true); 146 parameter -> SetDefaultValue(0.); 95 parameter -> SetDefaultValue(0.); 147 fpCommand -> SetParameter (parameter); 96 fpCommand -> SetParameter (parameter); 148 parameter = new G4UIparameter("pan-unit", 's 97 parameter = new G4UIparameter("pan-unit", 's', omitable = true); 149 parameter -> SetDefaultValue("cm"); 98 parameter -> SetDefaultValue("cm"); 150 fpCommand -> SetParameter (parameter); 99 fpCommand -> SetParameter (parameter); 151 parameter = new G4UIparameter("zoom-factor", 100 parameter = new G4UIparameter("zoom-factor", 'd', omitable = true); 152 parameter -> SetDefaultValue(1.); 101 parameter -> SetDefaultValue(1.); 153 fpCommand -> SetParameter (parameter); 102 fpCommand -> SetParameter (parameter); 154 parameter = new G4UIparameter("dolly", 'd', 103 parameter = new G4UIparameter("dolly", 'd', omitable = true); 155 parameter -> SetDefaultValue(0.); 104 parameter -> SetDefaultValue(0.); 156 fpCommand -> SetParameter (parameter); 105 fpCommand -> SetParameter (parameter); 157 parameter = new G4UIparameter("dolly-unit", 106 parameter = new G4UIparameter("dolly-unit", 's', omitable = true); 158 parameter -> SetDefaultValue("cm"); 107 parameter -> SetDefaultValue("cm"); 159 fpCommand -> SetParameter (parameter); 108 fpCommand -> SetParameter (parameter); 160 } 109 } 161 110 162 G4VisCommandDrawView::~G4VisCommandDrawView() 111 G4VisCommandDrawView::~G4VisCommandDrawView() { 163 delete fpCommand; 112 delete fpCommand; 164 } 113 } 165 114 166 void G4VisCommandDrawView::SetNewValue(G4UIcom << 115 void G4VisCommandDrawView::SetNewValue 167 << 116 (G4UIcommand* command, G4String newValue) { 168 G4VisManager::Verbosity verbosity = fpVisMan << 169 117 170 G4VViewer* currentViewer = fpVisManager->Get 118 G4VViewer* currentViewer = fpVisManager->GetCurrentViewer(); 171 if (!currentViewer) { 119 if (!currentViewer) { 172 if (verbosity >= G4VisManager::warnings) { << 120 G4cout << "G4VisCommandsDrawView::SetNewValue: no current viewer." 173 G4warn << << 121 << G4endl; 174 "WARNING: G4VisCommandsDrawView::SetNewValue << 175 << G4endl; << 176 } << 177 return; 122 return; 178 } 123 } 179 124 180 G4String thetaDeg; 125 G4String thetaDeg; 181 G4String phiDeg; 126 G4String phiDeg; 182 G4String panRight; 127 G4String panRight; 183 G4String panUp; 128 G4String panUp; 184 G4String panUnit; 129 G4String panUnit; 185 G4String zoomFactor; 130 G4String zoomFactor; 186 G4String dolly; 131 G4String dolly; 187 G4String dollyUnit; 132 G4String dollyUnit; 188 std::istringstream is(newValue); << 133 const char* t = newValue; >> 134 G4std::istrstream is((char*)t); 189 is >> thetaDeg >> phiDeg >> panRight >> panU 135 is >> thetaDeg >> phiDeg >> panRight >> panUp >> panUnit 190 >> zoomFactor >> dolly >> dollyUnit; 136 >> zoomFactor >> dolly >> dollyUnit; 191 137 192 G4UImanager* UImanager = G4UImanager::GetUIp 138 G4UImanager* UImanager = G4UImanager::GetUIpointer(); >> 139 G4int keepVerbose = UImanager->GetVerboseLevel(); >> 140 UImanager->SetVerboseLevel(2); 193 G4ViewParameters vp = currentViewer->GetView 141 G4ViewParameters vp = currentViewer->GetViewParameters(); 194 G4bool keepAutoRefresh = vp.IsAutoRefresh(); 142 G4bool keepAutoRefresh = vp.IsAutoRefresh(); 195 vp.SetAutoRefresh(false); 143 vp.SetAutoRefresh(false); 196 currentViewer->SetViewParameters(vp); 144 currentViewer->SetViewParameters(vp); 197 UImanager->ApplyCommand( << 145 UImanager->ApplyCommand 198 G4String("/vis/viewer/set/viewpointThetaPh << 146 ("/vis/viewer/viewpointThetaPhi " + thetaDeg + " " + phiDeg + " deg"); 199 UImanager->ApplyCommand( << 147 UImanager->ApplyCommand 200 G4String("/vis/viewer/panTo " + panRight + << 148 ("/vis/viewer/panTo " + panRight + " " + panUp + " " + panUnit); 201 UImanager->ApplyCommand( << 149 UImanager->ApplyCommand 202 G4String("/vis/viewer/zoomTo " + zoomFacto << 150 ("/vis/viewer/zoomTo " + zoomFactor); 203 vp = currentViewer->GetViewParameters(); 151 vp = currentViewer->GetViewParameters(); 204 vp.SetAutoRefresh(keepAutoRefresh); 152 vp.SetAutoRefresh(keepAutoRefresh); 205 currentViewer->SetViewParameters(vp); 153 currentViewer->SetViewParameters(vp); 206 UImanager->ApplyCommand( << 154 UImanager->ApplyCommand 207 G4String("/vis/viewer/dollyTo " + dolly + << 155 ("/vis/viewer/dollyTo " + dolly + " " + dollyUnit); 208 } << 156 UImanager->SetVerboseLevel(keepVerbose); 209 << 210 ////////////// /vis/drawLogicalVolume //////// << 211 << 212 G4VisCommandDrawLogicalVolume::G4VisCommandDra << 213 fpCommand = new G4UIcommand("/vis/drawLogica << 214 fpCommand->SetGuidance << 215 ("Draws logical volume with additional compo << 216 fpCommand->SetGuidance << 217 ("Synonymous with \"/vis/specify\"."); << 218 fpCommand->SetGuidance << 219 ("Creates a scene consisting of this logical << 220 "\n current viewer to draw it. The scene b << 221 const G4UIcommandTree* tree = G4UImanager::G << 222 const G4UIcommand* addLogVolCmd = tree->Find << 223 // Pick up guidance from /vis/scene/add/logi << 224 CopyGuidanceFrom(addLogVolCmd,fpCommand); << 225 // Pick up parameters from /vis/scene/add/lo << 226 CopyParametersFrom(addLogVolCmd,fpCommand); << 227 } << 228 << 229 G4VisCommandDrawLogicalVolume::~G4VisCommandDr << 230 delete fpCommand; << 231 } << 232 << 233 void G4VisCommandDrawLogicalVolume::SetNewValu << 234 G4VisManager::Verbosity verbosity = fpVisMan << 235 G4UImanager* UImanager = G4UImanager::GetUIp << 236 G4VViewer* currentViewer = fpVisManager->Get << 237 const G4ViewParameters& currentViewParams = << 238 G4bool keepAutoRefresh = currentViewParams.I << 239 if (keepAutoRefresh) UImanager->ApplyCommand << 240 UImanager->ApplyCommand("/vis/scene/create") << 241 UImanager->ApplyCommand(G4String("/vis/scene << 242 UImanager->ApplyCommand("/vis/sceneHandler/a << 243 G4ViewParameters::DrawingStyle keepDrawingSt << 244 if(keepDrawingStyle != G4ViewParameters::wir << 245 UImanager->ApplyCommand("/vis/viewer/set/s << 246 G4bool keepMarkerNotHidden = currentViewPara << 247 if (!keepMarkerNotHidden) UImanager->ApplyCo << 248 if (keepAutoRefresh) UImanager->ApplyCommand << 249 if (verbosity >= G4VisManager::warnings) { << 250 if (keepDrawingStyle != currentViewParams. << 251 G4warn << 252 << "Drawing style changed to wireframe. << 253 G4String style, edge; << 254 switch (keepDrawingStyle) { << 255 case G4ViewParameters::wireframe: << 256 style = "wireframe"; edge = "false"; << 257 case G4ViewParameters::hlr: << 258 style = "wireframe"; edge = "true"; << 259 case G4ViewParameters::hsr: << 260 style = "surface"; edge = "false"; b << 261 case G4ViewParameters::hlhsr: << 262 style = "surface"; edge = "true"; br << 263 case G4ViewParameters::cloud: << 264 style = "cloud"; edge = ""; break; << 265 } << 266 G4warn << "\n /vis/viewer/set/style " + << 267 if (!edge.empty()) G4warn << "\n /vis/v << 268 G4warn << G4endl; << 269 } << 270 if (keepMarkerNotHidden != currentViewPara << 271 G4warn << 272 << "Markers changed to \"not hidden\". T << 273 << "\n /vis/viewer/set/hiddenmarker tru << 274 << G4endl; << 275 } << 276 } << 277 static G4bool warned = false; << 278 if (verbosity >= G4VisManager::confirmations << 279 G4cout << << 280 "NOTE: For systems which are not \"auto-re << 281 "\n issue \"/vis/viewer/refresh\" or \"/v << 282 << G4endl; << 283 warned = true; << 284 } << 285 } 157 } 286 158 287 ////////////// /vis/drawVolume /////////////// 159 ////////////// /vis/drawVolume /////////////////////////////////////// 288 160 289 G4VisCommandDrawVolume::G4VisCommandDrawVolume 161 G4VisCommandDrawVolume::G4VisCommandDrawVolume() { 290 fpCommand = new G4UIcommand("/vis/drawVolume << 162 G4bool omitable; >> 163 fpCommand = new G4UIcmdWithAString("/vis/drawVolume", this); >> 164 fpCommand->SetGuidance("/vis/drawVolume [<physical-volume-name>]"); >> 165 fpCommand->SetGuidance("Default: world volume"); 291 fpCommand->SetGuidance 166 fpCommand->SetGuidance 292 ("Creates a scene containing this physical v << 167 ("Creates a scene consisting of this physical volume and asks the" 293 "\ncurrent viewer to draw it. The scene be << 168 "\n current viewer to draw it."); 294 const G4UIcommandTree* tree = G4UImanager::G << 169 fpCommand->SetGuidance("The scene becomes current."); 295 const G4UIcommand* addVolCmd = tree->FindPat << 170 fpCommand->SetParameterName("physical-volume-name", omitable = true); 296 // Pick up guidance from /vis/scene/add/volu << 171 fpCommand->SetDefaultValue("world"); 297 CopyGuidanceFrom(addVolCmd,fpCommand); << 298 // Pick up parameters from /vis/scene/add/vo << 299 CopyParametersFrom(addVolCmd,fpCommand); << 300 } 172 } 301 173 302 G4VisCommandDrawVolume::~G4VisCommandDrawVolum 174 G4VisCommandDrawVolume::~G4VisCommandDrawVolume() { 303 delete fpCommand; 175 delete fpCommand; 304 } 176 } 305 177 306 void G4VisCommandDrawVolume::SetNewValue(G4UIc << 178 void G4VisCommandDrawVolume::SetNewValue 307 G4VisManager::Verbosity verbosity = fpVisMan << 179 (G4UIcommand* command, G4String newValue) { 308 G4UImanager* UImanager = G4UImanager::GetUIp 180 G4UImanager* UImanager = G4UImanager::GetUIpointer(); >> 181 G4int keepVerbose = UImanager->GetVerboseLevel(); >> 182 UImanager->SetVerboseLevel(2); 309 UImanager->ApplyCommand("/vis/scene/create") 183 UImanager->ApplyCommand("/vis/scene/create"); 310 UImanager->ApplyCommand(G4String("/vis/scene << 184 UImanager->ApplyCommand("/vis/scene/add/volume " + newValue); 311 UImanager->ApplyCommand("/vis/sceneHandler/a 185 UImanager->ApplyCommand("/vis/sceneHandler/attach"); 312 static G4bool warned = false; << 186 UImanager->ApplyCommand("/vis/viewer/refresh"); 313 if (verbosity >= G4VisManager::confirmations << 187 UImanager->SetVerboseLevel(keepVerbose); 314 G4cout << << 315 "NOTE: For systems which are not \"auto- << 316 "\n issue \"/vis/viewer/refresh\" or \" << 317 << G4endl; << 318 warned = true; << 319 } << 320 } 188 } 321 189 322 ////////////// /vis/open ///////////////////// 190 ////////////// /vis/open /////////////////////////////////////// 323 191 324 G4VisCommandOpen::G4VisCommandOpen() { 192 G4VisCommandOpen::G4VisCommandOpen() { 325 G4bool omitable; 193 G4bool omitable; 326 fpCommand = new G4UIcommand("/vis/open", thi 194 fpCommand = new G4UIcommand("/vis/open", this); >> 195 fpCommand->SetGuidance("/vis/open [<graphics-system-name>] [<pixels>]"); 327 fpCommand->SetGuidance 196 fpCommand->SetGuidance 328 ("Creates a scene handler and viewer ready << 197 ("For this graphics system, creates a scene handler ready for drawing."); 329 fpCommand->SetGuidance << 198 fpCommand->SetGuidance("The scene handler becomes current."); 330 ("The scene handler and viewer names are a << 199 fpCommand->SetGuidance("The scene handler name is auto-generated."); 331 // Pick up guidance from /vis/viewer/create << 200 fpCommand->SetGuidance("The 2nd parameter is the window size hint."); 332 const G4UIcommandTree* tree = G4UImanager::G << 333 const G4UIcommand* viewerCreateCmd = tree->F << 334 CopyGuidanceFrom(viewerCreateCmd,fpCommand,2 << 335 G4UIparameter* parameter; 201 G4UIparameter* parameter; 336 parameter = new G4UIparameter("graphics-syst << 202 parameter = new G4UIparameter("graphics-system-name", 's', omitable = false); 337 parameter->SetCurrentAsDefault(true); << 203 const G4GraphicsSystemList& gslist = >> 204 fpVisManager->GetAvailableGraphicsSystems(); >> 205 G4String candidates; >> 206 for (size_t igslist = 0; igslist < gslist.size(); igslist++) { >> 207 const G4String& name = gslist[igslist]->GetName(); >> 208 const G4String& nickname = gslist[igslist]->GetNickname(); >> 209 if (nickname.isNull()) { >> 210 candidates += name; >> 211 } >> 212 else { >> 213 candidates += nickname; >> 214 } >> 215 candidates += " "; >> 216 } >> 217 candidates = candidates.strip(); >> 218 parameter->SetParameterCandidates(candidates); 338 fpCommand->SetParameter(parameter); 219 fpCommand->SetParameter(parameter); 339 parameter = new G4UIparameter("window-size-h << 220 parameter = new G4UIparameter("pixels", 'i', omitable = true); 340 parameter->SetGuidance << 221 parameter->SetDefaultValue(600); 341 ("integer (pixels) for square window place << 342 " X-Windows-type geometry string, e.g. 60 << 343 parameter->SetCurrentAsDefault(true); << 344 fpCommand->SetParameter(parameter); 222 fpCommand->SetParameter(parameter); 345 } 223 } 346 224 347 G4VisCommandOpen::~G4VisCommandOpen() { 225 G4VisCommandOpen::~G4VisCommandOpen() { 348 delete fpCommand; 226 delete fpCommand; 349 } 227 } 350 228 351 G4String G4VisCommandOpen::GetCurrentValue(G4U << 229 void G4VisCommandOpen::SetNewValue (G4UIcommand* command, G4String newValue) { 352 { << 353 G4String graphicsSystemName, windowSizeHint; << 354 auto graphicsSystem = fpVisManager->GetCurre << 355 if (graphicsSystem) { << 356 // Take name and hint from latest graphics << 357 graphicsSystemName = graphicsSystem->GetNa << 358 auto viewer = fpVisManager->GetCurrentView << 359 if (viewer) { << 360 windowSizeHint = viewer->GetViewParamete << 361 } << 362 else { // Viewer not yet created? << 363 windowSizeHint = fpVisManager->GetDefaul << 364 } << 365 } << 366 else { // No graphics system yet - must be << 367 graphicsSystemName = fpVisManager->GetDefa << 368 windowSizeHint = fpVisManager->GetDefaultX << 369 } << 370 return graphicsSystemName + ' ' + windowSize << 371 } << 372 << 373 void G4VisCommandOpen::SetNewValue (G4UIcomman << 374 { << 375 G4String systemName, windowSizeHint; 230 G4String systemName, windowSizeHint; 376 std::istringstream is(newValue); << 231 const char* t = newValue; >> 232 G4std::istrstream is((char*)t); 377 is >> systemName >> windowSizeHint; 233 is >> systemName >> windowSizeHint; 378 G4UImanager* UImanager = G4UImanager::GetUIp 234 G4UImanager* UImanager = G4UImanager::GetUIpointer(); 379 << 235 G4int keepVerbose = UImanager->GetVerboseLevel(); 380 auto errorCode = UImanager->ApplyCommand(G4S << 236 UImanager->SetVerboseLevel(2); 381 if (errorCode) { << 237 UImanager->ApplyCommand("/vis/sceneHandler/create " + systemName); 382 G4warn << "sub-command \"/vis/sceneHandler << 238 UImanager->ApplyCommand("/vis/viewer/create ! ! " + windowSizeHint); 383 goto finish; << 239 UImanager->SetVerboseLevel(keepVerbose); 384 } << 385 << 386 errorCode = UImanager->ApplyCommand(G4String << 387 if (errorCode) { << 388 G4warn << "sub-command \"/vis/viewer/creat << 389 goto finish; << 390 } << 391 << 392 finish: << 393 if (errorCode) { << 394 fpVisManager->PrintAvailableGraphicsSystem << 395 if (errorCode != JustWarning) { << 396 G4ExceptionDescription ed; << 397 ed << "Invoked command has failed - see << 398 command->CommandFailed(errorCode,ed); << 399 } << 400 } << 401 } << 402 << 403 ////////////// /vis/plot ///////////////////// << 404 << 405 G4VisCommandPlot::G4VisCommandPlot () << 406 { << 407 G4bool omitable; << 408 G4UIparameter* parameter; << 409 << 410 fpCommand = new G4UIcommand("/vis/plot", thi << 411 fpCommand -> SetGuidance("Draws plots."); << 412 parameter = new G4UIparameter ("type", 's', << 413 parameter -> SetParameterCandidates("h1 h2") << 414 fpCommand -> SetParameter (parameter); << 415 parameter = new G4UIparameter ("id", 'i', om << 416 fpCommand -> SetParameter (parameter); << 417 #ifdef TOOLS_USE_FREETYPE << 418 parameter = new G4UIparameter ("style", 's', << 419 parameter -> SetParameterCandidates("none RO << 420 parameter -> SetDefaultValue("ROOT_default") << 421 fpCommand -> SetParameter (parameter); << 422 #endif << 423 } << 424 << 425 G4VisCommandPlot::~G4VisCommandPlot () << 426 { << 427 delete fpCommand; << 428 } << 429 << 430 G4String G4VisCommandPlot::GetCurrentValue (G4 << 431 { << 432 return ""; << 433 } << 434 << 435 void G4VisCommandPlot::SetNewValue (G4UIcomman << 436 { << 437 auto currentViewer = fpVisManager->GetCurren << 438 if (currentViewer->GetName().find("TOOLSSG") << 439 G4warn << << 440 "WARNING: Current viewer not able to draw << 441 "\n Try \"/vis/open TSG\", then \"/vis/pl << 442 << G4endl; << 443 return; << 444 } << 445 << 446 std::istringstream is (newValue); << 447 G4String type, id; << 448 is >> type >> id; << 449 #ifdef TOOLS_USE_FREETYPE << 450 G4String style; << 451 is >> style; << 452 #endif << 453 << 454 auto keepEnable = fpVisManager->IsEnabled(); << 455 << 456 auto ui = G4UImanager::GetUIpointer(); << 457 ui->ApplyCommand("/vis/enable"); << 458 ui->ApplyCommand("/vis/viewer/resetCameraPar << 459 ui->ApplyCommand("/vis/scene/create"); << 460 ui->ApplyCommand("/vis/scene/endOfEventActio << 461 static G4int plotterID = 0; << 462 std::ostringstream ossPlotter; << 463 ossPlotter << "plotter-" << plotterID++; << 464 const G4String& plotterName = ossPlotter.str << 465 ui->ApplyCommand("/vis/plotter/create " + pl << 466 ui->ApplyCommand("/vis/scene/add/plotter " + << 467 ui->ApplyCommand("/vis/plotter/add/" + type << 468 #ifdef TOOLS_USE_FREETYPE << 469 if (style != "none") { << 470 ui->ApplyCommand("/vis/plotter/addStyle " << 471 } << 472 #endif << 473 ui->ApplyCommand("/vis/sceneHandler/attach") << 474 << 475 if (!keepEnable) { << 476 fpVisManager->Disable(); << 477 G4warn << << 478 "WARNING: drawing was enabled for plotting << 479 << G4endl; << 480 } << 481 } 240 } 482 241 483 ////////////// /vis/specify ////////////////// 242 ////////////// /vis/specify /////////////////////////////////////// 484 243 485 G4VisCommandSpecify::G4VisCommandSpecify() { 244 G4VisCommandSpecify::G4VisCommandSpecify() { 486 G4bool omitable; 245 G4bool omitable; 487 fpCommand = new G4UIcommand("/vis/specify", << 246 fpCommand = new G4UIcmdWithAString("/vis/specify", this); 488 fpCommand->SetGuidance << 247 fpCommand->SetGuidance("/vis/specify <logical-volume-name>"); 489 ("Draws logical volume with Boolean compon << 490 fpCommand->SetGuidance << 491 ("Synonymous with \"/vis/drawLogicalVolume << 492 fpCommand->SetGuidance 248 fpCommand->SetGuidance 493 ("Creates a scene consisting of this logic 249 ("Creates a scene consisting of this logical volume and asks the" 494 "\n current viewer to draw it to the spe << 250 "\n current viewer to draw it and the geometry to print the" 495 "\n showing boolean components (if any), << 251 "\n specification."); 496 "\n readout geometry (if any), local axe << 497 "\n under control of the appropriate fla << 498 fpCommand->SetGuidance << 499 ("Note: voxels are not constructed until sta << 500 "\n (For voxels without a run, \"/run/beam << 501 fpCommand->SetGuidance("The scene becomes cu 252 fpCommand->SetGuidance("The scene becomes current."); 502 G4UIparameter* parameter; << 253 fpCommand->SetParameterName("logical-volume-name", omitable = false); 503 parameter = new G4UIparameter("logical-volum << 504 fpCommand->SetParameter(parameter); << 505 parameter = new G4UIparameter("depth-of-desc << 506 parameter->SetDefaultValue(1); << 507 fpCommand->SetParameter(parameter); << 508 parameter = new G4UIparameter("booleans-flag << 509 parameter->SetDefaultValue(true); << 510 fpCommand->SetParameter(parameter); << 511 parameter = new G4UIparameter("voxels-flag", << 512 parameter->SetDefaultValue(true); << 513 fpCommand->SetParameter(parameter); << 514 parameter = new G4UIparameter("readout-flag" << 515 parameter->SetDefaultValue(true); << 516 fpCommand->SetParameter(parameter); << 517 parameter = new G4UIparameter("axes-flag", ' << 518 parameter->SetDefaultValue(true); << 519 parameter -> SetGuidance ("Set \"false\" to << 520 fpCommand->SetParameter(parameter); << 521 parameter = new G4UIparameter("check-overlap << 522 parameter->SetDefaultValue(true); << 523 parameter -> SetGuidance ("Set \"false\" to << 524 fpCommand->SetParameter(parameter); << 525 } 254 } 526 255 527 G4VisCommandSpecify::~G4VisCommandSpecify() { 256 G4VisCommandSpecify::~G4VisCommandSpecify() { 528 delete fpCommand; 257 delete fpCommand; 529 } 258 } 530 259 531 void G4VisCommandSpecify::SetNewValue(G4UIcomm << 260 void G4VisCommandSpecify::SetNewValue 532 G4VisManager::Verbosity verbosity = fpVisMan << 261 (G4UIcommand* command, G4String newValue) { 533 G4UImanager* UImanager = G4UImanager::GetUIp 262 G4UImanager* UImanager = G4UImanager::GetUIpointer(); 534 // UImanager->ApplyCommand(G4String("/geomet << 263 G4int keepVerbose = UImanager->GetVerboseLevel(); >> 264 UImanager->SetVerboseLevel(2); >> 265 UImanager->ApplyCommand("/geometry/print " + newValue); 535 UImanager->ApplyCommand("/vis/scene/create") 266 UImanager->ApplyCommand("/vis/scene/create"); 536 UImanager->ApplyCommand(G4String("/vis/scene << 267 UImanager->ApplyCommand("/vis/scene/add/logicalVolume " + newValue); 537 UImanager->ApplyCommand("/vis/sceneHandler/a 268 UImanager->ApplyCommand("/vis/sceneHandler/attach"); 538 static G4bool warned = false; << 269 UImanager->ApplyCommand("/vis/viewer/refresh"); 539 if (verbosity >= G4VisManager::confirmations << 270 UImanager->SetVerboseLevel(keepVerbose); 540 G4cout << << 541 "NOTE: For systems which are not \"auto- << 542 "\n issue \"/vis/viewer/refresh\" or \" << 543 << G4endl; << 544 warned = true; << 545 } << 546 } 271 } 547 272