Import Geant4 10.7.0 source tree

This commit is contained in:
Gabriele Cosmo
2020-12-04 12:30:43 +01:00
parent 67ba86d073
commit dab42d2018
3770 changed files with 226369 additions and 286486 deletions
+2 -1
View File
@@ -11,7 +11,7 @@ endif
# CPPFLAGS += -DG4DEBUG_VIS_MANAGEMENT
GLOBLIBS = libG4modeling.lib
GLOBLIBS += libG4run.lib libG4event.lib
GLOBLIBS += libG4tasking.lib libG4run.lib libG4event.lib
GLOBLIBS += libG4tracking.lib libG4processes.lib libG4digits_hits.lib
GLOBLIBS += libG4track.lib libG4particles.lib libG4geometry.lib
GLOBLIBS += libG4materials.lib libG4graphics_reps.lib
@@ -40,6 +40,7 @@ CPPFLAGS += -I$(G4BASE)/digits_hits/hits/include
CPPFLAGS += -I$(G4BASE)/particles/management/include
CPPFLAGS += -I$(G4BASE)/materials/include
CPPFLAGS += -I$(G4BASE)/run/include
CPPFLAGS += -I$(G4BASE)/tasking/include
CPPFLAGS += -I$(G4BASE)/event/include
CPPFLAGS += -I$(G4BASE)/track/include
CPPFLAGS += -I$(G4BASE)/processes/management/include
+51 -22
View File
@@ -25,6 +25,35 @@ committal in the CVS repository !
History file for visualization management sub-category
------------------------------------------------------
16 November 2020 Gabriele Cosmo (visman-V10-06-12)
- Fixed typos in printed-out text. Addressing problem report #2285.
21 October 2020 Jonathan Madsen (visman-V10-06-11)
- Implemented G4RunManagerFactory::GetMasterRunManager()
21 October 2020 John Allison (visman-V10-06-10)
- G4VisManager: Improve logic of automatic event keeping.
o In MT mode, now keeps one (random) event when end-of-event action is "refresh".
o In MT mode, keeps events (up to a user-adjustable maximum number).
o These may be in addition to events kept by a user in his/her user actions.
o Improved messaging.
15 October 2020 John Allison (visman-V10-06-09)
- Part of vis-V10-06-08.
- G4VVisCommand.hh/cc, G4VisCommandsCompound.cc, G4VisCommandsSceneHandler.cc:
o Use command->CommandFailed() - remove internal fErrorCode.
10 August 2020 John Allison (visman-V10-06-08)
- G4VVisCommand.cc, G4VisCommandsViewer.cc, G4VisManager.cc:
o Remove obsolete G4VIS_USE_STD11 and references to obsolete G4VIS_USE.
(G4VIS_USE was removed in Geant4 10.6.)
04 August 2020 John Allison (visman-V10-06-07)
- G4VisCommandsScene.cc:
o Remove superfluous/unnecessary SetView in G4VisCommandSceneNotifyHandlers.
- G4VisManager.cc:
o Protect algorithm in NotifyHandlers with IsValidView.
18 June 2020 John Allison (visman-V10-06-06)
* G4VisCommandsSceneAdd.cc:
/vis/scene/add/*Field: Correct guidance (red->green->blue).
@@ -422,7 +451,7 @@ History file for visualization management sub-category
- G4VViewer::G4Spline: Remove.
- /vis/viewer/set/timeWindow/displayLightFront: change defaults.
- /vis/viewer/colourByDensity: change defaults.
24 July 2018 John Allison (visman-V10-04-13)
- G4VisCommandsViewer.cc:
o /vis/viewer/interpolate: Fix gcc8 warnings.
@@ -585,7 +614,7 @@ History file for visualization management sub-category
- G4VisManager:
o Moved SetUserAction out of line and added warning message:
"Deprecated. Use RegisterRunDurationUserVisAction."
9th December 2016 John Allison (visman-V10-03-00)
- Coworks with modeling-V10-03-00.
- G4VVisCommand:
@@ -720,7 +749,7 @@ std::ostream& operator <<
- G4ViewParameters.cc:
o G4ViewParameters::CatmullRomCubicSplineInterpolation:
Improved interpolation of vis attributes modifiers.
14th August 2016 John Allison (visman-V10-02-19)
- Ooops. Now as stated.
@@ -798,7 +827,7 @@ G4VisCommandViewerClone::SetNewValue
available on Windows because it uses popen, a way of getting
output from a system command. _popen (with an underscore) is
said to be available in Windows but this has not been tried.
1st June 2016 John Allison (visman-V10-02-11)
- Introduced /vis/viewer/interpolate. See History from development
branch visman-V10-02-02-branch as follows:
@@ -850,7 +879,7 @@ G4VisCommandViewerClone::SetNewValue
26th January 2016 John Allison
- Merged visman-V10-02-03: G4VisManager::G4VisSubThread:
GetNavigatorForTracking -> SetWorldVolume
This is required for OriginVolume drawing and filtering.
This is required for OriginVolume drawing and filtering.
24th January 2016 John Allison (visman-V10-02-02-branch-04)
- Refinements.
23rd January 2016 John Allison (visman-V10-02-02-branch-01)
@@ -916,7 +945,7 @@ G4VisCommandViewerClone::SetNewValue
26th January 2016 John Allison (visman-V10-02-03)
- G4VisManager::G4VisSubThread:
GetNavigatorForTracking -> SetWorldVolume
This is required for OriginVolume drawing and filtering.
This is required for OriginVolume drawing and filtering.
14th January 2016 John Allison (visman-V10-02-02)
- Improved /vis/viewer/save.
@@ -935,14 +964,14 @@ G4VisCommandViewerClone::SetNewValue
- G4VViewer:
o Add ComputeFlyThrough method (beta)
o Add an G4Spline class for testing
1st November 2015 John Allison (visman-V10-01-20)
- Introduced (again!) <chrono> for queue handling in MT mode.
o Except for Xeon Phi, which is protected by #ifndef __MIC__
15th October 2015 John Allison (visman-V10-01-19)
- G4VisManager.cc:
o Corrected end-of-run printing for the case of
o Corrected end-of-run printing for the case of
"/vis/multithreading/actionOnEventQueueFull discard".
- G4VisCommandsViewer.cc:
o Improved guidance and confirmation printing for /vis/viewer/save.
@@ -1242,7 +1271,7 @@ G4VisCommandViewerClone::SetNewValue
1st October 2014 Laurent Garnier
-G4VSceneHandler.cc:
o AddPrimitive (const G4Scale& scale) : Remove unnecessary initialization
-G4VisManager :
-G4VisManager :
o Change G4cerr instead of G4cout on some error messages
o Add a warning in SetCurrentViewer() when no scene handler present
@@ -1281,12 +1310,12 @@ G4VisCommandViewerClone::SetNewValue
9th July 2014 Laurent Garnier (visman-V10-00-13)
- Change some G4cout in G4err in case of error messages in
G4VSceneHandler, G4ViewParameters, G4VisCommand, G4VisCommandGeometry, G4VisCommandGeometrySet,
G4VSceneHandler, G4ViewParameters, G4VisCommand, G4VisCommandGeometry, G4VisCommandGeometrySet,
G4VisCommandsTouchable, G4VisCommandsTouchableSet, G4VisCommandViewerDefault, G4VisCommandsViewerSet
8th July 2014 Laurent Garnier (visman-V10-00-12)
- G4VisCommandViewer :
o Revert change to /vis/viewer/update in order not to failed with a Cerr in all examples.
- G4VisCommandViewer :
o Revert change to /vis/viewer/update in order not to failed with a Cerr in all examples.
o Set verbosity on "/vis/viewer/update" to G4cout instead of G4cerr and change the message
7th July 2014 Laurent Garnier (visman-V10-00-11)
@@ -1369,9 +1398,9 @@ G4VisCommandViewerClone::SetNewValue
21st November 2013 Makoto Asai (visman-V09-06-26)
- Move invokation with G4TransportationManager in G4VisCommandsSceneAdd.cc
to G4TrakingMessenger. G4TransportationManager is thread-local.
to G4TrakingMessenger. G4TransportationManager is thread-local.
G4VisCommandsSceneAdd.cc cannot access to G4TransportationManager.
15th November 2013 John Allison
- Some changes as suggested by PVS.
- Fixes for Coverity.
@@ -1780,7 +1809,7 @@ G4VisCommandViewerClone::SetNewValue
twice!! This was an attempt to fix a curious problem whereby
trajectories were not refreshed. Probably the go only to the
back buffer, because a second refresh seems to do the trick.
o /vis/scene/list: Improved.
o /vis/scene/list: Improved.
- G4VisCommandsSceneAdd.cc: /vis/scene/add/userAction:
o Small improvement to guidance and code readability.
@@ -1918,7 +1947,7 @@ G4VisCommandViewerClone::SetNewValue
3rd January 2012 John Allison (visman-V09-05-01)
- G4VisCommandsScene.cc: /vis/scene/notifyHandlers:
o Downgraded "scene has changed" from WARNING to NOTE.
o Downgraded "scene has changed" from WARNING to NOTE.
2nd January 2012 John Allison
- G4VisManager::EndOfEvent: Removed unwarranted DrawView. It was
@@ -2150,7 +2179,7 @@ G4VisCommandViewerClone::SetNewValue
9th March 2010 Laurent Garnier
- G4OpenGLViewer : Fix clipping when resizing non square size windows
8th March 2010 Laurent Garnier
-G4VisManager.cc : Add protection against null pointer
@@ -2244,9 +2273,9 @@ G4VisCommandViewerClone::SetNewValue
argument, such as "800x400" or "800x400-0+0".)
2nd December, Laurent Garnier
- G4ViewParameters.hh G4ViewParameters.icc G4VisManager.hh G4VisManager.icc
- G4ViewParameters.hh G4ViewParameters.icc G4VisManager.hh G4VisManager.icc
G4ViewParameters.cc G4VisManager.cc G4VViewer.cc G4VisCommandsViewer.cc,
do a lot of change to be able to pass XString like 400x600-0+0 to viewers
do a lot of change to be able to pass XString like 400x600-0+0 to viewers
and set position and location. It will work for Qt, X, Win32 for the moment.
27th July 2008 John Allison (visman-V09-01-05)
@@ -2263,7 +2292,7 @@ G4VisCommandViewerClone::SetNewValue
- Fixed gcc-4.3.0 compiler warnings.
5th February 2008, Laurent Garnier
- Implemented a function in order to IncrementPan with X,Y,Z values
- Implemented a function in order to IncrementPan with X,Y,Z values
29th January 2008 John Allison (visman-V09-01-01)
- G4VisExecutive.icc: Re-instated G4DAWNFILE (somehow got lost!!)
@@ -2569,7 +2598,7 @@ G4VisCommandViewerClone::SetNewValue
4th May 2006 John Allison (visman-V08-00-15)
- Improved protection for null models and parameters.
2nd May 2006 Jane Tinslay
2nd May 2006 Jane Tinslay
- Add G4TrajectoryGenericDrawerFactory to G4VisExecutive
- Add FilterTrajectory method to G4VisManager
@@ -2706,7 +2735,7 @@ G4VisCommandViewerClone::SetNewValue
user has not instantiated a scene handler, e.g., in batch mode.
29th November 2005 Jane Tinslay
- Make G4VisManager::RegisterModelFactories() non-pure for
- Make G4VisManager::RegisterModelFactories() non-pure for
backwards compatibility.
- Add information message to G4VisManager::DispatchToModel when default trajectory
model is used.
@@ -181,7 +181,7 @@ public: // With description
// IMPORTANT: invoke this from your polymorphic versions, e.g.:
// void MyXXXSceneHandler::BeginPrimitives2D
// (const G4Transform3D& objectTransformation) {
// G4VSceneHandler::BeginPrimitives2D ();
// G4VSceneHandler::BeginPrimitives2D (objectTransformation);
// ...
// }
@@ -134,8 +134,6 @@ protected:
static G4VisManager* fpVisManager;
static G4int fErrorCode;
// Current quantities for use in appropriate commands
static G4int fCurrentArrow3DLineSegmentsPerCircle;
static G4Colour fCurrentColour;
@@ -105,6 +105,10 @@
#include "G4VRML2.hh"
#endif
#ifdef G4VIS_USE_QT3D
#include "G4Qt3D.hh"
#endif
// The inline keyword prevents the compiler making an external
// reference even though they cannot actually be inlined since they
// are virtual functions. This prevents a "multiple definition" error
@@ -236,6 +240,9 @@ G4VisExecutive::RegisterGraphicsSystems () {
RegisterGraphicsSystem (new G4RayTracerX);
#endif
#ifdef G4VIS_USE_QT3D
RegisterGraphicsSystem (new G4Qt3D);
#endif
}
// See comments about inlining above.
@@ -525,7 +525,6 @@ private:
G4int fNoOfEventsDrawnThisRun;
G4int fNKeepRequests;
G4bool fEventKeepingSuspended;
G4bool fKeptLastEvent;
G4bool fDrawEventOnlyIfToBeKept;
const G4Event* fpRequestedEvent; // If non-zero, scene handler uses.
G4bool fReviewingKeptEvents;
@@ -94,6 +94,7 @@ geant4_define_module(NAME G4vis_management
G4procman
G4run
G4specsolids
G4tasking
G4track
G4tracking
G4vis_management
@@ -110,6 +111,7 @@ geant4_define_module(NAME G4vis_management
G4particles
G4processes
G4run
G4tasking
G4track
G4tracking
)
@@ -80,9 +80,7 @@
#include "Randomize.hh"
#include "G4StateManager.hh"
#include "G4RunManager.hh"
#ifdef G4MULTITHREADED
#include "G4MTRunManager.hh"
#endif
#include "G4RunManagerFactory.hh"
#include "G4Run.hh"
#include "G4Transform3D.hh"
#include "G4AttHolder.hh"
@@ -657,23 +655,24 @@ void G4VSceneHandler::RequestPrimitives (const G4VSolid& solid)
}
}
void G4VSceneHandler::ProcessScene () {
void G4VSceneHandler::ProcessScene()
{
// Assumes graphics database store has already been cleared if
// relevant for the particular scene handler.
if (!fpScene) return;
if(!fpScene)
return;
if (fpScene->GetExtent() == G4VisExtent::GetNullExtent()) {
G4Exception
("G4VSceneHandler::ProcessScene",
"visman0106", JustWarning,
"The scene has no extent.");
if(fpScene->GetExtent() == G4VisExtent::GetNullExtent())
{
G4Exception("G4VSceneHandler::ProcessScene", "visman0106", JustWarning,
"The scene has no extent.");
}
G4VisManager* visManager = G4VisManager::GetInstance();
if (!visManager->GetConcreteInstance()) return;
if(!visManager->GetConcreteInstance())
return;
G4VisManager::Verbosity verbosity = visManager->GetVerbosity();
@@ -683,40 +682,44 @@ void G4VSceneHandler::ProcessScene () {
// fMarkForClearingTransientStore true causes problems with
// recomputing transients below.) Restore it again at end...
G4bool tmpMarkForClearingTransientStore = fMarkForClearingTransientStore;
fMarkForClearingTransientStore = false;
fMarkForClearingTransientStore = false;
// Traverse geometry tree and send drawing primitives to window(s).
const std::vector<G4Scene::Model>& runDurationModelList =
fpScene -> GetRunDurationModelList ();
fpScene->GetRunDurationModelList();
if (runDurationModelList.size ()) {
if (verbosity >= G4VisManager::confirmations) {
if(runDurationModelList.size())
{
if(verbosity >= G4VisManager::confirmations)
{
G4cout << "Traversing scene data..." << G4endl;
}
BeginModeling ();
BeginModeling();
// Create modeling parameters from view parameters...
G4ModelingParameters* pMP = CreateModelingParameters ();
G4ModelingParameters* pMP = CreateModelingParameters();
for (size_t i = 0; i < runDurationModelList.size (); i++) {
if (runDurationModelList[i].fActive) {
for(size_t i = 0; i < runDurationModelList.size(); i++)
{
if(runDurationModelList[i].fActive)
{
fpModel = runDurationModelList[i].fpModel;
// Note: this is not the place to take action on
// pModel->GetTransformation(). The model must take care of
// this in pModel->DescribeYourselfTo(*this). See, for example,
// G4PhysicalVolumeModel and /vis/scene/add/logo.
fpModel -> SetModelingParameters (pMP);
fpModel -> DescribeYourselfTo (*this);
fpModel -> SetModelingParameters (0);
// Note: this is not the place to take action on
// pModel->GetTransformation(). The model must take care of
// this in pModel->DescribeYourselfTo(*this). See, for example,
// G4PhysicalVolumeModel and /vis/scene/add/logo.
fpModel->SetModelingParameters(pMP);
fpModel->DescribeYourselfTo(*this);
fpModel->SetModelingParameters(0);
}
}
fpModel = 0;
delete pMP;
EndModeling ();
EndModeling();
}
fReadyForTransients = true;
@@ -724,57 +727,64 @@ void G4VSceneHandler::ProcessScene () {
// Refresh event from end-of-event model list.
// Allow only in Idle or GeomClosed state...
G4StateManager* stateManager = G4StateManager::GetStateManager();
G4ApplicationState state = stateManager->GetCurrentState();
if (state == G4State_Idle || state == G4State_GeomClosed) {
G4ApplicationState state = stateManager->GetCurrentState();
if(state == G4State_Idle || state == G4State_GeomClosed)
{
visManager->SetEventRefreshing(true);
if (visManager->GetRequestedEvent()) {
if(visManager->GetRequestedEvent())
{
DrawEvent(visManager->GetRequestedEvent());
} else {
G4RunManager* runManager = G4RunManager::GetRunManager();
#ifdef G4MULTITHREADED
if(G4Threading::IsMultithreadedApplication())
{ runManager = G4MTRunManager::GetMasterRunManager(); }
#endif
if (runManager) {
const G4Run* run = runManager->GetCurrentRun();
}
else
{
G4RunManager* runManager = G4RunManagerFactory::GetMasterRunManager();
if(runManager)
{
const G4Run* run = runManager->GetCurrentRun();
const std::vector<const G4Event*>* events =
run? run->GetEventVector(): 0;
size_t nKeptEvents = 0;
if (events) nKeptEvents = events->size();
if (nKeptEvents) {
run ? run->GetEventVector() : 0;
size_t nKeptEvents = 0;
if(events)
nKeptEvents = events->size();
if(nKeptEvents)
{
if(fpScene->GetRefreshAtEndOfEvent())
{
if(verbosity >= G4VisManager::confirmations)
{
G4cout << "Refreshing event..." << G4endl;
}
const G4Event* event = 0;
if(events && events->size())
event = events->back();
if(event)
DrawEvent(event);
}
else
{ // Accumulating events.
if (fpScene->GetRefreshAtEndOfEvent()) {
if (verbosity >= G4VisManager::confirmations) {
G4cout << "Refreshing event..." << G4endl;
}
const G4Event* event = 0;
if (events && events->size()) event = events->back();
if (event) DrawEvent(event);
} else { // Accumulating events.
if (verbosity >= G4VisManager::confirmations) {
G4cout << "Refreshing events in run..." << G4endl;
}
for (const auto& event: *events) {
if (event) DrawEvent(event);
if(verbosity >= G4VisManager::confirmations)
{
G4cout << "Refreshing events in run..." << G4endl;
}
for(const auto& event : *events)
{
if(event)
DrawEvent(event);
}
if (!fpScene->GetRefreshAtEndOfRun()) {
if (verbosity >= G4VisManager::warnings) {
G4cout <<
"WARNING: Cannot refresh events accumulated over more"
"\n than one runs. Refreshed just the last run."
<< G4endl;
}
}
}
}
if(!fpScene->GetRefreshAtEndOfRun())
{
if(verbosity >= G4VisManager::warnings)
{
G4cout << "WARNING: Cannot refresh events accumulated over more"
"\n than one runs. Refreshed just the last run."
<< G4endl;
}
}
}
}
}
}
visManager->SetEventRefreshing(false);
@@ -782,7 +792,8 @@ void G4VSceneHandler::ProcessScene () {
// Refresh end-of-run model list.
// Allow only in Idle or GeomClosed state...
if (state == G4State_Idle || state == G4State_GeomClosed) {
if(state == G4State_Idle || state == G4State_GeomClosed)
{
DrawEndOfRunModels();
}
@@ -1147,7 +1158,7 @@ G4int G4VSceneHandler::GetNoOfSides(const G4VisAttributes* pVisAttribs)
lineSegmentsPerCircle = pVisAttribs->GetMinLineSegmentsPerCircle();
G4cout <<
"G4VSceneHandler::GetNoOfSides: attempt to set the"
"\nnumber of line segements per circle < " << lineSegmentsPerCircle
"\nnumber of line segments per circle < " << lineSegmentsPerCircle
<< "; forced to " << pVisAttribs->GetMinLineSegmentsPerCircle() << G4endl;
}
}
@@ -36,8 +36,6 @@
#include <sstream>
#include <cctype>
G4int G4VVisCommand::fErrorCode = 0;
G4int G4VVisCommand::fCurrentArrow3DLineSegmentsPerCircle = 6;
G4Colour G4VVisCommand::fCurrentColour = G4Colour::White();
G4Colour G4VVisCommand::fCurrentTextColour = G4Colour::Blue();
@@ -291,10 +289,8 @@ void G4VVisCommand::InterpolateViews
}
// File-writing viewers need to close the file
currentViewer->ShowView();
#ifdef G4VIS_USE_STD11
if (waitTimePerPointmilliseconds > 0)
std::this_thread::sleep_for(std::chrono::milliseconds(waitTimePerPointmilliseconds));
#endif
} while (safetyCount++ < safety); // Loop checking, 16.02.2016, J.Allison
}
@@ -35,9 +35,7 @@
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithoutParameter.hh"
#include "G4RunManager.hh"
#ifdef G4MULTITHREADED
#include "G4MTRunManager.hh"
#endif
#include "G4RunManagerFactory.hh"
#include "G4Run.hh"
#include "G4UIsession.hh"
#include "G4Trajectory.hh"
@@ -286,14 +284,11 @@ void G4VisCommandReviewKeptEvents::SetNewValue (G4UIcommand*, G4String newValue)
G4String& macroFileName = newValue;
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
G4RunManager* runManager = G4RunManager::GetRunManager();
#ifdef G4MULTITHREADED
if(G4Threading::IsMultithreadedApplication())
{ runManager = G4MTRunManager::GetMasterRunManager(); }
#endif
const G4Run* run = runManager? runManager->GetCurrentRun(): 0;
const std::vector<const G4Event*>* events = run? run->GetEventVector(): 0;
size_t nKeptEvents = events? events->size(): 0;
G4RunManager* runManager = G4RunManagerFactory::GetMasterRunManager();
const G4Run* run = runManager ? runManager->GetCurrentRun() : nullptr;
const std::vector<const G4Event*>* events =
run ? run->GetEventVector() : nullptr;
size_t nKeptEvents = events ? events->size() : 0;
if (!nKeptEvents) {
if (verbosity >= G4VisManager::errors) {
@@ -96,8 +96,8 @@ void G4VisCommandDrawTree::SetNewValue(G4UIcommand*, G4String newValue) {
G4bool keepAbleness = fpVisManager->GetConcreteInstance()? true: false;
UImanager->ApplyCommand(G4String("/vis/open " + system));
if (fErrorCode == 0) {
auto errorCode = UImanager->ApplyCommand(G4String("/vis/open " + system));
if (errorCode == 0) {
if (!keepAbleness) { // Enable temporarily
fpVisManager->SetVerboseLevel("Quiet");
UImanager->ApplyCommand("/vis/enable");
@@ -360,7 +360,7 @@ G4VisCommandOpen::~G4VisCommandOpen() {
delete fpCommand;
}
void G4VisCommandOpen::SetNewValue (G4UIcommand*, G4String newValue) {
void G4VisCommandOpen::SetNewValue (G4UIcommand* command, G4String newValue) {
G4String systemName, windowSizeHint;
std::istringstream is(newValue);
is >> systemName >> windowSizeHint;
@@ -371,8 +371,8 @@ void G4VisCommandOpen::SetNewValue (G4UIcommand*, G4String newValue) {
fpVisManager->GetVerbosity() >= G4VisManager::confirmations)
newVerbose = 2;
UImanager->SetVerboseLevel(newVerbose);
fErrorCode = UImanager->ApplyCommand(G4String("/vis/sceneHandler/create " + systemName));
if (fErrorCode == 0) {
auto errorCode = UImanager->ApplyCommand(G4String("/vis/sceneHandler/create " + systemName));
if (errorCode == 0) {
UImanager->ApplyCommand(G4String("/vis/viewer/create ! ! " + windowSizeHint));
} else {
// Use set to get alphabetical order
@@ -385,11 +385,13 @@ void G4VisCommandOpen::SetNewValue (G4UIcommand*, G4String newValue) {
}
}
}
G4cerr << "Candidates are:";
std::ostringstream oss;
oss << "Candidates are:";
for (const auto& candidate: candidates) {
G4cerr << ' ' << candidate;
}
G4cerr << G4endl;
oss << ' ' << candidate;
};
G4cerr << oss.str() << G4endl;
command->CommandFailed(oss);
}
UImanager->SetVerboseLevel(keepVerbose);
}
@@ -32,9 +32,7 @@
#include "G4VisManager.hh"
#include "G4TransportationManager.hh"
#include "G4RunManager.hh"
#ifdef G4MULTITHREADED
#include "G4MTRunManager.hh"
#endif
#include "G4RunManagerFactory.hh"
#include "G4Run.hh"
#include "G4PhysicalVolumeModel.hh"
#include "G4ApplicationState.hh"
@@ -339,18 +337,16 @@ void G4VisCommandSceneEndOfEventAction::SetNewValue (G4UIcommand*,
fpVisManager->ResetTransientsDrawnFlags();
// Are there any events currently kept...
size_t nCurrentlyKept = 0;
G4RunManager* runManager = G4RunManager::GetRunManager();
#ifdef G4MULTITHREADED
if(G4Threading::IsMultithreadedApplication())
{ runManager = G4MTRunManager::GetMasterRunManager(); }
#endif
if (runManager) {
size_t nCurrentlyKept = 0;
G4RunManager* runManager = G4RunManagerFactory::GetMasterRunManager();
if(runManager)
{
const G4Run* currentRun = runManager->GetCurrentRun();
if (currentRun) {
const std::vector<const G4Event*>* events =
currentRun->GetEventVector();
if (events) nCurrentlyKept = events->size();
if(currentRun)
{
const std::vector<const G4Event*>* events = currentRun->GetEventVector();
if(events)
nCurrentlyKept = events->size();
}
}
@@ -768,9 +764,10 @@ void G4VisCommandSceneNotifyHandlers::SetNewValue (G4UIcommand*,
const G4int nViewers = viewerList.size ();
if (nViewers) {
pCurrentSceneHandler -> SetCurrentViewer (pCurrentViewer);
if (pCurrentViewer && pCurrentSceneHandler->GetScene()) {
pCurrentViewer -> SetView ();
}
// JA: I don't think we need this. SetView will be called when needed.
// if (pCurrentViewer && pCurrentSceneHandler->GetScene()) {
// pCurrentViewer -> SetView ();
// }
}
}
}
@@ -61,9 +61,7 @@
#include "G4UIcmdWithAnInteger.hh"
#include "G4Tokenizer.hh"
#include "G4RunManager.hh"
#ifdef G4MULTITHREADED
#include "G4MTRunManager.hh"
#endif
#include "G4RunManagerFactory.hh"
#include "G4StateManager.hh"
#include "G4Run.hh"
#include "G4Event.hh"
@@ -717,13 +715,9 @@ void G4VisCommandSceneAddEventID::SetNewValue (G4UIcommand*, G4String newValue)
void G4VisCommandSceneAddEventID::EventID::operator()
(G4VGraphicsScene& sceneHandler, const G4Transform3D&, const G4ModelingParameters* mp)
{
G4RunManager* runManager = G4RunManager::GetRunManager();
#ifdef G4MULTITHREADED
if (G4Threading::IsMultithreadedApplication()) {
runManager = G4MTRunManager::GetMasterRunManager();
}
#endif
if (!runManager) return;
G4RunManager* runManager = G4RunManagerFactory::GetMasterRunManager();
if(!runManager)
return;
const G4Run* currentRun = runManager->GetCurrentRun();
if (!currentRun) return;
@@ -197,7 +197,7 @@ G4String G4VisCommandSceneHandlerCreate::GetCurrentValue(G4UIcommand*) {
return graphicsSystemName + " " + NextName ();
}
void G4VisCommandSceneHandlerCreate::SetNewValue (G4UIcommand*,
void G4VisCommandSceneHandlerCreate::SetNewValue (G4UIcommand* command,
G4String newValue) {
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
@@ -276,14 +276,15 @@ void G4VisCommandSceneHandlerCreate::SetNewValue (G4UIcommand*,
}
}
if (iGS < 0 || iGS >= nSystems || loopCounter >=3) {
std::ostringstream oss;
oss << "\"" << gsl[iGSBeingTested]->GetNickname()
<< "\" is not compatible with your chosen session,"
" and no fallback system found.";
if (verbosity >= G4VisManager::errors) {
G4cerr <<
"ERROR: G4VisCommandSceneHandlerCreate::SetNewValue: \""
<< gsl[iGSBeingTested]->GetNickname()
<< "\" is not compatible with your chosen session,"
" and no fallback system found."
<< G4endl;
G4cerr << "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue: "
<< oss.str() << G4endl;
}
command->CommandFailed(oss);
return;
}
// A fallback system found...but go back and check this too.
@@ -45,10 +45,8 @@
#include "G4SystemOfUnits.hh"
#include "G4UnitsTable.hh"
#include "G4ios.hh"
#ifdef G4VIS_USE_STD11
#include <chrono>
#include <thread>
#endif
#include <sstream>
#include <fstream>
#include <sstream>
@@ -1062,7 +1062,7 @@ void G4VisCommandsViewerSet::SetNewValue
nSides = vp.SetNoOfSides(nSides);
if (verbosity >= G4VisManager::confirmations) {
G4cout <<
"Number of line segements per circle in polygon approximation is "
"Number of line segments per circle in polygon approximation is "
<< nSides << G4endl;
}
}
@@ -70,6 +70,7 @@
#include "G4TrajectoryDrawByCharge.hh"
#include "Randomize.hh"
#include "G4RunManager.hh"
#include "G4RunManagerFactory.hh"
#include "G4EventManager.hh"
#include "G4Run.hh"
#include "G4Event.hh"
@@ -79,17 +80,14 @@
#include <sstream>
#ifdef G4MULTITHREADED
#include "G4MTRunManager.hh"
#include "G4Threading.hh"
#include "G4AutoLock.hh"
#include "G4GeometryWorkspace.hh"
#include "G4SolidsWorkspace.hh"
#include <deque>
#include <typeinfo>
#ifdef G4VIS_USE_STD11
#include <chrono>
#include <thread>
#endif
# include "G4Threading.hh"
# include "G4AutoLock.hh"
# include "G4GeometryWorkspace.hh"
# include "G4SolidsWorkspace.hh"
# include <deque>
# include <typeinfo>
# include <chrono>
# include <thread>
#endif
G4VisManager* G4VisManager::fpInstance = 0;
@@ -110,7 +108,6 @@ G4VisManager::G4VisManager (const G4String& verbosityString):
fNoOfEventsDrawnThisRun (0),
fNKeepRequests (0),
fEventKeepingSuspended (false),
fKeptLastEvent (false),
fDrawEventOnlyIfToBeKept (false),
fpRequestedEvent (0),
fReviewingKeptEvents (false),
@@ -183,12 +180,10 @@ G4VisManager::G4VisManager (const G4String& verbosityString):
// (c) invoke the Initialise() method of the subclass.
// For example:
// ...
// #ifdef G4VIS_USE
// // Instantiate and initialise Visualization Manager.
// G4VisManager* visManager = new G4VisExecutive;
// visManager -> SetVerboseLevel (Verbose);
// visManager -> Initialise ();
// #endif
// // (Don't forget to delete visManager;)
// ...
@@ -271,11 +266,9 @@ void G4VisManager::Initialise () {
"\n Also you should implement RegisterModelFactories()."
"\n See visualization/management/include/G4VisExecutive.hh/icc, for example."
"\n In your main() you will have something like:"
"\n #ifdef G4VIS_USE"
"\n G4VisManager* visManager = new G4VisExecutive;"
"\n visManager -> SetVerboseLevel (Verbose);"
"\n visManager -> Initialize ();"
"\n #endif"
"\n (Don't forget to delete visManager;)"
"\n"
<< G4endl;
@@ -1047,13 +1040,8 @@ void G4VisManager::Draw (const G4VTrajectory& traj) {
// A trajectory needs a trajectories model to provide G4Atts, etc.
static G4TrajectoriesModel trajectoriesModel;
trajectoriesModel.SetCurrentTrajectory(&traj);
G4RunManager* runManager = G4RunManager::GetRunManager();
#ifdef G4MULTITHREADED
if (G4Threading::IsMultithreadedApplication()) {
runManager = G4MTRunManager::GetMasterRunManager();
}
#endif
const G4Run* currentRun = runManager->GetCurrentRun();
G4RunManager* runManager = G4RunManagerFactory::GetMasterRunManager();
const G4Run* currentRun = runManager->GetCurrentRun();
if (currentRun) {
trajectoriesModel.SetRunID(currentRun->GetRunID());
}
@@ -1329,35 +1317,38 @@ void G4VisManager::NotifyHandlers () {
G4cout << "G4VisManager::NotifyHandler() called." << G4endl;
}
// Check scenes.
G4SceneList& sceneList = fSceneList;
G4int iScene, nScenes = sceneList.size ();
for (iScene = 0; iScene < nScenes; iScene++) {
G4Scene* pScene = sceneList [iScene];
std::vector<G4Scene::Model>& modelList = pScene -> SetRunDurationModelList ();
if (modelList.size ()) {
pScene->CalculateExtent();
G4UImanager::GetUIpointer () ->
ApplyCommand (G4String("/vis/scene/notifyHandlers " + pScene->GetName()));
}
}
if (IsValidView()) {
// Check the manager's current scene...
if (fpScene && fpScene -> GetRunDurationModelList ().size () == 0) {
if (fVerbosity >= warnings) {
G4cout << "WARNING: The current scene \""
<< fpScene -> GetName ()
<< "\" has no run duration models."
<< "\n Use \"/vis/scene/add/volume\" or create a new scene."
<< G4endl;
// Check scenes.
G4SceneList& sceneList = fSceneList;
G4int iScene, nScenes = sceneList.size ();
for (iScene = 0; iScene < nScenes; iScene++) {
G4Scene* pScene = sceneList [iScene];
std::vector<G4Scene::Model>& modelList = pScene -> SetRunDurationModelList ();
if (modelList.size ()) {
pScene->CalculateExtent();
G4UImanager::GetUIpointer () ->
ApplyCommand (G4String("/vis/scene/notifyHandlers " + pScene->GetName()));
}
}
// Check the manager's current scene...
if (fpScene && fpScene -> GetRunDurationModelList ().size () == 0) {
if (fVerbosity >= warnings) {
G4cout << "WARNING: The current scene \""
<< fpScene -> GetName ()
<< "\" has no run duration models."
<< "\n Use \"/vis/scene/add/volume\" or create a new scene."
<< G4endl;
}
fpSceneHandler->ClearTransientStore();
fpSceneHandler->ClearStore();
fpViewer->NeedKernelVisit();
fpViewer->SetView();
fpViewer->ClearView();
fpViewer->FinishView();
}
fpSceneHandler->ClearTransientStore();
fpSceneHandler->ClearStore();
fpViewer->NeedKernelVisit();
fpViewer->SetView();
fpViewer->ClearView();
fpViewer->FinishView();
}
}
@@ -1600,7 +1591,8 @@ void G4VisManager::SetCurrentViewer (G4VViewer* pViewer) {
}
return;
}
fpViewer->SetView();
// JA: I don't think we need this. Setview will be called when needed.
// fpViewer->SetView();
fpSceneHandler -> SetCurrentViewer (pViewer);
fpScene = fpSceneHandler -> GetScene ();
fpGraphicsSystem = fpSceneHandler -> GetGraphicsSystem ();
@@ -1796,16 +1788,16 @@ G4ThreadFunReturnType G4VisManager::G4VisSubThread(G4ThreadFunArgType p)
G4UImanager::GetUIpointer()->SetUpForSpecialThread("G4VIS");
// G4cout << "G4VisManager::G4VisSubThread: thread: "
// << G4Threading::G4GetThreadId() << std::endl;
// G4cout << "G4VisManager::G4VisSubThread: thread: "
// << G4Threading::G4GetThreadId() << std::endl;
// Set up geometry and navigation for a thread
G4GeometryWorkspace::GetPool()->CreateAndUseWorkspace();
G4SolidsWorkspace::GetPool()->CreateAndUseWorkspace();
G4Navigator* navigator =
G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
navigator->SetWorldVolume
(G4MTRunManager::GetMasterRunManagerKernel()->GetCurrentWorld());
G4Navigator* navigator = G4TransportationManager::GetTransportationManager()
->GetNavigatorForTracking();
navigator->SetWorldVolume(
G4RunManagerFactory::GetMasterRunManagerKernel()->GetCurrentWorld());
pViewer->SwitchToVisSubThread();
@@ -1814,17 +1806,18 @@ G4ThreadFunReturnType G4VisManager::G4VisSubThread(G4ThreadFunArgType p)
G4MUTEXLOCK(&mtVisSubThreadMutex);
G4int eventQueueSize = mtVisEventQueue.size();
G4MUTEXUNLOCK(&mtVisSubThreadMutex);
// G4cout << "Event queue size (A): " << eventQueueSize << G4endl;
// G4cout << "Event queue size (A): " << eventQueueSize << G4endl;
while (eventQueueSize) {
G4MUTEXLOCK(&mtVisSubThreadMutex);
const G4Event* event = mtVisEventQueue.front();
G4MUTEXUNLOCK(&mtVisSubThreadMutex);
// G4int eventID = event->GetEventID();
// G4cout <<
// "G4VisManager::G4VisSubThread: Vis sub-thread: Dealing with event: "
// << eventID << G4endl;
// G4int eventID = event->GetEventID();
// G4cout
// << "G4VisManager::G4VisSubThread: Vis sub-thread: Dealing with event:
// "
// << eventID << G4endl;
// Here comes the event drawing
pVisManager->SetTransientsDrawnThisEvent(false);
@@ -1855,7 +1848,7 @@ G4ThreadFunReturnType G4VisManager::G4VisSubThread(G4ThreadFunArgType p)
}
// Testing.
// std::this_thread::sleep_for(std::chrono::seconds(5));
// std::this_thread::sleep_for(std::chrono::seconds(5));
// Then pop and release event
G4MUTEXLOCK(&mtVisSubThreadMutex);
@@ -1863,7 +1856,7 @@ G4ThreadFunReturnType G4VisManager::G4VisSubThread(G4ThreadFunArgType p)
event->PostProcessingFinished();
eventQueueSize = mtVisEventQueue.size();
G4MUTEXUNLOCK(&mtVisSubThreadMutex);
// G4cout << "Event queue size (B): " << eventQueueSize << G4endl;
// G4cout << "Event queue size (B): " << eventQueueSize << G4endl;
}
G4MUTEXLOCK(&mtVisSubThreadMutex);
@@ -1876,18 +1869,14 @@ G4ThreadFunReturnType G4VisManager::G4VisSubThread(G4ThreadFunArgType p)
}
// Run still in progress but nothing to draw, so wait a while.
#ifdef G4VIS_USE_STD11
std::this_thread::sleep_for(std::chrono::milliseconds(100));
#else
G4THREADSLEEP(1);
#endif
}
// Inform viewer that we have finished all sub-thread drawing
pViewer->DoneWithVisSubThread();
pViewer->MovingToMasterThread();
// G4cout << "G4VisManager::G4VisSubThread: Vis sub-thread: ending" << G4endl;
return /*(G4ThreadFunReturnType)*/0;
// G4cout << "G4VisManager::G4VisSubThread: Vis sub-thread: ending" << G4endl;
return nullptr;
}
namespace {
@@ -1906,22 +1895,16 @@ void G4VisManager::BeginOfRun ()
#ifdef G4MULTITHREADED
if (G4Threading::IsWorkerThread()) return;
#endif
// G4cout << "G4VisManager::BeginOfRun: thread: "
// << G4Threading::G4GetThreadId() << G4endl;
// G4cout << "G4VisManager::BeginOfRun: thread: "
// << G4Threading::G4GetThreadId() << G4endl;
G4RunManager* runManager = G4RunManager::GetRunManager();
#ifdef G4MULTITHREADED
if (G4Threading::IsMultithreadedApplication()) {
runManager = G4MTRunManager::GetMasterRunManager();
}
#endif
G4RunManager* runManager = G4RunManagerFactory::GetMasterRunManager();
// For a fake run...
G4int nEventsToBeProcessed = runManager->GetNumberOfEventsToBeProcessed();
if (nEventsToBeProcessed == 0) return;
fNKeepRequests = 0;
fKeptLastEvent = false;
fEventKeepingSuspended = false;
fTransientsDrawnThisRun = false;
if (fpSceneHandler) fpSceneHandler->SetTransientsDrawnThisRun(false);
@@ -2001,12 +1984,7 @@ void G4VisManager::EndOfEvent ()
// std::this_thread::sleep_for(std::chrono::seconds(5));
#endif
G4RunManager* runManager = G4RunManager::GetRunManager();
#ifdef G4MULTITHREADED
if (G4Threading::IsMultithreadedApplication()) {
runManager = G4MTRunManager::GetMasterRunManager();
}
#endif
G4RunManager* runManager = G4RunManagerFactory::GetMasterRunManager();
const G4Run* currentRun = runManager->GetCurrentRun();
if (!currentRun) return;
@@ -2058,11 +2036,7 @@ void G4VisManager::EndOfEvent ()
}
// G4cout << "Event queue size (3): " << eventQueueSize << G4endl;
// Wait a while to give event drawing time to reduce the queue...
#ifdef G4VIS_USE_STD11
std::this_thread::sleep_for(std::chrono::milliseconds(100));
#else
G4THREADSLEEP(1);
#endif
// G4cout << "Event queue size (4): " << eventQueueSize << G4endl;
} else {
static G4bool warned = false;
@@ -2091,6 +2065,13 @@ void G4VisManager::EndOfEvent ()
G4MUTEXLOCK(&mtVisSubThreadMutex);
// Keep event for processing and put event on vis event queue
currentEvent->KeepForPostProcessing();
if (fpScene->GetRefreshAtEndOfEvent()) {
// Keep one event (cannot know which is last so any will do)
if (fNKeepRequests == 0) {
eventManager->KeepTheCurrentEvent();
fNKeepRequests++;
}
}
mtVisEventQueue.push_back(currentEvent);
G4MUTEXUNLOCK(&mtVisSubThreadMutex);
}
@@ -2143,7 +2124,6 @@ void G4VisManager::EndOfEvent ()
if (nKeptEvents == 0) {
eventManager->KeepTheCurrentEvent();
fNKeepRequests++;
fKeptLastEvent = true;
}
}
fpSceneHandler->SetMarkForClearingTransientStore(true);
@@ -2199,15 +2179,10 @@ void G4VisManager::EndOfRun ()
if (G4Threading::IsWorkerThread()) return;
#endif
// G4cout << "G4VisManager::EndOfRun: thread: "
// << G4Threading::G4GetThreadId() << G4endl;
// G4cout << "G4VisManager::EndOfRun: thread: "
// << G4Threading::G4GetThreadId() << G4endl;
G4RunManager* runManager = G4RunManager::GetRunManager();
#ifdef G4MULTITHREADED
if (G4Threading::IsMultithreadedApplication()) {
runManager = G4MTRunManager::GetMasterRunManager();
}
#endif
G4RunManager* runManager = G4RunManagerFactory::GetMasterRunManager();
// For a fake run...
G4int nEventsToBeProcessed = runManager->GetNumberOfEventsToBeProcessed();
@@ -2253,28 +2228,36 @@ void G4VisManager::EndOfRun ()
G4int nKeptEvents = 0;
const std::vector<const G4Event*>* events = currentRun->GetEventVector();
if (events) nKeptEvents = events->size();
if (nKeptEvents && !fKeptLastEvent) {
if (fVerbosity >= warnings) {
G4cout << nKeptEvents;
if (nKeptEvents == 1) G4cout << " event has";
else G4cout << " events have";
G4cout << " been kept for refreshing and/or reviewing." << G4endl;
if (nKeptEvents != fNKeepRequests) {
G4cout << " (Note: ";
if (fNKeepRequests == 0) {
G4cout << "No keep requests were";
} else if (fNKeepRequests == 1) {
G4cout << "Only 1 keep request was";
} else {
G4cout << "Only " << fNKeepRequests << " keep requests were";
}
G4cout << " made by the vis manager.)" << G4endl;
if (fVerbosity >= warnings) {
G4cout << nKeptEvents;
if (nKeptEvents == 1) G4cout << " event has";
else G4cout << " events have";
G4cout << " been kept for refreshing and/or reviewing." << G4endl;
if (nKeptEvents != fNKeepRequests) {
G4cout << " (Note: ";
if (fNKeepRequests == 0) {
G4cout << "No keep requests were";
} else if (fNKeepRequests == 1) {
G4cout << "1 keep request was";
} else {
G4cout << fNKeepRequests << " keep requests were";
}
G4cout <<
"\n \"/vis/reviewKeptEvents\" to review them one by one."
"\n \"/vis/enable\", then \"/vis/viewer/flush\" or \"/vis/viewer/rebuild\" to see them accumulated."
<< G4endl;
G4cout << " made by the vis manager.";
if (fNKeepRequests == 0) {
G4cout <<
"\n The kept events are those you have asked to be kept in your user action(s).)";
} else {
G4cout <<
"\n The same or further events may have been kept by you in your user action(s).)";
}
G4cout << G4endl;
}
G4cout <<
" \"/vis/reviewKeptEvents\" to review them one by one."
"\n \"/vis/enable\", then \"/vis/viewer/flush\" or \"/vis/viewer/rebuild\" to see them accumulated."
<< G4endl;
}
// static G4bool warned = false;
// if (!valid && fVerbosity >= warnings && !warned) {
// G4cout <<
@@ -2291,7 +2274,6 @@ void G4VisManager::EndOfRun ()
// << G4endl;
// warned = true;
// }
}
if (fEventKeepingSuspended && fVerbosity >= warnings) {
G4cout <<