81 #ifdef G4MULTITHREADED
89 #ifdef G4VIS_USE_STD11
101 fInitialised (false),
102 fpGraphicsSystem (0),
106 fpStateDependent (0),
107 fEventRefreshing (false),
108 fTransientsDrawnThisRun (false),
109 fTransientsDrawnThisEvent (false),
110 fNoOfEventsDrawnThisRun (0),
112 fEventKeepingSuspended (false),
113 fKeptLastEvent (false),
114 fDrawEventOnlyIfToBeKept (false),
115 fpRequestedEvent (0),
116 fAbortReviewKeptEvents (false),
117 fIsDrawGroup (false),
118 fDrawGroupNestingDepth (0),
119 fIgnoreStateChanges (false)
120 #ifdef G4MULTITHREADED
121 , fMaxEventQueueSize (100)
122 , fWaitOnEventQueueFull (true)
132 (
"Simple graded message scheme - digit or string (1st character defines):");
134 (
" 0) quiet, // Nothing is printed.");
136 (
" 1) startup, // Startup and endup messages are printed...");
138 (
" 2) errors, // ...and errors...");
140 (
" 3) warnings, // ...and warnings...");
142 (
" 4) confirmations, // ...and confirming messages...");
144 (
" 5) parameters, // ...and parameters of scenes and views...");
146 (
" 6) all // ...and everything available.");
150 (
"G4VisManager::G4VisManager",
152 "Attempt to Construct more than one VisManager");
164 <<
"Visualization Manager instantiating with verbosity \""
197 directory -> SetGuidance (
"Visualization commands.");
227 G4cout <<
"Visualization Manager deleting..." <<
G4endl;
245 (
"G4VisManager::GetInstance",
254 G4cout <<
"WARNING: G4VisManager::Initialise: already initialised."
260 G4cout <<
"Visualization Manager initialising..." <<
G4endl;
265 "\nYou have instantiated your own Visualization Manager, inheriting"
266 "\n G4VisManager and implementing RegisterGraphicsSystems(), in which"
267 "\n you should, normally, instantiate drivers which do not need"
268 "\n external packages or libraries, and, optionally, drivers under"
269 "\n control of environment variables."
270 "\n Also you should implement RegisterModelFactories()."
271 "\n See visualization/management/include/G4VisExecutive.hh/icc, for example."
272 "\n In your main() you will have something like:"
273 "\n #ifdef G4VIS_USE"
274 "\n G4VisManager* visManager = new G4VisExecutive;"
275 "\n visManager -> SetVerboseLevel (Verbose);"
276 "\n visManager -> Initialize ();"
278 "\n (Don't forget to delete visManager;)"
291 "\nYou have successfully registered the following graphics systems."
301 directory -> SetGuidance (
"Modeling commands.");
303 directory =
new G4UIdirectory (
"/vis/modeling/trajectories/");
304 directory -> SetGuidance (
"Trajectory model commands.");
306 directory =
new G4UIdirectory (
"/vis/modeling/trajectories/create/");
307 directory -> SetGuidance (
"Create trajectory models and messengers.");
312 directory -> SetGuidance (
"Filtering commands.");
314 directory =
new G4UIdirectory (
"/vis/filtering/trajectories/");
315 directory -> SetGuidance (
"Trajectory filtering commands.");
317 directory =
new G4UIdirectory (
"/vis/filtering/trajectories/create/");
318 directory -> SetGuidance (
"Create trajectory filters and messengers.");
321 directory -> SetGuidance (
"Hit filtering commands.");
323 directory =
new G4UIdirectory (
"/vis/filtering/hits/create/");
324 directory -> SetGuidance (
"Create hit filters and messengers.");
327 directory -> SetGuidance (
"Digi filtering commands.");
329 directory =
new G4UIdirectory (
"/vis/filtering/digi/create/");
330 directory -> SetGuidance (
"Create digi filters and messengers.");
343 "\nYou have successfully registered the following model factories."
358 "Some /vis commands (optionally) take a string to specify colour."
359 "\n\"/vis/list\" to see available colours."
375 #define TOOLS_COLORS_STAT(name,r,g,b) \
376 G4Colour::AddToMap(#name, G4Colour(r,g,b));
457 #undef TOOLS_COLORS_STAT
488 directory -> SetGuidance(
"Operations on vis attributes of Geant4 geometry.");
494 directory -> SetGuidance(
"Set vis attributes of Geant4 geometry.");
506 #ifdef G4MULTITHREADED
508 directory -> SetGuidance(
"Commands unique to multithreading mode.");
515 directory -> SetGuidance
516 (
"Set quantities for use in future commands where appropriate.");
527 directory -> SetGuidance (
"Operations on Geant4 scenes.");
538 directory -> SetGuidance (
"Add model to current scene.");
565 directory -> SetGuidance (
"Operations on Geant4 scene handlers.");
573 directory -> SetGuidance (
"Operations on touchables.");
578 directory -> SetGuidance (
"Set vis attributes of current touchable.");
583 directory -> SetGuidance (
"Operations on Geant4 viewers.");
610 directory -> SetGuidance(
"Set default values for future viewers.");
616 directory -> SetGuidance (
"Set view parameters of current viewer.");
649 G4cout <<
"G4VisManager::Enable: visualization enabled." <<
G4endl;
652 G4int nKeptEvents = 0;
656 "There are " << nKeptEvents <<
" kept events."
657 "\n \"/vis/reviewKeptEvents\" to review them one by one."
658 "\n \"/vis/viewer/flush\" or \"/vis/viewer/rebuild\" to see them accumulated."
665 "G4VisManager::Enable: WARNING: visualization remains disabled for"
666 "\n above reasons. Rectifying with valid vis commands will"
667 "\n automatically enable."
677 "G4VisManager::Disable: visualization disabled."
678 "\n The pointer returned by GetConcreteInstance will be zero."
679 "\n Note that it will become enabled after some valid vis commands."
683 G4int currentTrajectoryType =
685 if (currentTrajectoryType > 0) {
687 "You may wish to disable trajectory production too:"
688 "\n \"/tracking/storeTrajectory 0\""
689 "\nbut don't forget to re-enable with"
691 "\n \"/tracking/storeTrajectory " << currentTrajectoryType <<
"\" (for your case)."
701 G4cout <<
"G4VisManager::GetAvailableGraphicsSystems: WARNING: no"
702 "\n graphics system available!"
703 "\n 1) Did you have environment variables G4VIS_BUILD_xxxx_DRIVER set"
704 "\n when you compiled/built the visualization code?"
705 "\n 2) Did you instantiate your own Visualization Manager and forget"
706 "\n to implement RegisterGraphicsSystems correctly?"
707 "\n 3) You can register your own graphics system, e.g.,"
708 "\n visManager->RegisterGraphicsSystem(new MyGraphicsSystem);)"
709 "\n after instantiating your vis manager and before"
710 "\n visManager->Initialize()."
722 G4cout <<
"G4VisManager::RegisterGraphicsSystem: "
723 << pSystem -> GetName ();
724 if (pSystem -> GetNickname () !=
"") {
725 G4cout <<
" (" << pSystem -> GetNickname () <<
")";
732 G4cout <<
"G4VisManager::RegisterGraphicsSystem: null pointer!"
752 G4cout<<
"G4VisManager: Using G4TrajectoryDrawByCharge as fallback trajectory model."<<
G4endl;
753 G4cout<<
"See commands in /vis/modeling/trajectories/ for other options."<<
G4endl;
814 #ifdef G4MULTITHREADED
820 (
"G4VisManager::BeginDraw",
822 "Nesting detected. It is illegal to nest Begin/EndDraw."
835 #ifdef G4MULTITHREADED
851 #ifdef G4MULTITHREADED
857 (
"G4VisManager::BeginDraw2D",
859 "Nesting detected. It is illegal to nest Begin/EndDraw2D."
872 #ifdef G4MULTITHREADED
888 #ifdef G4MULTITHREADED
892 if (objectTransform != fpSceneHandler->GetObjectTransformation()) {
894 (
"G4VSceneHandler::DrawT",
896 "Different transform detected in Begin/EndDraw group.");
898 fpSceneHandler -> AddPrimitive (graphics_primitive);
900 if (IsValidView ()) {
901 ClearTransientStoreIfMarked();
902 fpSceneHandler -> BeginPrimitives (objectTransform);
903 fpSceneHandler -> AddPrimitive (graphics_primitive);
904 fpSceneHandler -> EndPrimitives ();
911 #ifdef G4MULTITHREADED
915 if (objectTransform != fpSceneHandler->GetObjectTransformation()) {
917 (
"G4VSceneHandler::DrawT",
919 "Different transform detected in Begin/EndDraw2D group.");
921 fpSceneHandler -> AddPrimitive (graphics_primitive);
923 if (IsValidView ()) {
924 ClearTransientStoreIfMarked();
925 fpSceneHandler -> BeginPrimitives2D (objectTransform);
926 fpSceneHandler -> AddPrimitive (graphics_primitive);
927 fpSceneHandler -> EndPrimitives2D ();
935 DrawT (circle, objectTransform);
941 DrawT (polyhedron, objectTransform);
947 DrawT (line, objectTransform);
953 DrawT (polymarker, objectTransform);
959 DrawT (scale, objectTransform);
965 DrawT (square, objectTransform);
971 DrawT (text, objectTransform);
977 DrawT2D (circle, objectTransform);
983 DrawT2D (polyhedron, objectTransform);
989 DrawT2D (line, objectTransform);
995 DrawT2D (polymarker, objectTransform);
1001 DrawT2D (square, objectTransform);
1007 DrawT2D (text, objectTransform);
1011 #ifdef G4MULTITHREADED
1025 #ifdef G4MULTITHREADED
1039 #ifdef G4MULTITHREADED
1046 #ifdef G4MULTITHREADED
1077 #ifdef G4MULTITHREADED
1082 Draw (*pSol, attribs, objectTransform);
1088 #ifdef G4MULTITHREADED
1108 #ifdef G4MULTITHREADED
1124 G4VSolid* pSol = pLV -> GetSolid ();
1125 Draw (*pSol, attribs, objectTransform);
1133 if (pSceneHandler) {
1139 G4cout <<
"ERROR in G4VisManager::CreateSceneHandler during "
1141 <<
" scene handler creation.\n No action taken."
1153 if (!fInitialised) Initialise ();
1155 if (!fpSceneHandler) {
1156 PrintInvalidPointers ();
1160 G4VViewer*
p = fpGraphicsSystem -> CreateViewer (*fpSceneHandler, name);
1163 if (fVerbosity >= errors) {
1164 G4cerr <<
"ERROR in G4VisManager::CreateViewer: null pointer during "
1165 << fpGraphicsSystem -> GetName ()
1166 <<
" viewer creation.\n No action taken."
1172 if (p -> GetViewId() < 0) {
1173 if (fVerbosity >= errors) {
1174 G4cerr <<
"ERROR in G4VisManager::CreateViewer during "
1175 << fpGraphicsSystem -> GetName ()
1176 <<
" viewer instantiation.\n No action taken."
1187 p -> SetViewParameters(initialvp);
1189 if (p -> GetViewId() < 0) {
1190 if (fVerbosity >= errors) {
1191 G4cerr <<
"ERROR in G4VisManager::CreateViewer during "
1192 << fpGraphicsSystem -> GetName ()
1193 <<
" viewer initialisation.\n No action taken."
1200 fpSceneHandler -> AddViewerToList (fpViewer);
1201 fpSceneHandler -> SetCurrentViewer (fpViewer);
1202 if (fVerbosity >= confirmations) {
1203 G4cout <<
"G4VisManager::CreateViewer: new viewer created."
1208 if (fVerbosity >= parameters) {
1213 static G4bool warned =
false;
1214 if (fVerbosity >= confirmations) {
1217 "NOTE: objects with visibility flag set to \"false\""
1218 " will not be drawn!"
1219 "\n \"/vis/viewer/set/culling global false\" to Draw such objects."
1220 "\n Also see other \"/vis/viewer/set\" commands."
1227 static G4bool warned =
false;
1228 if (fVerbosity >= warnings) {
1231 "WARNING: covered objects in solid mode will not be rendered!"
1232 "\n \"/vis/viewer/set/culling coveredDaughters false\" to reverse this."
1233 "\n Also see other \"/vis/viewer/set\" commands."
1243 G4cout <<
"G4VisManager::GeometryHasChanged() called." <<
G4endl;
1249 -> GetNavigatorForTracking () -> GetWorldVolume ();
1252 G4cout <<
"WARNING: There is no world volume!" <<
G4endl;
1258 G4int iScene, nScenes = sceneList.size ();
1259 for (iScene = 0; iScene < nScenes; iScene++) {
1260 G4Scene* pScene = sceneList [iScene];
1261 std::vector<G4Scene::Model>& modelList = pScene -> SetRunDurationModelList ();
1262 if (modelList.size ()) {
1265 modelInvalid =
false;
1266 std::vector<G4Scene::Model>::iterator iterModel;
1267 for (iterModel = modelList.begin();
1268 iterModel != modelList.end();
1274 G4cout <<
"WARNING: Model \""
1275 << iterModel->fpModel->GetGlobalDescription ()
1277 "\" is no longer valid - being removed\n from scene \""
1278 << pScene -> GetName () <<
"\""
1281 modelList.erase (iterModel);
1285 }
while (modelInvalid);
1287 if (modelList.size () == 0) {
1289 G4cout <<
"WARNING: No models left in this scene \""
1290 << pScene -> GetName ()
1298 ApplyCommand (
G4String(
"/vis/scene/notifyHandlers " + pScene->
GetName()));
1304 if (
fpScene &&
fpScene -> GetRunDurationModelList ().size () == 0) {
1306 G4cout <<
"WARNING: The current scene \""
1308 <<
"\" has no models."
1317 G4cout <<
"G4VisManager::NotifyHandler() called." <<
G4endl;
1322 G4int iScene, nScenes = sceneList.size ();
1323 for (iScene = 0; iScene < nScenes; iScene++) {
1324 G4Scene* pScene = sceneList [iScene];
1325 std::vector<G4Scene::Model>& modelList = pScene -> SetRunDurationModelList ();
1327 if (modelList.size ()) {
1330 ApplyCommand (
G4String(
"/vis/scene/notifyHandlers " + pScene->
GetName()));
1335 if (
fpScene &&
fpScene -> GetRunDurationModelList ().size () == 0) {
1337 G4cout <<
"WARNING: The current scene \""
1339 <<
"\" has no models."
1379 assert (0 != trajectoryModel);
1382 trajectoryModel->
Draw(trajectory, visible);
1389 if (fVerbosity >= warnings) {
1391 "WARNING: SetUserAction is deprecated. Use RegisterRunDurationUserVisAction."
1394 RegisterRunDurationUserVisAction(
"SetUserAction",pVisAction,extent);
1401 fRunDurationUserVisActions.push_back(
UserVisAction(name,pVisAction));
1403 fUserVisActionExtents[pVisAction] = extent;
1405 if (fVerbosity >= warnings) {
1407 "WARNING: No extent set for user vis action \"" << name <<
"\"."
1417 fEndOfEventUserVisActions.push_back(
UserVisAction(name,pVisAction));
1419 fUserVisActionExtents[pVisAction] = extent;
1421 if (fVerbosity >= warnings) {
1423 "WARNING: No extent set for user vis action \"" << name <<
"\"."
1433 fEndOfRunUserVisActions.push_back(
UserVisAction(name,pVisAction));
1435 fUserVisActionExtents[pVisAction] = extent;
1437 if (fVerbosity >= warnings) {
1439 "WARNING: No extent set for user vis action \"" << name <<
"\"."
1457 G4cout <<
"G4VisManager::SetCurrentGraphicsSystem: system now "
1458 << pSystem -> GetName () <<
G4endl;
1465 G4int nSH = sceneHandlerList.size ();
1467 for (iSH = nSH - 1; iSH >= 0; iSH--) {
1468 if (sceneHandlerList [iSH] -> GetGraphicsSystem () == pSystem)
break;
1473 G4cout <<
" Scene Handler now "
1479 G4cout <<
" Scene now \""
1484 if (viewerList.size ()) {
1504 G4cout <<
"G4VisManager::SetCurrentSceneHandler: scene handler now \""
1505 << pSceneHandler -> GetName () <<
"\"" <<
G4endl;
1510 G4cout <<
" Scene now \""
1517 G4cout <<
" Graphics system now \""
1522 G4int nViewers = viewerList.size ();
1525 for (iViewer = 0; iViewer < nViewers; iViewer++) {
1526 if (
fpViewer == viewerList [iViewer])
break;
1528 if (iViewer >= nViewers) {
1538 "WARNING: Problem setting scene handler - please report circumstances."
1547 "WARNING: No viewers for this scene handler - please create one."
1556 G4cout <<
"G4VisManager::SetCurrentViewer: viewer now "
1557 << pViewer -> GetName ()
1564 "WARNING: No scene handler for this viewer - please create one."
1576 "WARNING: Problem setting viewer - please report circumstances."
1584 G4cout <<
"Current available graphics systems are:\n";
1587 const G4String& name = gs->GetName();
1588 const std::vector<G4String>& nicknames = gs->GetNicknames();
1592 for (
size_t i = 0; i < nicknames.size(); ++i) {
1606 G4cout <<
"\n NONE!!! None registered - yet! Mmmmm!" <<
G4endl;
1615 const std::vector<G4VModelFactory<G4VTrajectoryModel>*>& factoryList =
1617 if (factoryList.empty())
G4cout <<
" None" << G4endl;
1619 std::vector<G4VModelFactory<G4VTrajectoryModel>*>::const_iterator i;
1620 for (i = factoryList.begin(); i != factoryList.end(); ++i)
1625 const std::map<G4String, G4VTrajectoryModel*>& modelMap =
1627 if (!modelMap.empty()) {
1629 std::map<G4String, G4VTrajectoryModel*>::const_iterator i;
1630 for (i = modelMap.begin(); i != modelMap.end(); ++i) {
1631 G4cout <<
" " << i->second->Name();
1632 if (i->second == listManager->
Current())
G4cout <<
" (Current)";
1644 const std::vector<G4VModelFactory<G4VFilter<G4VTrajectory> >*>&
1646 if (factoryList.empty())
G4cout <<
" None" << G4endl;
1648 std::vector<G4VModelFactory<G4VFilter<G4VTrajectory> >*>::const_iterator i;
1649 for (i = factoryList.begin(); i != factoryList.end(); ++i)
1652 const std::vector<G4VFilter<G4VTrajectory>*>&
1654 if (!filterList.empty()) {
1656 std::vector<G4VFilter<G4VTrajectory>*>::const_iterator i;
1657 for (i = filterList.begin(); i != filterList.end(); ++i) {
1668 "You have successfully registered the following user vis actions."
1670 G4cout <<
"Run Duration User Vis Actions:";
1680 G4cout <<
"End of Event User Vis Actions:";
1690 G4cout <<
"End of Run User Vis Actions:";
1703 "Some /vis commands (optionally) take a string to specify colour."
1704 "\nAvailable colours:\n ";
1706 for (std::map<G4String, G4Colour>::const_iterator i = map.begin();
1709 if (++i != map.end())
G4cout <<
", ";
1716 G4cerr <<
"ERROR: G4VisManager::PrintInvalidPointers:";
1718 G4cerr <<
"\n null graphics system pointer.";
1725 "\n Null scene pointer. Use \"/vis/drawVolume\" or"
1726 " \"/vis/scene/create\".";
1729 "\n Null scene handler pointer. Use \"/vis/open\" or"
1730 " \"/vis/sceneHandler/create\".";
1733 "\n Null viewer pointer. Use \"/vis/viewer/create\".";
1739 #ifdef G4MULTITHREADED
1742 G4bool mtRunInProgress =
false;
1743 std::deque<const G4Event*> mtVisEventQueue;
1752 if (!pSceneHandler)
return 0;
1754 if (!pScene)
return 0;
1756 if (!pViewer)
return 0;
1771 pViewer->SwitchToVisSubThread();
1776 G4int eventQueueSize = mtVisEventQueue.size();
1780 while (eventQueueSize) {
1783 const G4Event*
event = mtVisEventQueue.front();
1823 mtVisEventQueue.pop_front();
1824 event->PostProcessingFinished();
1825 eventQueueSize = mtVisEventQueue.size();
1831 G4int runInProgress = mtRunInProgress;
1833 if (!runInProgress) {
1840 #ifdef G4VIS_USE_STD11
1841 std::this_thread::sleep_for(std::chrono::milliseconds(100));
1848 pViewer->DoneWithVisSubThread();
1849 pViewer->MovingToMasterThread();
1867 #ifdef G4MULTITHREADED
1874 #ifdef G4MULTITHREADED
1882 if (nEventsToBeProcessed == 0)
return;
1891 #ifdef G4MULTITHREADED
1905 mtRunInProgress =
true;
1931 #ifndef G4MULTITHREADED
1953 #ifdef G4MULTITHREADED
1960 #ifdef G4MULTITHREADED
1967 if (!currentRun)
return;
1972 if (!currentEvent)
return;
1977 if (!currentEvent->
ToBeKept())
return;
1982 #ifdef G4MULTITHREADED
1986 G4int eventQueueSize = mtVisEventQueue.size();
1990 G4bool eventQueueFull =
false;
1991 while (fMaxEventQueueSize > 0 && eventQueueSize >= fMaxEventQueueSize) {
1994 if (fWaitOnEventQueueFull) {
1995 static G4bool warned =
false;
1998 "WARNING: The number of events in the visualisation queue has exceeded"
2000 << fMaxEventQueueSize <<
2001 ".\n If, during a multithreaded run, the simulation gets ahead of the"
2002 "\n visualisation by more than this maximum, the simulation is delayed"
2003 "\n until the vis sub-thread has drawn a few more events and removed them"
2004 "\n from the queue. You may change this maximum number of events with"
2005 "\n \"/vis/multithreading/maxEventQueueSize <N>\", where N is the maximum"
2006 "\n number you wish to allow. N <= 0 means \"unlimited\"."
2007 "\n Alternatively you may choose to discard events for drawing by setting"
2008 "\n \"/vis/multithreading/actionOnEventQueueFull discard\"."
2009 "\n To avoid visualisation altogether: \"/vis/disable\"."
2010 "\n And maybe \"/tracking/storeTrajectories 0\"."
2016 #ifdef G4VIS_USE_STD11
2017 std::this_thread::sleep_for(std::chrono::milliseconds(100));
2023 static G4bool warned =
false;
2026 "WARNING: The number of events in the visualisation queue has exceeded"
2028 << fMaxEventQueueSize <<
2029 ".\n Some events have been discarded for drawing. You may change this"
2030 "\n behaviour with \"/vis/multithreading/actionOnEventQueueFull wait\"."
2031 "\n To avoid visualisation altogether: \"/vis/disable\"."
2032 "\n And maybe \"/tracking/storeTrajectories 0\"."
2036 eventQueueFull =
true;
2041 eventQueueSize = mtVisEventQueue.size();
2045 if (!eventQueueFull) {
2049 mtVisEventQueue.push_back(currentEvent);
2064 G4int nEventsToBeProcessed = 0;
2065 G4int nKeptEvents = 0;
2070 const std::vector<const G4Event*>* events = currentRun->
GetEventVector();
2071 if (events) nKeptEvents = events->size();
2091 if (eventID < nEventsToBeProcessed - 1) {
2098 if (nKeptEvents == 0) {
2117 if (maxNumberOfKeptEvents > 0 &&
2121 static G4bool warned =
false;
2125 "WARNING: G4VisManager::EndOfEvent: Automatic event keeping suspended."
2126 "\n The number of events exceeds the maximum, "
2127 << maxNumberOfKeptEvents <<
2128 ", that may be kept by\n the vis manager."
2134 }
else if (maxNumberOfKeptEvents != 0) {
2153 #ifdef G4MULTITHREADED
2161 #ifdef G4MULTITHREADED
2169 if (nEventsToBeProcessed == 0)
return;
2172 if (!currentRun)
return;
2174 #ifdef G4MULTITHREADED
2179 mtRunInProgress =
false;
2183 delete mtVisSubThread;
2188 #ifdef G4MULTITHREADED
2198 <<
"WARNING: Number of events drawn this run, "
2200 << noOfEventsRequested <<
2201 ".\n (This is because you requested \"/vis/multithreading/actionOnEventQueueFull discard\".)"
2208 G4int nKeptEvents = 0;
2209 const std::vector<const G4Event*>* events = currentRun->
GetEventVector();
2210 if (events) nKeptEvents = events->size();
2213 G4cout <<
"WARNING: " << nKeptEvents;
2214 if (nKeptEvents == 1)
G4cout <<
" event has";
2215 else G4cout <<
" events have";
2216 G4cout <<
" been kept for refreshing and/or reviewing." <<
G4endl;
2220 G4cout <<
"No keep requests were";
2222 G4cout <<
"Only 1 keep request was";
2229 "\n \"/vis/reviewKeptEvents\" to review them one by one."
2230 "\n \"/vis/enable\", then \"/vis/viewer/flush\" or \"/vis/viewer/rebuild\" to see them accumulated."
2253 "WARNING: G4VisManager::EndOfRun: Automatic event keeping was suspended."
2254 "\n The number of events in the run exceeded the maximum, "
2256 ", that may be\n kept by the vis manager." <<
2257 "\n The number of events kept by the vis manager can be changed with"
2258 "\n \"/vis/scene/endOfEventAction accumulate <N>\", where N is the"
2259 "\n maximum number you wish to allow. N < 0 means \"unlimited\"."
2290 G4cout <<
"\"/vis/viewer/update\" to close file." <<
G4endl;
2320 (*i)->SetTransientsDrawnThisEvent(
false);
2321 (*i)->SetTransientsDrawnThisRun(
false);
2326 G4String viewerShortName (viewerName);
2327 viewerShortName = viewerShortName (0, viewerShortName.find (
' '));
2328 return viewerShortName.
strip ();
2334 size_t iHandler, iViewer;
2337 for (iHandler = 0; iHandler < nHandlers; iHandler++) {
2339 const G4ViewerList& viewerList = sceneHandler -> GetViewerList ();
2340 for (iViewer = 0; iViewer < viewerList.size (); iViewer++) {
2341 viewer = viewerList [iViewer];
2342 if (viewerShortName == viewer -> GetShortName ()) {
2349 if (found)
return viewer;
2357 switch (verbosity) {
2358 case quiet: rs =
"quiet (0)";
break;
2359 case startup: rs =
"startup (1)";
break;
2360 case errors: rs =
"errors (2)";
break;
2361 case warnings: rs =
"warnings (3)";
break;
2363 case parameters: rs =
"parameters (5)";
break;
2364 case all: rs =
"all (6)";
break;
2373 if (
ss(0) ==
'q') verbosity =
quiet;
2374 else if (
ss(0) ==
's') verbosity =
startup;
2375 else if (
ss(0) ==
'e') verbosity =
errors;
2379 else if (
ss(0) ==
'a') verbosity =
all;
2382 std::istringstream is(ss);
2385 G4cerr <<
"ERROR: G4VisManager::GetVerbosityValue: invalid verbosity \""
2386 << verbosityString <<
"\"";
2404 else if (intVerbosity >
all) verbosity =
all;
2405 else verbosity =
Verbosity(intVerbosity);
2425 static G4bool noGSPrinting =
true;
2430 noGSPrinting =
false;
2433 "WARNING: G4VisManager::IsValidView(): Attempt to draw when no graphics system"
2434 "\n has been instantiated. Use \"/vis/open\" or \"/vis/sceneHandler/create\"."
2435 "\n Alternatively, to avoid this message, suppress instantiation of vis"
2436 "\n manager (G4VisExecutive) and ensure drawing code is executed only if"
2437 "\n G4VVisManager::GetConcreteInstance() is non-zero."
2447 "ERROR: G4VisManager::IsValidView(): Current view is not valid."
2456 G4cerr <<
"ERROR: G4VisManager::IsValidView ():";
2459 "\n The current scene \""
2461 <<
"\" is not handled by"
2462 "\n the current scene handler \""
2465 "\n (it currently handles scene \""
2469 "\n (a) attach it to the scene handler with"
2470 "\n /vis/sceneHandler/attach "
2473 "\n (b) create a new scene handler with "
2474 "\n /vis/sceneHandler/create <graphics-system>,"
2475 "\n in which case it should pick up the the new scene."
2479 G4cout <<
"\n Scene handler \""
2481 <<
"\" has null scene pointer."
2482 "\n Attach a scene with /vis/sceneHandler/attach [<scene-name>]"
2490 if (viewerList.size () == 0) {
2493 "ERROR: G4VisManager::IsValidView (): the current scene handler\n \""
2495 <<
"\" has no viewers. Do /vis/viewer/create."
2505 if (!successful ||
fpScene -> IsEmpty ()) {
2507 G4cerr <<
"ERROR: G4VisManager::IsValidView ():";
2509 "\n Attempt at some drawing operation when scene is empty."
2510 "\n Maybe the geometry has not yet been defined."
2511 " Try /run/initialize."
2512 "\n Or use \"/vis/scene/add/extent\"."
2521 "WARNING: G4VisManager: the scene was empty, \"world\" has been"
2522 "\n added and the scene handlers notified.";
2534 G4cout<<
"G4VisManager: No model factories registered with G4VisManager."<<
G4endl;
2535 G4cout<<
"G4VisManager::RegisterModelFactories() should be overridden in derived"<<
G4endl;
2536 G4cout<<
"class. See G4VisExecutive for an example."<<
G4endl;
2540 #ifdef G4MULTITHREADED
2541 void G4VisManager::SetUpForAThread()
void RegisterModelFactory(G4TrajDrawModelFactory *factory)
const std::map< G4String, T * > & Map() const
G4bool GetMarkForClearingTransientStore() const
void SetTransientsDrawnThisEvent(G4bool)
static G4MTRunManager * GetMasterRunManager()
static G4RunManager * GetRunManager()
const G4Run * GetCurrentRun() const
void SetTransientsDrawnThisEvent(G4bool)
std::vector< G4UImessenger * > fMessengerList
const G4VTrajectoryModel * CurrentTrajDrawModel() const
G4bool fTransientsDrawnThisEvent
void Draw2D(const G4Circle &, const G4Transform3D &objectTransformation=G4Transform3D())
static void SetConcreteInstance(G4VVisManager *)
G4LogicalVolume * GetLogicalVolume() const
void ResetTransientsDrawnFlags()
friend class G4VisStateDependent
#define TOOLS_COLORS_STAT(name, r, g, b)
const std::vector< Factory * > & FactoryList() const
static Verbosity GetVerbosityValue(const G4String &)
void SetCurrentTrajectory(const G4VTrajectory *pTraj)
G4VSceneHandler * fpSceneHandler
G4int GetStoreTrajectory() const
const std::vector< Filter * > & FilterList() const
G4int ApplyCommand(const char *aCommand)
void PrintAvailableColours(Verbosity) const
G4int fDrawGroupNestingDepth
static G4SolidsWorkspacePool * GetInstance()
G4VisModelManager< G4VTrajectoryModel > * fpTrajDrawModelMgr
const List * ListManager() const
const std::vector< Factory * > & FactoryList() const
void SetRunID(G4int runID)
G4bool fTransientsDrawnThisRun
static G4VisManager * GetInstance()
virtual void ClearTransientStore()
void CreateViewer(const G4String &name="", const G4String &XGeometry="")
virtual void DescribeYourselfTo(G4VGraphicsScene &scene) const =0
void RegisterEndOfRunUserVisAction(const G4String &name, G4VUserVisAction *, const G4VisExtent &=G4VisExtent())
G4Navigator * GetNavigatorForTracking() const
const G4ViewParameters & GetViewParameters() const
const Model * Current() const
G4bool fEventKeepingSuspended
void PrintAvailableUserVisActions(Verbosity) const
static std::vector< G4String > VerbosityGuidanceStrings
G4int GetNumberOfEventsToBeProcessed() const
G4VisFilterManager< G4VDigi > * fpDigiFilterMgr
static G4UImanager * GetUIpointer()
G4GraphicsSystemList fAvailableGraphicsSystems
void SetVerboseLevel(G4int)
void PrintAvailableModels(Verbosity) const
G4TrackingManager * GetTrackingManager() const
static G4VVisManager * GetConcreteInstance()
static Verbosity fVerbosity
std::vector< UserVisAction > fEndOfRunUserVisActions
#define G4THREADSLEEP(tick)
void DispatchToModel(const G4VTrajectory &)
void PrintAvailableGraphicsSystems(Verbosity) const
static G4RunManagerKernel * GetRunManagerKernel()
G4bool FilterHit(const G4VHit &)
#define G4MUTEX_INITIALIZER
G4bool fIgnoreStateChanges
G4VisFilterManager< G4VHit > * fpHitFilterMgr
G4bool GetRefreshAtEndOfEvent() const
virtual void RegisterGraphicsSystems()=0
static void InitialiseColourMap()
G4VGraphicsSystem * fpGraphicsSystem
const G4String & GetName() const
G4bool RegisterGraphicsSystem(G4VGraphicsSystem *)
void SetCurrentViewer(G4VViewer *)
void InitialiseG4ColourMap() const
G4VisManager(const G4String &verbosityString="warnings")
G4int GetMaxNumberOfKeptEvents() const
G4VViewer * GetCurrentViewer() const
void KeepForPostProcessing() const
void RegisterModel(G4VTrajectoryModel *model)
void DrawEvent(const G4Event *)
void SetWorldVolume(G4VPhysicalVolume *pWorld)
G4VisFilterManager< G4VTrajectory > * fpTrajFilterMgr
static G4EventManager * GetEventManager()
G4String strip(G4int strip_Type=trailing, char c=' ')
void Draw(const G4Circle &, const G4Transform3D &objectTransformation=G4Transform3D())
void KeepTheCurrentEvent()
G4int fNoOfEventsDrawnThisRun
void SetTransientsDrawnThisRun(G4bool)
static Verbosity GetVerbosity()
static G4VisManager * fpInstance
G4bool IsCullingInvisible() const
G4bool GetTransientsDrawnThisEvent() const
std::vector< G4VSceneHandler * >::const_iterator G4SceneHandlerListConstIterator
void RegisterMessenger(G4UImessenger *messenger)
void SetUpForSpecialThread(G4String aPrefix)
G4GLOB_DLL std::ostream G4cerr
void RegisterMessengers()
static void SetVisManager(G4VisManager *)
#define G4MUTEXUNLOCK(mutex)
G4bool IsAutoRefresh() const
const G4Event * GetConstCurrentEvent()
void SetCurrentGraphicsSystem(G4VGraphicsSystem *)
void CreateAndUseWorkspace()
static G4TransportationManager * GetTransportationManager()
void ClearTransientStoreIfMarked()
void SetCurrentSceneHandler(G4VSceneHandler *)
static G4GeometryWorkspacePool * GetInstance()
G4bool GetRefreshAtEndOfRun() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
void * G4ThreadFunReturnType
std::vector< G4UIcommand * > fDirectoryList
void PrintInvalidPointers() const
std::vector< UserVisAction > fEndOfEventUserVisActions
void BeginDraw(const G4Transform3D &objectTransformation=G4Transform3D())
FilterMode::Mode GetMode() const
G4bool IsMultithreadedApplication()
G4bool fDrawEventOnlyIfToBeKept
const T * Current() const
void SetCurrentScene(G4Scene *)
void SelectTrajectoryModel(const G4String &model)
const G4GraphicsSystemList & GetAvailableGraphicsSystems()
Functionality GetFunctionality() const
void * G4ThreadFunArgType
#define G4THREADJOIN(worker)
G4bool FilterDigi(const G4VDigi &)
G4String Placement() const
G4double GetExtentRadius() const
static const std::map< G4String, G4Colour > & GetMap()
void SetUserAction(G4VUserVisAction *pVisAction, const G4VisExtent &=G4VisExtent())
G4String Placement() const
const std::vector< const G4Event * > * GetEventVector() const
void GeometryHasChanged()
#define G4MUTEXLOCK(mutex)
static G4RunManagerKernel * GetMasterRunManagerKernel()
G4bool FilterTrajectory(const G4VTrajectory &)
G4GLOB_DLL std::ostream G4cout
void SetXGeometryString(const G4String &)
void RegisterRunDurationUserVisAction(const G4String &name, G4VUserVisAction *, const G4VisExtent &=G4VisExtent())
void G4THREADCREATE(_Worker *&worker, _Func func, _Args...args)
void DrawT2D(const T &graphics_primitive, const G4Transform3D &objectTransform)
virtual void Draw(const G4VTrajectory &trajectory, const G4bool &visible=true) const =0
G4VSolid * GetSolid() const
G4VisStateDependent * fpStateDependent
G4bool IsCullingCovered() const
void SetEventID(G4int eventID)
void SetCurrent(const G4String &)
void BeginDraw2D(const G4Transform3D &objectTransformation=G4Transform3D())
G4VSceneHandler * GetCurrentSceneHandler() const
std::vector< UserVisAction > fRunDurationUserVisActions
G4VViewer * GetViewer(const G4String &viewerName) const
const XML_Char XML_Content * model
static G4String VerbosityString(Verbosity)
void DrawEndOfRunModels()
virtual void RegisterModelFactories()
G4String ViewerShortName(const G4String &viewerName) const
G4SceneHandlerList fAvailableSceneHandlers
void CreateSceneHandler(const G4String &name="")
G4bool GetTransientsDrawnThisRun() const
void CreateAndUseWorkspace()
G4Scene * GetScene() const
void RegisterEndOfEventUserVisAction(const G4String &name, G4VUserVisAction *, const G4VisExtent &=G4VisExtent())
void IgnoreStateChanges(G4bool)
void SetMarkForClearingTransientStore(G4bool)
void DrawT(const T &graphics_primitive, const G4Transform3D &objectTransform)