Import Geant4 10.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-10 12:08:39 +02:00
parent 286caacf06
commit c9b32a6c0a
5770 changed files with 1050949 additions and 367105 deletions
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4Scene.cc 75567 2013-11-04 11:35:11Z gcosmo $
// $Id: G4Scene.cc 86360 2014-11-10 08:34:16Z gcosmo $
//
//
// Scene data John Allison 19th July 1996.
@@ -147,6 +147,8 @@ void G4Scene::CalculateExtent ()
"visman0202", JustWarning,
"Scene has no extent. Please activate or add something."
"\nThe camera needs to have something to point at!"
"\nAdd a volume. (You may need \"/run/initialize\".)"
"\nOr use \"/vis/scene/add/extent\"."
"\n\"/vis/scene/list\" to see list of models.");
}
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VSceneHandler.cc 73126 2013-08-19 08:01:37Z gcosmo $
// $Id: G4VSceneHandler.cc 87360 2014-12-01 16:07:16Z gcosmo $
//
//
// John Allison 19th July 1996
@@ -78,10 +78,14 @@
#include "Randomize.hh"
#include "G4StateManager.hh"
#include "G4RunManager.hh"
#ifdef G4MULTITHREADED
#include "G4MTRunManager.hh"
#endif
#include "G4Run.hh"
#include "G4Transform3D.hh"
#include "G4AttHolder.hh"
#include "G4AttDef.hh"
#include "G4VVisCommand.hh"
#include "G4PhysicalConstants.hh"
G4VSceneHandler::G4VSceneHandler (G4VGraphicsSystem& system, G4int id, const G4String& name):
@@ -397,9 +401,9 @@ void G4VSceneHandler::AddPrimitive (const G4Scale& scale) {
rotation = G4RotateY3D(piBy2);
break;
}
G4double sxmid(scale.GetXmid());
G4double symid(scale.GetYmid());
G4double szmid(scale.GetZmid());
G4double sxmid;
G4double symid;
G4double szmid;
sxmid = xmin + oneMinusMargin * (xmax - xmin);
symid = ymin + margin * (ymax - ymin);
szmid = zmin + oneMinusMargin * (zmax - zmin);
@@ -430,7 +434,7 @@ void G4VSceneHandler::AddPrimitive (const G4Scale& scale) {
AddPrimitive(tick21.transform(transformation));
AddPrimitive(tick22.transform(transformation));
G4Text text(scale.GetAnnotation(),textPosition.transform(transformation));
text.SetScreenSize(12.);
text.SetScreenSize(scale.GetAnnotationSize());
AddPrimitive(text);
}
@@ -494,7 +498,7 @@ void G4VSceneHandler::RequestPrimitives (const G4VSolid& solid) {
else {
G4VisManager::Verbosity verbosity = G4VisManager::GetVerbosity();
if (verbosity >= G4VisManager::errors) {
G4cout <<
G4cerr <<
"ERROR: G4VSceneHandler::RequestPrimitives"
"\n Polyhedron not available for " << solid.GetName () <<
".\n This means it cannot be visualized on most systems."
@@ -574,6 +578,10 @@ void G4VSceneHandler::ProcessScene () {
} else {
G4RunManager* runManager = G4RunManager::GetRunManager();
#ifdef G4MULTITHREADED
if(G4Threading::IsMultithreadedApplication())
{ runManager = G4MTRunManager::GetMasterRunManager(); }
#endif
if (runManager) {
const G4Run* run = runManager->GetCurrentRun();
const std::vector<const G4Event*>* events =
@@ -672,6 +680,8 @@ void G4VSceneHandler::DrawEndOfRunModels()
G4ModelingParameters* G4VSceneHandler::CreateModelingParameters ()
{
// Create modeling parameters from View Parameters...
if (!fpViewer) return NULL;
const G4ViewParameters& vp = fpViewer -> GetViewParameters ();
// Convert drawing styles...
@@ -789,16 +799,20 @@ void G4VSceneHandler::LoadAtts(const G4Visible& visible, G4AttHolder* holder)
}
// Load G4Atts from trajectory...
const G4VTrajectory* traj = trajModel->GetCurrentTrajectory();
const std::map<G4String,G4AttDef>* trajDefs = traj->GetAttDefs();
if (trajDefs) {
holder->AddAtts(traj->CreateAttValues(), trajDefs);
}
G4int nPoints = traj->GetPointEntries();
for (G4int i = 0; i < nPoints; ++i) {
G4VTrajectoryPoint* trajPoint = traj->GetPoint(i);
const std::map<G4String,G4AttDef>* pointDefs = trajPoint->GetAttDefs();
if (pointDefs) {
holder->AddAtts(trajPoint->CreateAttValues(), pointDefs);
if (traj) {
const std::map<G4String,G4AttDef>* trajDefs = traj->GetAttDefs();
if (trajDefs) {
holder->AddAtts(traj->CreateAttValues(), trajDefs);
}
G4int nPoints = traj->GetPointEntries();
for (G4int i = 0; i < nPoints; ++i) {
G4VTrajectoryPoint* trajPoint = traj->GetPoint(i);
if (trajPoint) {
const std::map<G4String,G4AttDef>* pointDefs = trajPoint->GetAttDefs();
if (pointDefs) {
holder->AddAtts(trajPoint->CreateAttValues(), pointDefs);
}
}
}
}
}
@@ -918,13 +932,12 @@ G4int G4VSceneHandler::GetNoOfSides(const G4VisAttributes* pVisAttribs)
if (pVisAttribs) {
if (pVisAttribs->IsForceLineSegmentsPerCircle())
lineSegmentsPerCircle = pVisAttribs->GetForcedLineSegmentsPerCircle();
const G4int nSegmentsMin = 12;
if (lineSegmentsPerCircle < nSegmentsMin) {
lineSegmentsPerCircle = nSegmentsMin;
if (lineSegmentsPerCircle < pVisAttribs->GetMinLineSegmentsPerCircle()) {
lineSegmentsPerCircle = pVisAttribs->GetMinLineSegmentsPerCircle();
G4cout <<
"G4VSceneHandler::GetNoOfSides: attempt to set the"
"\nnumber of line segements per circle < " << nSegmentsMin
<< "; forced to " << lineSegmentsPerCircle << G4endl;
"\nnumber of line segements per circle < " << lineSegmentsPerCircle
<< "; forced to " << pVisAttribs->GetMinLineSegmentsPerCircle() << G4endl;
}
}
return lineSegmentsPerCircle;
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VVisCommand.cc 66870 2013-01-14 23:38:59Z adotti $
// $Id: G4VVisCommand.cc 85021 2014-10-23 09:53:47Z gcosmo $
// Base class for visualization commands - John Allison 9th August 1998
// It is really a messenger - we have one command per messenger.
@@ -39,7 +39,8 @@
G4Colour G4VVisCommand::fCurrentColour = G4Colour::White();
G4Colour G4VVisCommand::fCurrentTextColour = G4Colour::Blue();
G4Text::Layout G4VVisCommand::fCurrentTextLayout = G4Text::left;
G4double G4VVisCommand::fCurrentLineWidth = 1.;
G4double G4VVisCommand::fCurrentTextSize = 12.; // pixels
G4double G4VVisCommand::fCurrentLineWidth = 1.; // pixels
// Not yet used: G4VisAttributes::LineStyle G4VVisCommand::fCurrentLineStyle = G4VisAttributes::unbroken;
// Not yet used: G4VMarker::FillStyle G4VVisCommand::fCurrentFillStyle = G4VMarker::filled;
// Not yet used: G4VMarker::SizeType G4VVisCommand::fCurrentSizeType = G4VMarker::screen;
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4ViewParameters.cc 71534 2013-06-17 16:07:53Z gcosmo $
// $Id: G4ViewParameters.cc 85021 2014-10-23 09:53:47Z gcosmo $
//
//
// John Allison 19th July 1996
@@ -152,7 +152,7 @@ void G4ViewParameters::AddCutawayPlane (const G4Plane3D& cutawayPlane) {
fCutawayPlanes.push_back (cutawayPlane);
}
else {
G4cout <<
G4cerr <<
"ERROR: G4ViewParameters::AddCutawayPlane:"
"\n A maximum of 3 cutaway planes supported." << G4endl;
}
@@ -161,7 +161,7 @@ void G4ViewParameters::AddCutawayPlane (const G4Plane3D& cutawayPlane) {
void G4ViewParameters::ChangeCutawayPlane
(size_t index, const G4Plane3D& cutawayPlane) {
if (index >= fCutawayPlanes.size()) {
G4cout <<
G4cerr <<
"ERROR: G4ViewParameters::ChangeCutawayPlane:"
"\n Plane " << index << " does not exist." << G4endl;
} else {
@@ -187,7 +187,7 @@ void G4ViewParameters::SetVisibleDensity (G4double visibleDensity) {
}
G4int G4ViewParameters::SetNoOfSides (G4int nSides) {
const G4int nSidesMin = 12;
const G4int nSidesMin = fDefaultVisAttributes.GetMinLineSegmentsPerCircle();
if (nSides < nSidesMin) {
nSides = nSidesMin;
G4cout << "G4ViewParameters::SetNoOfSides: attempt to set the"
@@ -1001,7 +1001,7 @@ int G4ViewParameters::ParseGeometry (
{
G4int mask = fNoValue;
register char *strind;
char *strind;
unsigned int tempWidth = 0;
unsigned int tempHeight = 0;
G4int tempX = 0;
@@ -1087,7 +1087,7 @@ int G4ViewParameters::ParseGeometry (
*/
G4int G4ViewParameters::ReadInteger(char *string, char **NextString)
{
register G4int Result = 0;
G4int Result = 0;
G4int Sign = 1;
if (*string == '+')
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VisCommands.cc 75567 2013-11-04 11:35:11Z gcosmo $
// $Id: G4VisCommands.cc 87360 2014-12-01 16:07:16Z gcosmo $
// /vis/ top level commands - John Allison 5th February 2001
@@ -36,6 +36,9 @@
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithoutParameter.hh"
#include "G4RunManager.hh"
#ifdef G4MULTITHREADED
#include "G4MTRunManager.hh"
#endif
#include "G4Run.hh"
#include "G4UIsession.hh"
#include "G4Trajectory.hh"
@@ -168,18 +171,22 @@ void G4VisCommandList::SetNewValue (G4UIcommand*, G4String newValue)
"\n \"/vis/filtering/trajectories/create/attributeFilter\" commands"
"\nand by picking:"
<< G4endl;
G4cout << G4TrajectoriesModel().GetAttDefs();
G4cout << G4RichTrajectory().GetAttDefs()
<< G4RichTrajectoryPoint().GetAttDefs();
G4cout << G4SmoothTrajectory().GetAttDefs()
<< G4SmoothTrajectoryPoint().GetAttDefs();
G4cout << G4Trajectory().GetAttDefs()
<< G4TrajectoryPoint().GetAttDefs();
G4cout
<< *G4TrajectoriesModel().GetAttDefs();
G4cout
<< *G4RichTrajectory().GetAttDefs()
<< *G4RichTrajectoryPoint().GetAttDefs();
G4cout
<< *G4SmoothTrajectory().GetAttDefs()
<< *G4SmoothTrajectoryPoint().GetAttDefs();
G4cout
<< *G4Trajectory().GetAttDefs()
<< *G4TrajectoryPoint().GetAttDefs();
G4cout <<
"\nAttributes available for touchables by picking:"
<< G4endl;
G4cout << G4PhysicalVolumeModel().GetAttDefs();
"\nGeometry attributes available for touchables by picking:\n";
G4cout
<< *G4PhysicalVolumeModel().GetAttDefs();
if (verbosity < G4VisManager::parameters)
G4cout <<
@@ -241,13 +248,17 @@ void G4VisCommandReviewKeptEvents::SetNewValue (G4UIcommand*, G4String 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;
if (!nKeptEvents) {
if (verbosity >= G4VisManager::errors) {
G4cout <<
G4cerr <<
"ERROR: G4VisCommandReviewKeptEvents::SetNewValue: No kept events,"
"\n or kept events not accessible."
<< G4endl;
@@ -258,7 +269,7 @@ void G4VisCommandReviewKeptEvents::SetNewValue (G4UIcommand*, G4String newValue)
G4VViewer* viewer = fpVisManager->GetCurrentViewer();
if (!viewer) {
if (verbosity >= G4VisManager::errors) {
G4cout <<
G4cerr <<
"ERROR: No current viewer - \"/vis/viewer/list\" to see possibilities."
<< G4endl;
}
@@ -268,7 +279,7 @@ void G4VisCommandReviewKeptEvents::SetNewValue (G4UIcommand*, G4String newValue)
G4Scene* pScene = fpVisManager->GetCurrentScene();
if (!pScene) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: No current scene. Please create one." << G4endl;
G4cerr << "ERROR: No current scene. Please create one." << G4endl;
}
return;
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VisCommandsCompound.cc 66870 2013-01-14 23:38:59Z adotti $
// $Id: G4VisCommandsCompound.cc 82050 2014-06-10 08:24:52Z gcosmo $
// Compound /vis/ commands - John Allison 15th May 2000
@@ -313,6 +313,10 @@ G4VisCommandSpecify::G4VisCommandSpecify() {
parameter = new G4UIparameter("readout-flag", 'b', omitable = true);
parameter->SetDefaultValue(true);
fpCommand->SetParameter(parameter);
parameter = new G4UIparameter("axes-flag", 'b', omitable = true);
parameter->SetDefaultValue(true);
parameter -> SetGuidance ("Set \"false\" to suppress axes.");
fpCommand->SetParameter(parameter);
}
G4VisCommandSpecify::~G4VisCommandSpecify() {
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VisCommandsGeometry.cc 66870 2013-01-14 23:38:59Z adotti $
// $Id: G4VisCommandsGeometry.cc 82799 2014-07-10 13:18:29Z gcosmo $
// /vis/geometry commands - John Allison 31st January 2006
@@ -83,7 +83,7 @@ void G4VisCommandGeometryList::SetNewValue(G4UIcommand*, G4String newValue)
}
if (newValue != "all" && !found) {
if (fpVisManager->GetVerbosity() >= G4VisManager::errors) {
G4cout << "ERROR: Logical volume \"" << newValue
G4cerr << "ERROR: Logical volume \"" << newValue
<< "\" not found in logical volume store." << G4endl;
}
return;
@@ -140,7 +140,7 @@ void G4VisCommandGeometryRestore::SetNewValue(G4UIcommand*, G4String newValue)
}
if (newValue != "all" && !found) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: Logical volume \"" << newValue
G4cerr << "ERROR: Logical volume \"" << newValue
<< "\" not found in logical volume store." << G4endl;
}
return;
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VisCommandsGeometrySet.cc 66870 2013-01-14 23:38:59Z adotti $
// $Id: G4VisCommandsGeometrySet.cc 86865 2014-11-19 14:41:25Z gcosmo $
// /vis/geometry commands - John Allison 31st January 2006
@@ -56,7 +56,7 @@ void G4VVisCommandGeometrySet::Set
}
if (requestedName != "all" && !found) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: Logical volume \"" << requestedName
G4cerr << "ERROR: Logical volume \"" << requestedName
<< "\" not found in logical volume store." << G4endl;
}
return;
@@ -83,15 +83,20 @@ void G4VVisCommandGeometrySet::SetLVVisAtts
pLV->SetVisAttributes(newVisAtts);
if (verbosity >= G4VisManager::confirmations) {
G4cout << "\nLogical Volume \"" << pLV->GetName()
<< "\": setting vis attributes:\nwas: " << *oldVisAtts
<< "\nnow: " << *newVisAtts
<< "\": setting vis attributes:";
if (oldVisAtts) {
G4cout << "\nwas: " << *oldVisAtts;
} else {
G4cout << "\n(no old attributes)";
}
G4cout << "\nnow: " << *newVisAtts
<< G4endl;
}
if (requestedDepth < 0 || depth++ < requestedDepth) {
if (requestedDepth < 0 || depth < requestedDepth) {
G4int nDaughters = pLV->GetNoDaughters();
for (G4int i = 0; i < nDaughters; ++i) {
SetLVVisAtts(pLV->GetDaughter(i)->GetLogicalVolume(),
setFunction, depth, requestedDepth);
setFunction, ++depth, requestedDepth);
}
}
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VisCommandsScene.cc 75567 2013-11-04 11:35:11Z gcosmo $
// $Id: G4VisCommandsScene.cc 87360 2014-12-01 16:07:16Z gcosmo $
// /vis/scene commands - John Allison 9th August 1998
@@ -33,6 +33,9 @@
#include "G4VisManager.hh"
#include "G4TransportationManager.hh"
#include "G4RunManager.hh"
#ifdef G4MULTITHREADED
#include "G4MTRunManager.hh"
#endif
#include "G4Run.hh"
#include "G4PhysicalVolumeModel.hh"
#include "G4ApplicationState.hh"
@@ -96,7 +99,7 @@ void G4VisCommandSceneActivateModel::SetNewValue (G4UIcommand*,
G4Scene* pScene = fpVisManager->GetCurrentScene();
if (!pScene) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: No current scene. Please create one." << G4endl;
G4cerr << "ERROR: No current scene. Please create one." << G4endl;
}
return;
}
@@ -104,7 +107,7 @@ void G4VisCommandSceneActivateModel::SetNewValue (G4UIcommand*,
G4VSceneHandler* pSceneHandler = fpVisManager->GetCurrentSceneHandler();
if (!pSceneHandler) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: No current sceneHandler. Please create one." << G4endl;
G4cerr << "ERROR: No current sceneHandler. Please create one." << G4endl;
}
return;
}
@@ -293,7 +296,7 @@ void G4VisCommandSceneEndOfEventAction::SetNewValue (G4UIcommand*,
G4Scene* pScene = fpVisManager->GetCurrentScene();
if (!pScene) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: No current scene. Please create one." << G4endl;
G4cerr << "ERROR: No current scene. Please create one." << G4endl;
}
return;
}
@@ -301,7 +304,7 @@ void G4VisCommandSceneEndOfEventAction::SetNewValue (G4UIcommand*,
G4VSceneHandler* pSceneHandler = fpVisManager->GetCurrentSceneHandler();
if (!pSceneHandler) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: No current sceneHandler. Please create one." << G4endl;
G4cerr << "ERROR: No current sceneHandler. Please create one." << G4endl;
}
return;
}
@@ -313,7 +316,7 @@ void G4VisCommandSceneEndOfEventAction::SetNewValue (G4UIcommand*,
else if (action == "refresh") {
if (!pScene->GetRefreshAtEndOfRun()) {
if (verbosity >= G4VisManager::errors) {
G4cout <<
G4cerr <<
"ERROR: Cannot refresh events unless runs refresh too."
"\n Use \"/vis/scene/endOfRun refresh\"."
<< G4endl;
@@ -326,7 +329,7 @@ void G4VisCommandSceneEndOfEventAction::SetNewValue (G4UIcommand*,
}
else {
if (verbosity >= G4VisManager::errors) {
G4cout <<
G4cerr <<
"ERROR: unrecognised parameter \"" << action << "\"."
<< G4endl;
}
@@ -339,6 +342,10 @@ void G4VisCommandSceneEndOfEventAction::SetNewValue (G4UIcommand*,
// 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) {
const G4Run* currentRun = runManager->GetCurrentRun();
if (currentRun) {
@@ -424,7 +431,7 @@ void G4VisCommandSceneEndOfRunAction::SetNewValue (G4UIcommand*,
G4Scene* pScene = fpVisManager->GetCurrentScene();
if (!pScene) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: No current scene. Please create one." << G4endl;
G4cerr << "ERROR: No current scene. Please create one." << G4endl;
}
return;
}
@@ -432,7 +439,7 @@ void G4VisCommandSceneEndOfRunAction::SetNewValue (G4UIcommand*,
G4VSceneHandler* pSceneHandler = fpVisManager->GetCurrentSceneHandler();
if (!pSceneHandler) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: No current sceneHandler. Please create one." << G4endl;
G4cerr << "ERROR: No current sceneHandler. Please create one." << G4endl;
}
return;
}
@@ -440,7 +447,7 @@ void G4VisCommandSceneEndOfRunAction::SetNewValue (G4UIcommand*,
if (action == "accumulate") {
if (pScene->GetRefreshAtEndOfEvent()) {
if (verbosity >= G4VisManager::errors) {
G4cout <<
G4cerr <<
"ERROR: Cannot accumulate runs unless events accumulate too."
"\n Use \"/vis/scene/endOfEventAction accumulate\"."
<< G4endl;
@@ -456,7 +463,7 @@ void G4VisCommandSceneEndOfRunAction::SetNewValue (G4UIcommand*,
}
else {
if (verbosity >= G4VisManager::errors) {
G4cout <<
G4cerr <<
"ERROR: unrecognised parameter \"" << action << "\"."
<< G4endl;
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VisCommandsSceneAdd.cc 77479 2013-11-25 10:01:22Z gcosmo $
// $Id: G4VisCommandsSceneAdd.cc 87360 2014-12-01 16:07:16Z gcosmo $
// /vis/scene/add commands - John Allison 9th August 1998
#include "G4VisCommandsSceneAdd.hh"
@@ -59,6 +59,9 @@
#include "G4UIcmdWithAnInteger.hh"
#include "G4Tokenizer.hh"
#include "G4RunManager.hh"
#ifdef G4MULTITHREADED
#include "G4MTRunManager.hh"
#endif
#include "G4StateManager.hh"
#include "G4Run.hh"
#include "G4Event.hh"
@@ -69,6 +72,7 @@
#include "G4SmoothTrajectory.hh"
#include "G4SmoothTrajectoryPoint.hh"
#include "G4AttDef.hh"
#include "G4AttCheck.hh"
#include "G4Polyline.hh"
#include "G4UnitsTable.hh"
#include "G4PhysicalConstants.hh"
@@ -127,7 +131,7 @@ void G4VisCommandSceneAddArrow::SetNewValue (G4UIcommand*, G4String newValue)
G4Scene* pScene = fpVisManager->GetCurrentScene();
if (!pScene) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: No current scene. Please create one." << G4endl;
G4cerr << "ERROR: No current scene. Please create one." << G4endl;
}
return;
}
@@ -195,7 +199,7 @@ void G4VisCommandSceneAddArrow2D::SetNewValue (G4UIcommand*, G4String newValue)
G4Scene* pScene = fpVisManager->GetCurrentScene();
if (!pScene) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: No current scene. Please create one." << G4endl;
G4cerr << "ERROR: No current scene. Please create one." << G4endl;
}
return;
}
@@ -271,6 +275,8 @@ G4VisCommandSceneAddAxes::G4VisCommandSceneAddAxes () {
"\n use \"/vis/list\".");
fpCommand -> SetGuidance
("If \"length\" is negative, it is set to about 25% of scene extent.");
fpCommand -> SetGuidance
("If \"showtext\" is false, annotations are suppressed.");
G4UIparameter* parameter;
parameter = new G4UIparameter ("x0", 'd', omitable = true);
parameter->SetDefaultValue (0.);
@@ -290,6 +296,9 @@ G4VisCommandSceneAddAxes::G4VisCommandSceneAddAxes () {
parameter = new G4UIparameter ("unitcolour", 's', omitable = true);
parameter->SetDefaultValue ("auto");
fpCommand->SetParameter (parameter);
parameter = new G4UIparameter ("showtext", 'b', omitable = true);
parameter->SetDefaultValue ("true");
fpCommand->SetParameter (parameter);
}
G4VisCommandSceneAddAxes::~G4VisCommandSceneAddAxes () {
@@ -308,27 +317,40 @@ void G4VisCommandSceneAddAxes::SetNewValue (G4UIcommand*, G4String newValue) {
G4Scene* pScene = fpVisManager->GetCurrentScene();
if (!pScene) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: No current scene. Please create one." << G4endl;
G4cerr << "ERROR: No current scene. Please create one." << G4endl;
}
return;
} else {
if (pScene->GetExtent().GetExtentRadius() <= 0.) {
if (verbosity >= G4VisManager::errors) {
G4cerr
<< "ERROR: Scene has no extent. Add volumes or use \"/vis/scene/add/extent\"."
<< G4endl;
}
return;
}
}
G4String unitString, colourString;
G4String unitString, colourString, showTextString;
G4double x0, y0, z0, length;
std::istringstream is (newValue);
is >> x0 >> y0 >> z0 >> length >> unitString >> colourString;
is >> x0 >> y0 >> z0 >> length >> unitString
>> colourString >> showTextString;
G4bool showText = G4UIcommand::ConvertToBool(showTextString);
G4double unit = G4UIcommand::ValueOf(unitString);
x0 *= unit; y0 *= unit; z0 *= unit;
const G4VisExtent& sceneExtent = pScene->GetExtent(); // Existing extent.
if (length < 0.) {
length = 0.5 * sceneExtent.GetExtentRadius();
G4double intLog10Length = std::floor(std::log10(length));
const G4double lengthMax = 0.5 * sceneExtent.GetExtentRadius();
const G4double intLog10Length = std::floor(std::log10(lengthMax));
length = std::pow(10,intLog10Length);
if (5.*length < lengthMax) length *= 5.;
else if (2.*length < lengthMax) length *= 2.;
} else {
length *= unit;
}
G4String annotation = G4BestUnit(length,"Length");
// Consult scene for arrow width...
G4double arrowWidth =
@@ -337,14 +359,16 @@ void G4VisCommandSceneAddAxes::SetNewValue (G4UIcommand*, G4String newValue) {
if (arrowWidth > length/50.) arrowWidth = length/50.;
G4VModel* model = new G4AxesModel
(x0, y0, z0, length, arrowWidth, colourString, newValue);
(x0, y0, z0, length, arrowWidth, colourString, newValue,
showText, fCurrentTextSize);
G4bool successful = pScene -> AddRunDurationModel (model, warn);
const G4String& currentSceneName = pScene -> GetName ();
if (successful) {
if (verbosity >= G4VisManager::confirmations) {
G4cout << "Axes have been added to scene \"" << currentSceneName << "\"."
<< G4endl;
G4cout << "Axes of length " << G4BestUnit(length,"Length")
<< "have been added to scene \"" << currentSceneName << "\"."
<< G4endl;
}
}
else G4VisCommandsSceneAddUnsuccessful(verbosity);
@@ -398,7 +422,7 @@ void G4VisCommandSceneAddDate::SetNewValue (G4UIcommand*, G4String newValue)
G4Scene* pScene = fpVisManager->GetCurrentScene();
if (!pScene) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: No current scene. Please create one." << G4endl;
G4cerr << "ERROR: No current scene. Please create one." << G4endl;
}
return;
}
@@ -411,6 +435,7 @@ void G4VisCommandSceneAddDate::SetNewValue (G4UIcommand*, G4String newValue)
// Read rest of line, if any.
const size_t NREMAINDER = 100;
char remainder[NREMAINDER];
remainder[0]='\0'; // In case there is nothing remaining.
is.getline(remainder, NREMAINDER);
dateString += remainder;
G4Text::Layout layout = G4Text::right;
@@ -485,7 +510,7 @@ void G4VisCommandSceneAddDigis::SetNewValue (G4UIcommand*, G4String) {
G4Scene* pScene = fpVisManager->GetCurrentScene();
if (!pScene) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: No current scene. Please create one." << G4endl;
G4cerr << "ERROR: No current scene. Please create one." << G4endl;
}
return;
}
@@ -548,7 +573,7 @@ void G4VisCommandSceneAddEventID::SetNewValue (G4UIcommand*, G4String newValue)
G4Scene* pScene = fpVisManager->GetCurrentScene();
if (!pScene) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: No current scene. Please create one." << G4endl;
G4cerr << "ERROR: No current scene. Please create one." << G4endl;
}
return;
}
@@ -588,6 +613,11 @@ void G4VisCommandSceneAddEventID::EventID::operator()
{
const G4Run* currentRun = 0;
G4RunManager* runManager = G4RunManager::GetRunManager();
#ifdef G4MULTITHREADED
if (G4Threading::IsMultithreadedApplication()) {
runManager = G4MTRunManager::GetMasterRunManager();
}
#endif
if (runManager) currentRun = runManager->GetCurrentRun();
G4VModel* model = fpVisManager->GetCurrentSceneHandler()->GetModel();
@@ -599,7 +629,7 @@ void G4VisCommandSceneAddEventID::EventID::operator()
} else {
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: No model defined for this SceneHandler : "
G4cerr << "ERROR: No model defined for this SceneHandler : "
<< fpVisManager->GetCurrentSceneHandler()->GetName()
<< G4endl;
}
@@ -639,6 +669,104 @@ void G4VisCommandSceneAddEventID::EventID::operator()
}
}
////////////// /vis/scene/add/extent ///////////////////////////////////////
G4VisCommandSceneAddExtent::G4VisCommandSceneAddExtent () {
fpCommand = new G4UIcommand("/vis/scene/add/extent", this);
fpCommand -> SetGuidance
("Adds a dummy model with given extent to the current scene."
"\nThis can be used to provide an extent to the scene even if"
"\nno other models with extent are available. For example,"
"\neven if there is no geometry.");
G4bool omitable;
G4UIparameter* parameter;
parameter = new G4UIparameter ("xmin", 'd', omitable = true);
parameter -> SetDefaultValue (0.);
fpCommand -> SetParameter (parameter);
parameter = new G4UIparameter ("xmax", 'd', omitable = true);
parameter -> SetDefaultValue (0.);
fpCommand -> SetParameter (parameter);
parameter = new G4UIparameter ("ymin", 'd', omitable = true);
parameter -> SetDefaultValue (0.);
fpCommand -> SetParameter (parameter);
parameter = new G4UIparameter ("ymax", 'd', omitable = true);
parameter -> SetDefaultValue (0.);
fpCommand -> SetParameter (parameter);
parameter = new G4UIparameter ("zmin", 'd', omitable = true);
parameter -> SetDefaultValue (0.);
fpCommand -> SetParameter (parameter);
parameter = new G4UIparameter ("zmax", 'd', omitable = true);
parameter -> SetDefaultValue (0.);
fpCommand -> SetParameter (parameter);
parameter = new G4UIparameter ("unit", 's', omitable = true);
parameter -> SetDefaultValue ("m");
fpCommand -> SetParameter (parameter);
}
G4VisCommandSceneAddExtent::~G4VisCommandSceneAddExtent () {
delete fpCommand;
}
G4String G4VisCommandSceneAddExtent::GetCurrentValue (G4UIcommand*) {
return "";
}
void G4VisCommandSceneAddExtent::SetNewValue (G4UIcommand*, G4String newValue)
{
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
G4bool warn(verbosity >= G4VisManager::warnings);
G4Scene* pScene = fpVisManager->GetCurrentScene();
if (!pScene) {
if (verbosity >= G4VisManager::errors) {
G4cerr << "ERROR: No current scene. Please create one." << G4endl;
}
return;
}
G4double xmin, xmax, ymin, ymax, zmin, zmax;
G4String unitString;
std::istringstream is(newValue);
is >> xmin >> xmax >> ymin >> ymax >> zmin >> zmax >> unitString;
G4double unit = G4UIcommand::ValueOf(unitString);
xmin *= unit; xmax *= unit;
ymin *= unit; ymax *= unit;
zmin *= unit; zmax *= unit;
G4VisExtent visExtent(xmin, xmax, ymin, ymax, zmin, zmax);
Extent* extent = new Extent(xmin, xmax, ymin, ymax, zmin, zmax);
G4VModel* model =
new G4CallbackModel<G4VisCommandSceneAddExtent::Extent>(extent);
model->SetType("Extent");
model->SetGlobalTag("Extent");
model->SetGlobalDescription("Extent: " + newValue);
model->SetExtent(visExtent);
const G4String& currentSceneName = pScene -> GetName ();
G4bool successful = pScene -> AddRunDurationModel (model, warn);
if (successful) {
if (verbosity >= G4VisManager::confirmations) {
G4cout << "A benign model with extent "
<< visExtent
<< " has been added to scene \""
<< currentSceneName << "\"."
<< G4endl;
}
}
else G4VisCommandsSceneAddUnsuccessful(verbosity);
UpdateVisManagerScene (currentSceneName);
}
G4VisCommandSceneAddExtent::Extent::Extent
(G4double xmin, G4double xmax,
G4double ymin, G4double ymax,
G4double zmin, G4double zmax):
fExtent(xmin,xmax,ymin,ymax,zmin,zmax)
{}
void G4VisCommandSceneAddExtent::Extent::operator()
(G4VGraphicsScene&, const G4Transform3D&)
{}
////////////// /vis/scene/add/frame ///////////////////////////////////////
G4VisCommandSceneAddFrame::G4VisCommandSceneAddFrame () {
@@ -669,7 +797,7 @@ void G4VisCommandSceneAddFrame::SetNewValue (G4UIcommand*, G4String newValue)
G4Scene* pScene = fpVisManager->GetCurrentScene();
if (!pScene) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: No current scene. Please create one." << G4endl;
G4cerr << "ERROR: No current scene. Please create one." << G4endl;
}
return;
}
@@ -741,7 +869,7 @@ void G4VisCommandSceneAddHits::SetNewValue (G4UIcommand*, G4String) {
G4Scene* pScene = fpVisManager->GetCurrentScene();
if (!pScene) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: No current scene. Please create one." << G4endl;
G4cerr << "ERROR: No current scene. Please create one." << G4endl;
}
return;
}
@@ -800,7 +928,7 @@ void G4VisCommandSceneAddLine::SetNewValue (G4UIcommand*, G4String newValue)
G4Scene* pScene = fpVisManager->GetCurrentScene();
if (!pScene) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: No current scene. Please create one." << G4endl;
G4cerr << "ERROR: No current scene. Please create one." << G4endl;
}
return;
}
@@ -888,7 +1016,7 @@ void G4VisCommandSceneAddLine2D::SetNewValue (G4UIcommand*, G4String newValue)
G4Scene* pScene = fpVisManager->GetCurrentScene();
if (!pScene) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: No current scene. Please create one." << G4endl;
G4cerr << "ERROR: No current scene. Please create one." << G4endl;
}
return;
}
@@ -948,7 +1076,7 @@ G4VisCommandSceneAddLogicalVolume::G4VisCommandSceneAddLogicalVolume () {
fpCommand -> SetGuidance
("Shows boolean components (if any), voxels (if any) and readout geometry"
"\n(if any). Note: voxels are not constructed until start of run -"
"\n \"/run/beamOn\".");
"\n \"/run/beamOn\". (For voxels without a run, \"/run/beamOn 0\".)");
G4UIparameter* parameter;
parameter = new G4UIparameter ("logical-volume-name", 's', omitable = false);
fpCommand -> SetParameter (parameter);
@@ -965,6 +1093,10 @@ G4VisCommandSceneAddLogicalVolume::G4VisCommandSceneAddLogicalVolume () {
parameter = new G4UIparameter ("readout-flag", 'b', omitable = true);
parameter -> SetDefaultValue (true);
fpCommand -> SetParameter (parameter);
parameter = new G4UIparameter ("axes-flag", 'b', omitable = true);
parameter -> SetDefaultValue (true);
parameter -> SetGuidance ("Set \"false\" to suppress axes.");
fpCommand -> SetParameter (parameter);
}
G4VisCommandSceneAddLogicalVolume::~G4VisCommandSceneAddLogicalVolume () {
@@ -984,20 +1116,21 @@ void G4VisCommandSceneAddLogicalVolume::SetNewValue (G4UIcommand*,
G4Scene* pScene = fpVisManager->GetCurrentScene();
if (!pScene) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: No current scene. Please create one." << G4endl;
G4cerr << "ERROR: No current scene. Please create one." << G4endl;
}
return;
}
G4String name;
G4int requestedDepthOfDescent;
G4String booleansString, voxelsString, readoutString;
G4String booleansString, voxelsString, readoutString, axesString;
std::istringstream is (newValue);
is >> name >> requestedDepthOfDescent
>> booleansString >> voxelsString >> readoutString;
>> booleansString >> voxelsString >> readoutString >> axesString;
G4bool booleans = G4UIcommand::ConvertToBool(booleansString);
G4bool voxels = G4UIcommand::ConvertToBool(voxelsString);
G4bool readout = G4UIcommand::ConvertToBool(readoutString);
G4bool axes = G4UIcommand::ConvertToBool(axesString);
G4LogicalVolumeStore *pLVStore = G4LogicalVolumeStore::GetInstance();
int nLV = pLVStore -> size ();
@@ -1009,13 +1142,14 @@ void G4VisCommandSceneAddLogicalVolume::SetNewValue (G4UIcommand*,
}
if (iLV == nLV) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: Logical volume " << name
G4cerr << "ERROR: Logical volume " << name
<< " not found in logical volume store." << G4endl;
}
return;
}
const std::vector<G4Scene::Model>& rdModelList = pScene -> GetRunDurationModelList();
const std::vector<G4Scene::Model>& rdModelList =
pScene -> GetRunDurationModelList();
std::vector<G4Scene::Model>::const_iterator i;
for (i = rdModelList.begin(); i != rdModelList.end(); ++i) {
if (i->fpModel->GetGlobalDescription().find("Volume") != std::string::npos) break;
@@ -1036,13 +1170,36 @@ void G4VisCommandSceneAddLogicalVolume::SetNewValue (G4UIcommand*,
<< "\n (and also, if necessary, /vis/viewer/flush)"
<< G4endl;
}
return;
}
G4VModel* model = new G4LogicalVolumeModel
G4LogicalVolumeModel* model = new G4LogicalVolumeModel
(pLV, requestedDepthOfDescent, booleans, voxels, readout);
const G4String& currentSceneName = pScene -> GetName ();
G4bool successful = pScene -> AddRunDurationModel (model, warn);
if (successful) {
G4bool axesSuccessful = false;
if (axes) {
const G4double radius = model->GetExtent().GetExtentRadius();
const G4double axisLengthMax = radius / 2.;
const G4double intLog10Length = std::floor(std::log10(axisLengthMax));
G4double axisLength = std::pow(10,intLog10Length);
if (5.*axisLength < axisLengthMax) axisLength *= 5.;
else if (2.*axisLength < axisLengthMax) axisLength *= 2.;
const G4double axisWidth = axisLength / 20.;
G4VModel* axesModel = new G4AxesModel(0.,0.,0.,axisLength,axisWidth);
axesSuccessful = pScene -> AddRunDurationModel (axesModel, warn);
}
// if (verbosity >= G4VisManager::warnings) {
// const std::map<G4String,G4AttDef>* attDefs = model->GetAttDefs();
// std::vector<G4AttValue>* attValues = model->CreateCurrentAttValues();
// G4cout << G4AttCheck(attValues, attDefs);
// delete attValues;
// }
if (verbosity >= G4VisManager::confirmations) {
G4cout << "Logical volume \"" << pLV -> GetName ()
<< " with requested depth of descent "
@@ -1054,8 +1211,17 @@ void G4VisCommandSceneAddLogicalVolume::SetNewValue (G4UIcommand*,
G4cout << " voxels and with";
if (!readout) G4cout << "out";
G4cout << " readout geometry,"
<< "\n has been added to scene \"" << currentSceneName << "\"."
<< G4endl;
<< "\n has been added to scene \"" << currentSceneName << "\".";
if (axes) {
if (axesSuccessful) {
G4cout <<
"\n Axes have also been added at the origin of local cooordinates.";
} else {
G4cout <<
"\n Axes have not been added for some reason possibly stated above.";
}
}
G4cout << G4endl;
}
}
else {
@@ -1135,15 +1301,24 @@ void G4VisCommandSceneAddLogo::SetNewValue (G4UIcommand*, G4String newValue) {
G4Scene* pScene = fpVisManager->GetCurrentScene();
if (!pScene) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: No current scene. Please create one." << G4endl;
G4cerr << "ERROR: No current scene. Please create one." << G4endl;
}
return;
} else {
if (pScene->GetExtent().GetExtentRadius() <= 0.) {
if (verbosity >= G4VisManager::errors) {
G4cerr
<< "ERROR: Scene has no extent. Add volumes or use \"/vis/scene/add/extent\"."
<< G4endl;
}
return;
}
}
G4VViewer* pViewer = fpVisManager->GetCurrentViewer();
if (!pViewer) {
if (verbosity >= G4VisManager::errors) {
G4cout <<
G4cerr <<
"ERROR: G4VisCommandSceneAddLogo::SetNewValue: no viewer."
"\n Auto direction needs a viewer."
<< G4endl;
@@ -1191,7 +1366,7 @@ void G4VisCommandSceneAddLogo::SetNewValue (G4UIcommand*, G4String newValue) {
else if (direction(1) == 'z') logoDirection = minusZ;
} else {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: Unrecogniseed direction: \""
G4cerr << "ERROR: Unrecogniseed direction: \""
<< direction << "\"." << G4endl;
return;
}
@@ -1477,7 +1652,7 @@ void G4VisCommandSceneAddLogo2D::SetNewValue (G4UIcommand*, G4String newValue)
G4Scene* pScene = fpVisManager->GetCurrentScene();
if (!pScene) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: No current scene. Please create one." << G4endl;
G4cerr << "ERROR: No current scene. Please create one." << G4endl;
}
return;
}
@@ -1543,7 +1718,7 @@ G4VisCommandSceneAddMagneticField::G4VisCommandSceneAddMagneticField () {
"\nor, if only a small part of the scene has a field:"
"\n /vis/scene/add/magneticField 50 # or more");
fpCommand -> SetGuidance
("In the arrow representation, the length of the arrow is proporational"
("In the arrow representation, the length of the arrow is proportional"
"\nto the magnitude of the field and the colour is mapped onto the range"
"\nas a fraction of the maximum magnitude: 0->0.5->1 is blue->green->red.");
}
@@ -1565,7 +1740,7 @@ void G4VisCommandSceneAddMagneticField::SetNewValue
G4Scene* pScene = fpVisManager->GetCurrentScene();
if (!pScene) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: No current scene. Please create one." << G4endl;
G4cerr << "ERROR: No current scene. Please create one." << G4endl;
}
return;
}
@@ -1623,7 +1798,7 @@ void G4VisCommandSceneAddPSHits::SetNewValue
G4Scene* pScene = fpVisManager->GetCurrentScene();
if (!pScene) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: No current scene. Please create one." << G4endl;
G4cerr << "ERROR: No current scene. Please create one." << G4endl;
}
return;
}
@@ -1716,9 +1891,18 @@ void G4VisCommandSceneAddScale::SetNewValue (G4UIcommand*, G4String newValue) {
G4Scene* pScene = fpVisManager->GetCurrentScene();
if (!pScene) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: No current scene. Please create one." << G4endl;
G4cerr << "ERROR: No current scene. Please create one." << G4endl;
}
return;
} else {
if (pScene->GetExtent().GetExtentRadius() <= 0.) {
if (verbosity >= G4VisManager::errors) {
G4cerr
<< "ERROR: Scene has no extent. Add volumes or use \"/vis/scene/add/extent\"."
<< G4endl;
}
return;
}
}
G4double userLength, red, green, blue, xmid, ymid, zmid;
@@ -1732,9 +1916,11 @@ void G4VisCommandSceneAddScale::SetNewValue (G4UIcommand*, G4String newValue) {
G4double length = userLength;
const G4VisExtent& sceneExtent = pScene->GetExtent(); // Existing extent.
if (userLengthUnit == "auto") {
length *= sceneExtent.GetExtentRadius();
G4double intLog10Length = std::floor(std::log10(length));
const G4double lengthMax = 0.5 * sceneExtent.GetExtentRadius();
const G4double intLog10Length = std::floor(std::log10(lengthMax));
length = std::pow(10,intLog10Length);
if (5.*length < lengthMax) length *= 5.;
else if (2.*length < lengthMax) length *= 2.;
} else {
length *= G4UIcommand::ValueOf(userLengthUnit);
}
@@ -1750,7 +1936,7 @@ void G4VisCommandSceneAddScale::SetNewValue (G4UIcommand*, G4String newValue) {
G4VViewer* pViewer = fpVisManager->GetCurrentViewer();
if (!pViewer) {
if (verbosity >= G4VisManager::errors) {
G4cout <<
G4cerr <<
"ERROR: G4VisCommandSceneAddScale::SetNewValue: no viewer."
"\n Auto direction needs a viewer."
<< G4endl;
@@ -1840,14 +2026,14 @@ void G4VisCommandSceneAddScale::SetNewValue (G4UIcommand*, G4String newValue) {
// Let's go ahead a construct a scale and a scale model. Since the
// placing is done here, this G4Scale is *not* auto-placed...
G4Scale scale(length, annotation, scaleDirection,
false, xmid, ymid, zmid);
G4VisAttributes* pVisAttr = new G4VisAttributes(G4Colour(red, green, blue));
// Created of the heap because it needs a long lifetime. This is a
// mess. The model determines the life but the vis atttributes are
// associated with the scale. There's no way of knowing when to
// delete the vis atttributes!!!
scale.SetVisAttributes(pVisAttr);
false, xmid, ymid, zmid,
fCurrentTextSize);
G4VisAttributes visAttr(G4Colour(red, green, blue));
scale.SetVisAttributes(visAttr);
G4VModel* model = new G4ScaleModel(scale);
G4String globalDescription = model->GetGlobalDescription();
globalDescription += " (" + newValue + ")";
model->SetGlobalDescription(globalDescription);
// Now figure out the extent...
//
@@ -2070,7 +2256,7 @@ void G4VisCommandSceneAddText::SetNewValue (G4UIcommand*, G4String newValue) {
G4Scene* pScene = fpVisManager->GetCurrentScene();
if (!pScene) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: No current scene. Please create one." << G4endl;
G4cerr << "ERROR: No current scene. Please create one." << G4endl;
}
return;
}
@@ -2160,7 +2346,7 @@ void G4VisCommandSceneAddText2D::SetNewValue (G4UIcommand*, G4String newValue) {
G4Scene* pScene = fpVisManager->GetCurrentScene();
if (!pScene) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: No current scene. Please create one." << G4endl;
G4cerr << "ERROR: No current scene. Please create one." << G4endl;
}
return;
}
@@ -2260,7 +2446,7 @@ void G4VisCommandSceneAddTrajectories::SetNewValue (G4UIcommand*,
G4Scene* pScene = fpVisManager->GetCurrentScene();
if (!pScene) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: No current scene. Please create one." << G4endl;
G4cerr << "ERROR: No current scene. Please create one." << G4endl;
}
return;
}
@@ -2271,7 +2457,7 @@ void G4VisCommandSceneAddTrajectories::SetNewValue (G4UIcommand*,
if (newValue.find("rich") != std::string::npos) rich = true;
if (newValue.size() && !(rich || smooth)) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: Unrecognised parameter \"" << newValue << "\""
G4cerr << "ERROR: Unrecognised parameter \"" << newValue << "\""
"\n No action taken."
<< G4endl;
}
@@ -2304,16 +2490,16 @@ void G4VisCommandSceneAddTrajectories::SetNewValue (G4UIcommand*,
"\n \"/vis/modeling/trajectories/create/drawByAttribute\" and"
"\n \"/vis/filtering/trajectories/create/attributeFilter\" commands:"
<< G4endl;
G4cout << G4TrajectoriesModel().GetAttDefs();
G4cout << *G4TrajectoriesModel().GetAttDefs();
if (rich) {
G4cout << G4RichTrajectory().GetAttDefs()
<< G4RichTrajectoryPoint().GetAttDefs();
G4cout << *G4RichTrajectory().GetAttDefs()
<< *G4RichTrajectoryPoint().GetAttDefs();
} else if (smooth) {
G4cout << G4SmoothTrajectory().GetAttDefs()
<< G4SmoothTrajectoryPoint().GetAttDefs();
G4cout << *G4SmoothTrajectory().GetAttDefs()
<< *G4SmoothTrajectoryPoint().GetAttDefs();
} else {
G4cout << G4Trajectory().GetAttDefs()
<< G4TrajectoryPoint().GetAttDefs();
G4cout << *G4Trajectory().GetAttDefs()
<< *G4TrajectoryPoint().GetAttDefs();
}
}
@@ -2370,7 +2556,7 @@ void G4VisCommandSceneAddUserAction::SetNewValue
G4Scene* pScene = fpVisManager->GetCurrentScene();
if (!pScene) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: No current scene. Please create one." << G4endl;
G4cerr << "ERROR: No current scene. Please create one." << G4endl;
}
return;
}
@@ -2468,6 +2654,7 @@ void G4VisCommandSceneAddUserAction::AddVisAction
}
G4cout << G4endl;
}
else G4VisCommandsSceneAddUnsuccessful(verbosity);
}
////////////// /vis/scene/add/volume ///////////////////////////////////////
@@ -2558,7 +2745,7 @@ void G4VisCommandSceneAddVolume::SetNewValue (G4UIcommand*,
G4Scene* pScene = fpVisManager->GetCurrentScene();
if (!pScene) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: No current scene. Please create one." << G4endl;
G4cerr << "ERROR: No current scene. Please create one." << G4endl;
}
return;
}
@@ -2610,7 +2797,7 @@ void G4VisCommandSceneAddVolume::SetNewValue (G4UIcommand*,
if (!world) {
if (verbosity >= G4VisManager::errors) {
G4cout <<
G4cerr <<
"ERROR: G4VisCommandSceneAddVolume::SetNewValue:"
"\n No world. Maybe the geometry has not yet been defined."
"\n Try \"/run/initialize\""
@@ -2714,11 +2901,11 @@ void G4VisCommandSceneAddVolume::SetNewValue (G4UIcommand*,
}
} else {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: Volume \"" << name << "\"";
G4cerr << "ERROR: Volume \"" << name << "\"";
if (copyNo >= 0) {
G4cout << ", copy no. " << copyNo << ",";
G4cerr << ", copy no. " << copyNo << ",";
}
G4cout << " not found." << G4endl;
G4cerr << " not found." << G4endl;
}
return;
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VisCommandsSceneHandler.cc 70646 2013-06-03 15:07:58Z gcosmo $
// $Id: G4VisCommandsSceneHandler.cc 82756 2014-07-08 14:09:34Z gcosmo $
// /vis/sceneHandler commands - John Allison 10th October 1998
@@ -81,7 +81,7 @@ void G4VisCommandSceneHandlerAttach::SetNewValue (G4UIcommand*,
G4VSceneHandler* pSceneHandler = fpVisManager -> GetCurrentSceneHandler ();
if (!pSceneHandler) {
if (verbosity >= G4VisManager::errors) {
G4cout <<
G4cerr <<
"ERROR: Current scene handler not defined. Please select or create one."
<< G4endl;
}
@@ -92,7 +92,7 @@ void G4VisCommandSceneHandlerAttach::SetNewValue (G4UIcommand*,
if (sceneList.empty ()) {
if (verbosity >= G4VisManager::errors) {
G4cout <<
G4cerr <<
"ERROR: No valid scenes available yet. Please create one."
<< G4endl;
}
@@ -126,7 +126,7 @@ void G4VisCommandSceneHandlerAttach::SetNewValue (G4UIcommand*,
}
else {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: Scene \"" << sceneName
G4cerr << "ERROR: Scene \"" << sceneName
<< "\" not found. Use \"/vis/scene/list\" to see possibilities."
<< G4endl;
}
@@ -216,7 +216,7 @@ void G4VisCommandSceneHandlerCreate::SetNewValue (G4UIcommand*,
int nSystems = gsl.size ();
if (nSystems <= 0) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
G4cerr << "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
" no graphics systems available."
"\n Did you instantiate any in"
" YourVisManager::RegisterGraphicsSystems()?"
@@ -237,7 +237,7 @@ void G4VisCommandSceneHandlerCreate::SetNewValue (G4UIcommand*,
// Invalid command line argument or none.
// This shouldn't happen!!!!!!
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
G4cerr << "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
" invalid graphics system specified."
<< G4endl;
}
@@ -255,7 +255,7 @@ void G4VisCommandSceneHandlerCreate::SetNewValue (G4UIcommand*,
}
if (iGS < 0 || iGS >= nSystems) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
G4cerr << "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
" could not find fallback graphics system."
<< G4endl;
}
@@ -289,7 +289,7 @@ void G4VisCommandSceneHandlerCreate::SetNewValue (G4UIcommand*,
G4VSceneHandler* sceneHandler = list [iScene];
if (sceneHandler -> GetName () == newName) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: Scene handler \"" << newName
G4cerr << "ERROR: Scene handler \"" << newName
<< "\" already exists." << G4endl;
}
return;
@@ -300,7 +300,7 @@ void G4VisCommandSceneHandlerCreate::SetNewValue (G4UIcommand*,
fpVisManager -> CreateSceneHandler (newName);
if (fpVisManager -> GetCurrentSceneHandler () -> GetName () != newName) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
G4cerr << "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
" Curious name mismatch."
"\n Current name \""
<< fpVisManager -> GetCurrentSceneHandler () -> GetName ()
@@ -439,9 +439,8 @@ void G4VisCommandSceneHandlerSelect::SetNewValue (G4UIcommand*,
}
else {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: Scene handler \"" << selectName << "\""
<< " not found - \"/vis/sceneHandler/list\""
"\n to see possibilities."
G4cerr << "ERROR: Scene handler \"" << selectName << "\""
<< " not found - \"/vis/sceneHandler/list\" to see possibilities."
<< G4endl;
}
}
@@ -118,7 +118,7 @@ G4VisCommandSetLineWidth::G4VisCommandSetLineWidth ()
G4bool omitable;
fpCommand = new G4UIcmdWithADouble("/vis/set/lineWidth", this);
fpCommand->SetGuidance
("Defines lineWidth for future \"/vis/scene/add/\" commands.");
("Defines line width for future \"/vis/scene/add/\" commands.");
fpCommand->SetParameterName ("lineWidth", omitable = true);
fpCommand->SetDefaultValue (1.);
fpCommand->SetRange("lineWidth >= 1.");
@@ -267,6 +267,43 @@ void G4VisCommandSetTextLayout::SetNewValue (G4UIcommand*, G4String newValue)
}
}
////////////// /vis/set/textSize ////////////////////////////////////
G4VisCommandSetTextSize::G4VisCommandSetTextSize ()
{
G4bool omitable;
fpCommand = new G4UIcmdWithADouble("/vis/set/textSize", this);
fpCommand->SetGuidance
("Defines text size (pixels) for future \"/vis/scene/add/\" commands.");
fpCommand->SetParameterName ("textSize", omitable = true);
fpCommand->SetDefaultValue (12.); // pixels
fpCommand->SetRange("textSize >= 1.");
}
G4VisCommandSetTextSize::~G4VisCommandSetTextSize ()
{
delete fpCommand;
}
G4String G4VisCommandSetTextSize::GetCurrentValue (G4UIcommand*)
{
return G4String();
}
void G4VisCommandSetTextSize::SetNewValue (G4UIcommand*, G4String newValue)
{
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
fCurrentTextSize = fpCommand->GetNewDoubleValue(newValue);
if (verbosity >= G4VisManager::confirmations) {
G4cout <<
"Text size for future \"/vis/scene/add/\" commands has been set to "
<< fCurrentTextSize
<< G4endl;
}
}
////////////// /vis/set/touchable ////////////////////////////////////
G4VisCommandSetTouchable::G4VisCommandSetTouchable ()
@@ -0,0 +1,104 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4VisCommandsTouchable.cc 75794 2013-11-06 13:25:30Z allison $
// /vis/touchable commands - John Allison 14th May 2014
#include "G4VisCommandsTouchable.hh"
#include "G4UIcmdWithoutParameter.hh"
#include "G4TransportationManager.hh"
#include "G4TouchableDumpScene.hh"
////////////// /vis/touchable/dump ///////////////////////////////////////
G4VisCommandsTouchable::G4VisCommandsTouchable()
{
fpCommandDump = new G4UIcmdWithoutParameter("/vis/touchable/dump",this);
fpCommandDump->SetGuidance("Dump touchable attributes.");
fpCommandDump->SetGuidance
("Use \"/vis/set/touchable\" to set current touchable.");
}
G4VisCommandsTouchable::~G4VisCommandsTouchable() {
delete fpCommandDump;
}
G4String G4VisCommandsTouchable::GetCurrentValue(G4UIcommand*) {
return "";
}
void G4VisCommandsTouchable::SetNewValue
(G4UIcommand* command,G4String)
{
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
G4TransportationManager* transportationManager =
G4TransportationManager::GetTransportationManager ();
size_t nWorlds = transportationManager->GetNoWorlds();
G4VPhysicalVolume* world = *(transportationManager->GetWorldsIterator());
if (!world) {
if (verbosity >= G4VisManager::errors) {
G4cerr <<
"ERROR: G4VisCommandsTouchable::SetNewValue:"
"\n No world. Maybe the geometry has not yet been defined."
"\n Try \"/run/initialize\""
<< G4endl;
}
return;
}
if (command == fpCommandDump)
{
G4bool found = false;
std::vector<G4VPhysicalVolume*>::iterator iterWorld =
transportationManager->GetWorldsIterator();
for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
G4PhysicalVolumeModel pvModel (*iterWorld); // Unlimited depth.
G4ModelingParameters mp; // Default - no culling.
pvModel.SetModelingParameters (&mp);
G4TouchableDumpScene dumpScene (G4cout,&pvModel,fCurrentTouchablePath);
pvModel.DescribeYourselfTo (dumpScene); // Initiate dump.
if (dumpScene.IsFound()) found = true;
}
if (!found) {
G4cout << "Touchable not found." << G4endl;
}
return;
} else {
if (verbosity >= G4VisManager::errors) {
G4cerr <<
"ERROR: G4VisCommandsTouchable::SetNewValue: unrecognised command."
<< G4endl;
}
return;
}
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VisCommandsTouchableSet.cc 76285 2013-11-08 13:01:44Z gcosmo $
// $Id: G4VisCommandsTouchableSet.cc 82799 2014-07-10 13:18:29Z gcosmo $
// /vis/touchable/set commands - John Allison 8th October 2012
@@ -166,7 +166,7 @@ void G4VisCommandsTouchableSet::SetNewValue
G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
if (!currentViewer) {
if (verbosity >= G4VisManager::errors) {
G4cout <<
G4cerr <<
"ERROR: G4VisCommandsTouchableSet::SetNewValue: no current viewer."
<< G4endl;
}
@@ -288,7 +288,7 @@ void G4VisCommandsTouchableSet::SetNewValue
else {
if (verbosity >= G4VisManager::errors) {
G4cout <<
G4cerr <<
"ERROR: G4VisCommandsTouchableSet::SetNewValue: unrecognised command."
<< G4endl;
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VisCommandsViewer.cc 77246 2013-11-22 10:01:21Z gcosmo $
// $Id: G4VisCommandsViewer.cc 83403 2014-08-21 15:07:30Z gcosmo $
// /vis/viewer commands - John Allison 25th October 1998
@@ -126,7 +126,7 @@ void G4VisCommandViewerAddCutawayPlane::SetNewValue (G4UIcommand*, G4String newV
G4VViewer* viewer = fpVisManager -> GetCurrentViewer ();
if (!viewer) {
if (verbosity >= G4VisManager::errors) {
G4cout <<
G4cerr <<
"ERROR: No current viewer - \"/vis/viewer/list\" to see possibilities."
<< G4endl;
}
@@ -208,7 +208,7 @@ void G4VisCommandViewerChangeCutawayPlane::SetNewValue (G4UIcommand*, G4String n
G4VViewer* viewer = fpVisManager -> GetCurrentViewer ();
if (!viewer) {
if (verbosity >= G4VisManager::errors) {
G4cout <<
G4cerr <<
"ERROR: No current viewer - \"/vis/viewer/list\" to see possibilities."
<< G4endl;
}
@@ -268,7 +268,7 @@ void G4VisCommandViewerClear::SetNewValue (G4UIcommand*, G4String newValue) {
G4VViewer* viewer = fpVisManager -> GetViewer (clearName);
if (!viewer) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: Viewer \"" << clearName
G4cerr << "ERROR: Viewer \"" << clearName
<< "\" not found - \"/vis/viewer/list\" to see possibilities."
<< G4endl;
}
@@ -306,7 +306,7 @@ void G4VisCommandViewerClearCutawayPlanes::SetNewValue (G4UIcommand*, G4String)
G4VViewer* viewer = fpVisManager -> GetCurrentViewer ();
if (!viewer) {
if (verbosity >= G4VisManager::errors) {
G4cout <<
G4cerr <<
"ERROR: No current viewer - \"/vis/viewer/list\" to see possibilities."
<< G4endl;
}
@@ -354,7 +354,7 @@ void G4VisCommandViewerClearTransients::SetNewValue (G4UIcommand*, G4String newV
G4VViewer* viewer = fpVisManager -> GetViewer (clearName);
if (!viewer) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: Viewer \"" << clearName
G4cerr << "ERROR: Viewer \"" << clearName
<< "\" not found - \"/vis/viewer/list\" to see possibilities."
<< G4endl;
}
@@ -425,7 +425,7 @@ void G4VisCommandViewerClone::SetNewValue (G4UIcommand*, G4String newValue) {
G4VViewer* originalViewer = fpVisManager -> GetViewer (originalName);
if (!originalViewer) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: Viewer \"" << originalName
G4cerr << "ERROR: Viewer \"" << originalName
<< "\" not found - \"/vis/viewer/list\" to see possibilities."
<< G4endl;
}
@@ -468,7 +468,7 @@ void G4VisCommandViewerClone::SetNewValue (G4UIcommand*, G4String newValue) {
if (errorWhileNaming) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: While naming clone viewer \"" << cloneName
G4cerr << "ERROR: While naming clone viewer \"" << cloneName
<< "\"."
<< G4endl;
}
@@ -477,7 +477,7 @@ void G4VisCommandViewerClone::SetNewValue (G4UIcommand*, G4String newValue) {
if (fpVisManager -> GetViewer (cloneName)) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: Putative clone viewer \"" << cloneName
G4cerr << "ERROR: Putative clone viewer \"" << cloneName
<< "\" already exists."
<< G4endl;
}
@@ -534,7 +534,7 @@ void G4VisCommandViewerCopyViewFrom::SetNewValue (G4UIcommand*, G4String newValu
G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
if (!currentViewer) {
if (verbosity >= G4VisManager::errors) {
G4cout <<
G4cerr <<
"ERROR: G4VisCommandsViewerCopyViewFrom::SetNewValue: no current viewer."
<< G4endl;
}
@@ -545,7 +545,7 @@ void G4VisCommandViewerCopyViewFrom::SetNewValue (G4UIcommand*, G4String newValu
G4VViewer* fromViewer = fpVisManager -> GetViewer (fromViewerName);
if (!fromViewer) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: Viewer \"" << fromViewerName
G4cerr << "ERROR: Viewer \"" << fromViewerName
<< "\" not found - \"/vis/viewer/list\" to see possibilities."
<< G4endl;
}
@@ -661,7 +661,7 @@ void G4VisCommandViewerCreate::SetNewValue (G4UIcommand*, G4String newValue) {
// Now need to handle the possibility that the second string
// contains embedded blanks within quotation marks...
char c;
char c = ' ';
while (is.get(c) && c == ' '){}
if (c == '"') {
while (is.get(c) && c != '"') {newName += c;}
@@ -681,7 +681,7 @@ void G4VisCommandViewerCreate::SetNewValue (G4UIcommand*, G4String newValue) {
G4int nHandlers = sceneHandlerList.size ();
if (nHandlers <= 0) {
if (verbosity >= G4VisManager::errors) {
G4cout <<
G4cerr <<
"ERROR: G4VisCommandViewerCreate::SetNewValue: no scene handlers."
"\n Create a scene handler with \"/vis/sceneHandler/create\""
<< G4endl;
@@ -726,7 +726,7 @@ void G4VisCommandViewerCreate::SetNewValue (G4UIcommand*, G4String newValue) {
for (size_t iViewer = 0; iViewer < viewerList.size (); iViewer++) {
if (viewerList [iViewer] -> GetShortName () == newShortName ) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: Viewer \"" << newShortName << "\" already exists."
G4cerr << "ERROR: Viewer \"" << newShortName << "\" already exists."
<< G4endl;
}
return;
@@ -749,7 +749,7 @@ void G4VisCommandViewerCreate::SetNewValue (G4UIcommand*, G4String newValue) {
else {
if (verbosity >= G4VisManager::errors) {
if (newViewer) {
G4cout << "ERROR: New viewer doesn\'t match!!! Curious!!" << G4endl;
G4cerr << "ERROR: New viewer doesn\'t match!!! Curious!!" << G4endl;
} else {
G4cout << "WARNING: No viewer created." << G4endl;
}
@@ -825,7 +825,7 @@ void G4VisCommandViewerDolly::SetNewValue (G4UIcommand* command,
G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
if (!currentViewer) {
if (verbosity >= G4VisManager::errors) {
G4cout <<
G4cerr <<
"ERROR: G4VisCommandsViewerDolly::SetNewValue: no current viewer."
<< G4endl;
}
@@ -885,7 +885,7 @@ void G4VisCommandViewerFlush::SetNewValue (G4UIcommand*, G4String newValue) {
G4VViewer* viewer = fpVisManager -> GetViewer (flushName);
if (!viewer) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: Viewer \"" << flushName << "\"" <<
G4cerr << "ERROR: Viewer \"" << flushName << "\"" <<
" not found - \"/vis/viewer/list\"\n to see possibilities."
<< G4endl;
}
@@ -1079,7 +1079,7 @@ void G4VisCommandViewerPan::SetNewValue (G4UIcommand* command,
G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
if (!currentViewer) {
if (verbosity >= G4VisManager::errors) {
G4cout <<
G4cerr <<
"ERROR: G4VisCommandsViewerPan::SetNewValue: no current viewer."
<< G4endl;
}
@@ -1142,7 +1142,7 @@ void G4VisCommandViewerRebuild::SetNewValue (G4UIcommand*, G4String newValue) {
G4VViewer* viewer = fpVisManager -> GetViewer (rebuildName);
if (!viewer) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: Viewer \"" << rebuildName
G4cerr << "ERROR: Viewer \"" << rebuildName
<< "\" not found - \"/vis/viewer/list\" to see possibilities."
<< G4endl;
}
@@ -1152,7 +1152,7 @@ void G4VisCommandViewerRebuild::SetNewValue (G4UIcommand*, G4String newValue) {
G4VSceneHandler* sceneHandler = viewer->GetSceneHandler();
if (!sceneHandler) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: Viewer \"" << viewer->GetName() << "\"" <<
G4cerr << "ERROR: Viewer \"" << viewer->GetName() << "\"" <<
" has no scene handler - report serious bug."
<< G4endl;
}
@@ -1202,7 +1202,7 @@ void G4VisCommandViewerRefresh::SetNewValue (G4UIcommand*, G4String newValue) {
G4VViewer* viewer = fpVisManager -> GetViewer (refreshName);
if (!viewer) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: Viewer \"" << refreshName << "\"" <<
G4cerr << "ERROR: Viewer \"" << refreshName << "\"" <<
" not found - \"/vis/viewer/list\"\n to see possibilities."
<< G4endl;
}
@@ -1212,7 +1212,7 @@ void G4VisCommandViewerRefresh::SetNewValue (G4UIcommand*, G4String newValue) {
G4VSceneHandler* sceneHandler = viewer->GetSceneHandler();
if (!sceneHandler) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: Viewer \"" << refreshName << "\"" <<
G4cerr << "ERROR: Viewer \"" << refreshName << "\"" <<
" has no scene handler - report serious bug."
<< G4endl;
}
@@ -1297,7 +1297,7 @@ void G4VisCommandViewerReset::SetNewValue (G4UIcommand*, G4String newValue) {
G4VViewer* viewer = fpVisManager -> GetViewer (resetName);
if (!viewer) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: Viewer \"" << resetName
G4cerr << "ERROR: Viewer \"" << resetName
<< "\" not found - \"/vis/viewer/list\" to see possibilities."
<< G4endl;
}
@@ -1350,7 +1350,7 @@ void G4VisCommandViewerSave::SetNewValue (G4UIcommand*, G4String newValue) {
const G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
if (!currentViewer) {
if (verbosity >= G4VisManager::errors) {
G4cout <<
G4cerr <<
"ERROR: G4VisCommandsViewerSave::SetNewValue: no current viewer."
<< G4endl;
}
@@ -1360,7 +1360,7 @@ void G4VisCommandViewerSave::SetNewValue (G4UIcommand*, G4String newValue) {
const G4Scene* currentScene = currentViewer->GetSceneHandler()->GetScene();
if (!currentScene) {
if (verbosity >= G4VisManager::errors) {
G4cout <<
G4cerr <<
"ERROR: G4VisCommandsViewerSave::SetNewValue: no current scene."
<< G4endl;
}
@@ -1373,7 +1373,7 @@ void G4VisCommandViewerSave::SetNewValue (G4UIcommand*, G4String newValue) {
std::ifstream ifs(newValue);
if (ifs) {
if (verbosity >= G4VisManager::errors) {
G4cout <<
G4cerr <<
"ERROR: G4VisCommandsViewerSave::SetNewValue: File \""
<< newValue << "\" already exists."
<< G4endl;
@@ -1384,7 +1384,7 @@ void G4VisCommandViewerSave::SetNewValue (G4UIcommand*, G4String newValue) {
ofs.open(newValue);
if (!ofs) {
if (verbosity >= G4VisManager::errors) {
G4cout <<
G4cerr <<
"ERROR: G4VisCommandsViewerSave::SetNewValue: Trouble opening file \""
<< newValue << "\"."
<< G4endl;
@@ -1480,7 +1480,7 @@ void G4VisCommandViewerScale::SetNewValue (G4UIcommand* command,
G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
if (!currentViewer) {
if (verbosity >= G4VisManager::errors) {
G4cout <<
G4cerr <<
"ERROR: G4VisCommandsViewerScale::SetNewValue: no current viewer."
<< G4endl;
}
@@ -1533,8 +1533,8 @@ void G4VisCommandViewerSelect::SetNewValue (G4UIcommand*, G4String newValue) {
if (!viewer) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: Viewer \"" << selectName << "\"";
G4cout << " not found - \"/vis/viewer/list\""
G4cerr << "ERROR: Viewer \"" << selectName << "\"";
G4cerr << " not found - \"/vis/viewer/list\""
"\n to see possibilities."
<< G4endl;
}
@@ -1595,7 +1595,7 @@ void G4VisCommandViewerUpdate::SetNewValue (G4UIcommand*, G4String newValue) {
if (!viewer) {
if (verbosity >= G4VisManager::errors) {
G4cout <<
"ERROR: G4VisCommandsViewerUpdate::SetNewValue: no current viewer."
"WARNING: command \"/vis/viewer/update\" could not be applied: no current viewer."
<< G4endl;
}
return;
@@ -1604,7 +1604,7 @@ void G4VisCommandViewerUpdate::SetNewValue (G4UIcommand*, G4String newValue) {
G4VSceneHandler* sceneHandler = viewer->GetSceneHandler();
if (!sceneHandler) {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: Viewer \"" << updateName << "\"" <<
G4cerr << "ERROR: Viewer \"" << updateName << "\"" <<
" has no scene handler - report serious bug."
<< G4endl;
}
@@ -1685,7 +1685,7 @@ void G4VisCommandViewerZoom::SetNewValue (G4UIcommand* command,
G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
if (!currentViewer) {
if (verbosity >= G4VisManager::errors) {
G4cout <<
G4cerr <<
"ERROR: G4VisCommandsViewerZoom::SetNewValue: no current viewer."
<< G4endl;
}
@@ -166,7 +166,7 @@ void G4VisCommandViewerDefaultStyle::SetNewValue(G4UIcommand*, G4String newValue
}
else {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: \"" << newValue << "\" not recognised."
G4cerr << "ERROR: \"" << newValue << "\" not recognised."
" Looking for 'w' or 's' first character." << G4endl;
}
return;
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VisCommandsViewerSet.cc 76477 2013-11-11 10:39:56Z gcosmo $
// $Id: G4VisCommandsViewerSet.cc 86988 2014-11-21 13:06:15Z gcosmo $
// /vis/viewer/set commands - John Allison 16th May 2000
@@ -500,7 +500,7 @@ void G4VisCommandsViewerSet::SetNewValue
G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
if (!currentViewer) {
if (verbosity >= G4VisManager::errors) {
G4cout <<
G4cerr <<
"ERROR: G4VisCommandsViewerSet::SetNewValue: no current viewer."
<< G4endl;
}
@@ -513,7 +513,7 @@ void G4VisCommandsViewerSet::SetNewValue
G4VViewer* fromViewer = fpVisManager->GetViewer(newValue);
if (!fromViewer) {
if (verbosity >= G4VisManager::errors) {
G4cout <<
G4cerr <<
"ERROR: G4VisCommandsViewerSet::SetNewValue: all:"
"\n unrecognised from-viewer."
<< G4endl;
@@ -562,8 +562,8 @@ void G4VisCommandsViewerSet::SetNewValue
<< currentViewer->GetName() << " is NOT auto-refesh by default"
<< "\n so cannot be set to auto-refresh."
<< G4endl;
return;
}
return;
}
vp.SetAutoRefresh(autoRefresh);
if (verbosity >= G4VisManager::confirmations) {
@@ -680,7 +680,7 @@ void G4VisCommandsViewerSet::SetNewValue
}
else {
if (verbosity >= G4VisManager::errors) {
G4cout <<
G4cerr <<
"ERROR: G4VisCommandsViewerSet::SetNewValue: culling:"
"\n option not recognised."
<< G4endl;
@@ -891,7 +891,7 @@ void G4VisCommandsViewerSet::SetNewValue
vp.SetLightsMoveWithCamera(false);
else {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: \"" << newValue << "\" not recognised."
G4cerr << "ERROR: \"" << newValue << "\" not recognised."
" Looking for \"cam\" or \"obj\" in string." << G4endl;
}
}
@@ -965,7 +965,7 @@ void G4VisCommandsViewerSet::SetNewValue
fieldHalfAngle *= G4UIcommand::ValueOf(unit);
if (fieldHalfAngle > 89.5 * deg || fieldHalfAngle <= 0.0) {
if (verbosity >= G4VisManager::errors) {
G4cout <<
G4cerr <<
"ERROR: Field half angle should be 0 < angle <= 89.5 degrees.";
G4cout << G4endl;
}
@@ -974,7 +974,7 @@ void G4VisCommandsViewerSet::SetNewValue
}
else {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: \"" << newValue << "\" not recognised."
G4cerr << "ERROR: \"" << newValue << "\" not recognised."
" Looking for 'o' or 'p' first character." << G4endl;
}
return;
@@ -1050,7 +1050,7 @@ void G4VisCommandsViewerSet::SetNewValue
style = G4ViewParameters::freeRotation;
else {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: \"" << newValue << "\" not recognised." << G4endl;
G4cerr << "ERROR: \"" << newValue << "\" not recognised." << G4endl;
}
return;
}
@@ -1095,7 +1095,7 @@ void G4VisCommandsViewerSet::SetNewValue
}
else {
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: \"" << newValue << "\" not recognised."
G4cerr << "ERROR: \"" << newValue << "\" not recognised."
" Looking for 'w' or 's' first character." << G4endl;
}
return;
@@ -1167,21 +1167,28 @@ void G4VisCommandsViewerSet::SetNewValue
}
else if (command == fpCommandViewpointVector) {
fViewpointVector = G4UIcommand::ConvertTo3Vector(newValue).unit();
vp.SetViewAndLights(fViewpointVector);
if (verbosity >= G4VisManager::confirmations) {
G4cout << "Viewpoint direction set to "
<< vp.GetViewpointDirection() << G4endl;
if (vp.GetLightsMoveWithCamera ()) {
G4cout << "Lightpoint direction set to "
<< vp.GetActualLightpointDirection () << G4endl;
G4ThreeVector viewpointVector = G4UIcommand::ConvertTo3Vector(newValue);
if (viewpointVector.mag2() <= 0.) {
if (verbosity >= G4VisManager::errors) {
G4cerr << "ERROR: Null viewpoint vector. No action taken." << G4endl;
}
} else {
fViewpointVector = viewpointVector.unit();
vp.SetViewAndLights(fViewpointVector);
if (verbosity >= G4VisManager::confirmations) {
G4cout << "Viewpoint direction set to "
<< vp.GetViewpointDirection() << G4endl;
if (vp.GetLightsMoveWithCamera ()) {
G4cout << "Lightpoint direction set to "
<< vp.GetActualLightpointDirection () << G4endl;
}
}
}
}
else {
if (verbosity >= G4VisManager::errors) {
G4cout <<
G4cerr <<
"ERROR: G4VisCommandsViewerSet::SetNewValue: unrecognised command."
<< G4endl;
}
@@ -1,45 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4VisFeaturesOfDAWNFILE.cc 66373 2012-12-18 09:41:34Z gcosmo $
//
#include "G4VisFeaturesOfDAWNFILE.hh"
G4String G4VisFeaturesOfDAWNFILE () {
return
"High quality technical renderer."
"\n Features: exact hidden line, hidden surface algorithms."
"\n high (unlimited) resolution."
"\n renders to PostScript for viewing and/or hardcopy."
"\n remote rendering."
"\n off-line rendering."
"\n graphical user interface."
"\n connection via g4.prim file to Fukui Renderer DAWN etc."
"\n Disadvantages: compute intensive, takes time (use a fast graphics"
"\n system, such as OpenGL, to select view, then copy"
"\n view parameters to this renderer:"
"\n \"/vis/viewer/set/all <OpenGL-view>\".";
}
@@ -1,45 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4VisFeaturesOfFukuiRenderer.cc 66373 2012-12-18 09:41:34Z gcosmo $
//
//
#include "G4VisFeaturesOfFukuiRenderer.hh"
G4String G4VisFeaturesOfFukuiRenderer () {
return
"High quality technical renderer."
"\n Features: exact hidden line, hidden surface algorithms."
"\n high (unlimited) resolution."
"\n renders to PostScript for viewing and/or hardcopy."
"\n remote rendering."
"\n off-line rendering."
"\n graphical user interface."
"\n Disadvantages: compute intensive, takes time (use a fast graphics"
"\n system, such as OpenGL, to select view, then copy"
"\n to this renderer - /vis~/copy/view, /vis~/set/view).";
}
@@ -1,106 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4VisFeaturesOfOpenGL.cc 66373 2012-12-18 09:41:34Z gcosmo $
//
//
#include "G4VisFeaturesOfOpenGL.hh"
G4String G4VisFeaturesOfOpenGLIX () {
return
" Dumb single buffered X Window, No Graphics Database."
"\n Advantages: does not gobble server memory."
"\n good for drawing steps and hits."
"\n Disadvantages: needs G4 kernel for re-Draw."
"\n cannot take advantage of graphics accelerators.";
}
G4String G4VisFeaturesOfOpenGLSX () {
return
" Dumb double buffered X Window with Graphics Database."
"\n Advantages: uses display lists as graphics database."
"\n fastest possible redraw, e.g., on simple change"
"\n of viewpoint."
"\n uses client-server model for remote viewing"
"\n (but only if you have a full client-server"
"\n implementation of OpenGL, i.e., not Mesa)."
"\n Disadvantages: not advised for viewing large numbers of steps"
"\n and/or hits, because it gobbles memory for"
" database.";
}
G4String G4VisFeaturesOfOpenGLIXm () {
return
" Smart single buffered X Window, No Graphics Database."
"\n Advantages: resizeable, and has Motif-based view-control panel."
"\n does not gobble server memory."
"\n good for drawing steps and hits."
"\n Disadvantages: currently locks out GEANT4 commands, until \"exit\"."
"\n needs G4 kernel for re-Draw."
"\n cannot take advantage of graphics accelerators.";
}
G4String G4VisFeaturesOfOpenGLSXm () {
return
" Smart double buffered X Window with Graphics Database."
"\n Advantages: resizeable, and has Motif-based view-control panel."
"\n uses display lists as graphics database."
"\n fastest possible redraw, e.g., on simple change"
"\n of viewpoint."
"\n uses client-server model for remote viewing"
"\n (but only if you have a full client-server"
"\n implementation of OpenGL, i.e., not Mesa)."
"\n Disadvantages: currently locks out GEANT4 commands, until \"exit\"."
"\n not advised for viewing large numbers of steps"
"\n and/or hits, because it gobbles memory for"
" database.";
}
G4String G4VisFeaturesOfOpenGLIWin32 () {
return
"\n It runs on WindowsNT ";
}
G4String G4VisFeaturesOfOpenGLSWin32 () {
return
"\n It runs on WindowsNT ";
}
G4String G4VisFeaturesOfOpenGLIQt () {
return
"\n It runs everywhere";
}
G4String G4VisFeaturesOfOpenGLSQt () {
return
"\n It runs everywhere ";
}
G4String G4VisFeaturesOfOpenGLIWt () {
return
"\n It runs everywhere";
}
@@ -1,39 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4VisFeaturesOfOpenInventor.cc 66373 2012-12-18 09:41:34Z gcosmo $
//
//
#include "G4VisFeaturesOfOpenInventor.hh"
G4String G4VisFeaturesOfOpenInventor () {
return
" Open Inventor Window/View/Scene."
"\n Advantages: Open Inventor feature set (interactivity, scene control)."
"\n Disadvantages: Requires Open Inventor license ($$), Hepvis library (Free).";
}
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VisManager.cc 77479 2013-11-25 10:01:22Z gcosmo $
// $Id: G4VisManager.cc 87360 2014-12-01 16:07:16Z gcosmo $
//
//
// GEANT4 Visualization Manager - John Allison 02/Jan/1996.
@@ -38,6 +38,7 @@
#include "G4VisCommandsScene.hh"
#include "G4VisCommandsSceneAdd.hh"
#include "G4VisCommandsSceneHandler.hh"
#include "G4VisCommandsTouchable.hh"
#include "G4VisCommandsTouchableSet.hh"
#include "G4VisCommandsViewer.hh"
#include "G4VisCommandsViewerDefault.hh"
@@ -394,6 +395,7 @@ void G4VisManager::RegisterMessengers () {
RegisterMessenger(new G4VisCommandSetLineWidth);
RegisterMessenger(new G4VisCommandSetTextColour);
RegisterMessenger(new G4VisCommandSetTextLayout);
RegisterMessenger(new G4VisCommandSetTextSize);
RegisterMessenger(new G4VisCommandSetTouchable);
directory = new G4UIdirectory ("/vis/scene/");
@@ -416,6 +418,7 @@ void G4VisManager::RegisterMessengers () {
RegisterMessenger(new G4VisCommandSceneAddDate);
RegisterMessenger(new G4VisCommandSceneAddDigis);
RegisterMessenger(new G4VisCommandSceneAddEventID);
RegisterMessenger(new G4VisCommandSceneAddExtent);
RegisterMessenger(new G4VisCommandSceneAddFrame);
RegisterMessenger(new G4VisCommandSceneAddHits);
RegisterMessenger(new G4VisCommandSceneAddLine);
@@ -443,6 +446,8 @@ void G4VisManager::RegisterMessengers () {
directory = new G4UIdirectory ("/vis/touchable/");
directory -> SetGuidance ("Operations on touchables.");
fDirectoryList.push_back (directory);
RegisterMessenger(new G4VisCommandsTouchable);
directory = new G4UIdirectory ("/vis/touchable/set/");
directory -> SetGuidance ("Set vis attributes of current touchable.");
fDirectoryList.push_back (directory);
@@ -661,7 +666,7 @@ void G4VisManager::BeginDraw (const G4Transform3D& objectTransform)
fDrawGroupNestingDepth++;
if (fDrawGroupNestingDepth > 1) {
G4Exception
("G4VSceneHandler::BeginDraw",
("G4VisManager::BeginDraw",
"visman0008", JustWarning,
"Nesting detected. It is illegal to nest Begin/EndDraw."
"\n Ignored");
@@ -698,7 +703,7 @@ void G4VisManager::BeginDraw2D (const G4Transform3D& objectTransform)
fDrawGroupNestingDepth++;
if (fDrawGroupNestingDepth > 1) {
G4Exception
("G4VSceneHandler::BeginDraw2D",
("G4VisManager::BeginDraw2D",
"visman0009", JustWarning,
"Nesting detected. It is illegal to nest Begin/EndDraw2D."
"\n Ignored");
@@ -883,14 +888,28 @@ void G4VisManager::Draw (const G4VTrajectory& traj) {
#ifdef G4MULTITHREADED
if (G4Threading::IsWorkerThread()) return;
#endif
// A trajectory needs a trajectories model to provide G4Atts, etc.
static G4TrajectoriesModel trajectoriesModel;
trajectoriesModel.SetCurrentTrajectory(&traj);
const G4Run* currentRun = G4RunManager::GetRunManager()->GetCurrentRun();
if (currentRun) {
trajectoriesModel.SetRunID(currentRun->GetRunID());
}
const G4Event* currentEvent =
G4EventManager::GetEventManager()->GetConstCurrentEvent();
if (currentEvent) {
trajectoriesModel.SetEventID(currentEvent->GetEventID());
}
if (fIsDrawGroup) {
fpSceneHandler -> SetModel (&dummyTrajectoriesModel);
fpSceneHandler -> SetModel (&trajectoriesModel);
fpSceneHandler -> AddCompound (traj);
fpSceneHandler -> SetModel (0);
} else {
if (IsValidView ()) {
ClearTransientStoreIfMarked();
fpSceneHandler -> SetModel (&dummyTrajectoriesModel);
fpSceneHandler -> SetModel (&trajectoriesModel);
fpSceneHandler -> AddCompound (traj);
fpSceneHandler -> SetModel (0);
}
}
}
@@ -929,10 +948,21 @@ void G4VisManager::Draw (const G4VSolid& solid,
void G4VisManager::Draw (const G4VPhysicalVolume& physicalVol,
const G4VisAttributes& attribs,
const G4Transform3D& objectTransform) {
// Find corresponding logical volume and solid.
#ifdef G4MULTITHREADED
if (G4Threading::IsWorkerThread()) return;
#endif
// Note: It is tempting to use a temporary model here, as for
// trajectories, in order to get at the G4Atts of the physical
// volume. I tried it (JA). But it's not easy to pass the
// vis attributes. Also other aspects of the model seem not to
// be properly set up. So, the idea has been abandoned for the time
// being. The model pointer will be null. So when picking there
// will be no G4Atts from this physical volume.
//
// If this is called from DrawHit, for example, the user may G4Atts to the
// hit and these will be available with "/vis/scene/add/hits".
//
// Find corresponding logical volume and solid.
G4LogicalVolume* pLV = physicalVol.GetLogicalVolume ();
G4VSolid* pSol = pLV -> GetSolid ();
Draw (*pSol, attribs, objectTransform);
@@ -974,7 +1004,7 @@ void G4VisManager::CreateViewer
if (!p) {
if (fVerbosity >= errors) {
G4cout << "ERROR in G4VisManager::CreateViewer during "
G4cerr << "ERROR in G4VisManager::CreateViewer during "
<< fpGraphicsSystem -> GetName ()
<< " viewer creation.\n No action taken."
<< G4endl;
@@ -984,7 +1014,7 @@ void G4VisManager::CreateViewer
if (p -> GetViewId() < 0) {
if (fVerbosity >= errors) {
G4cout << "ERROR in G4VisManager::CreateViewer during "
G4cerr << "ERROR in G4VisManager::CreateViewer during "
<< fpGraphicsSystem -> GetName ()
<< " viewer initialisation.\n No action taken."
<< G4endl;
@@ -1351,6 +1381,14 @@ void G4VisManager::SetCurrentViewer (G4VViewer* pViewer) {
<< G4endl;
}
fpSceneHandler = fpViewer -> GetSceneHandler ();
if (!fpSceneHandler) {
if (fVerbosity >= warnings) {
G4cout <<
"WARNING: No scene handler for this viewer - please create one."
<< G4endl;
}
return;
}
fpSceneHandler -> SetCurrentViewer (pViewer);
fpScene = fpSceneHandler -> GetScene ();
fpGraphicsSystem = fpSceneHandler -> GetGraphicsSystem ();
@@ -1507,26 +1545,26 @@ void G4VisManager::PrintAvailableColours (Verbosity) const {
void G4VisManager::PrintInvalidPointers () const {
if (fVerbosity >= errors) {
G4cout << "ERROR: G4VisManager::PrintInvalidPointers:";
G4cerr << "ERROR: G4VisManager::PrintInvalidPointers:";
if (!fpGraphicsSystem) {
G4cout << "\n null graphics system pointer.";
G4cerr << "\n null graphics system pointer.";
}
else {
G4cout << "\n Graphics system is " << fpGraphicsSystem -> GetName ()
G4cerr << "\n Graphics system is " << fpGraphicsSystem -> GetName ()
<< " but:";
if (!fpScene)
G4cout <<
G4cerr <<
"\n Null scene pointer. Use \"/vis/drawVolume\" or"
" \"/vis/scene/create\".";
if (!fpSceneHandler)
G4cout <<
G4cerr <<
"\n Null scene handler pointer. Use \"/vis/open\" or"
" \"/vis/sceneHandler/create\".";
if (!fpViewer )
G4cout <<
G4cerr <<
"\n Null viewer pointer. Use \"/vis/viewer/create\".";
}
G4cout << G4endl;
G4cerr << G4endl;
}
}
@@ -1666,6 +1704,7 @@ void G4VisManager::EndOfRun ()
if (GetConcreteInstance() && eventsFromThreads) {
std::vector<const G4Event*>::const_iterator i;
if (fpScene->GetRefreshAtEndOfEvent()) {
for (i = eventsFromThreads->begin(); i != eventsFromThreads->end(); ++i) {
if (fVerbosity >= confirmations) {
G4cout << "Drawing event " << (*i)->GetEventID() << G4endl;
@@ -1700,12 +1739,13 @@ void G4VisManager::EndOfRun ()
eorModels = tmpEorModels;
fTransientsDrawnThisEvent = false;
if (fpSceneHandler) fpSceneHandler->SetTransientsDrawnThisEvent(false);
fpSceneHandler->SetTransientsDrawnThisEvent(false);
fpSceneHandler->DrawEvent(*i);
// ShowView guarantees the view comes to the screen. No action
// is taken for passive viewers like OGL*X, but it passes control to
// interactive viewers, such OGL*Xm and allows file-writing
// viewers to close the file.
// is taken for passive viewers like OGL*X (without picking enabled),
// but it passes control to interactive viewers, such as OGL*X (with
// picking enabled) or OGL*Xm, and allows file-writing viewers to
// close the file.
fpViewer->ShowView();
fpSceneHandler->SetMarkForClearingTransientStore(true);
}
@@ -1723,6 +1763,7 @@ void G4VisManager::EndOfRun ()
// But, for this stop-gap solution...
// Deactivate end-of-event and end-of-run models...
G4Scene* scene = fpSceneHandler->GetScene();
assert(scene); // To keep Coverity happy.
std::vector<G4Scene::Model>& eoeModels = scene->SetEndOfEventModelList();
std::vector<G4Scene::Model> tmpEoeModels = eoeModels;
std::vector<G4Scene::Model>::iterator iEoe;
@@ -1740,12 +1781,12 @@ void G4VisManager::EndOfRun ()
eoeModels = tmpEoeModels;
eorModels = tmpEorModels;
fTransientsDrawnThisEvent = false;
if (fpSceneHandler) fpSceneHandler->SetTransientsDrawnThisEvent(false);
for (i = eventsFromThreads->begin(); i != eventsFromThreads->end(); ++i) {
if (fVerbosity >= confirmations) {
G4cout << "Drawing event " << (*i)->GetEventID() << G4endl;
}
fTransientsDrawnThisEvent = false;
fpSceneHandler->SetTransientsDrawnThisEvent(false);
fpSceneHandler->DrawEvent(*i);
}
if (fpScene->GetRefreshAtEndOfRun()) {
@@ -1756,9 +1797,17 @@ void G4VisManager::EndOfRun ()
fpViewer->RefreshView();
}
fpSceneHandler->SetMarkForClearingTransientStore(true);
} else {
if (fpGraphicsSystem->GetFunctionality() ==
G4VGraphicsSystem::fileWriter) {
if (fVerbosity >= warnings) {
G4cout << "\"/vis/viewer/update\" to close file." << G4endl;
}
}
}
}
}
fEventRefreshing = false;
}
// End of multithreaded versions of Begin/EndOfRun/Event.
@@ -1800,81 +1849,9 @@ void G4VisManager::EndOfEvent ()
const G4Event* currentEvent = eventManager->GetConstCurrentEvent();
if (!currentEvent) return;
G4RunManager* runManager = G4RunManager::GetRunManager();
const G4Run* currentRun = runManager->GetCurrentRun();
if (!currentRun) return;
//G4cout << "G4VisManager::EndOfEvent" << G4endl;
// We are about to draw the event (trajectories, etc.), but first we
// have to clear the previous event(s) if necessary. If this event
// needs to be drawn afresh, e.g., the first event or any event when
// "accumulate" is not requested, the old event has to be cleared.
// We have postponed this so that, for normal viewers like OGL, the
// previous event(s) stay on screen until this new event comes
// along. For a file-writing viewer the geometry has to be drawn.
// See, for example, G4HepRepFileSceneHandler::ClearTransientStore.
ClearTransientStoreIfMarked();
// Now draw the event...
fpSceneHandler->DrawEvent(currentEvent);
G4int nEventsToBeProcessed = 0;
G4int nKeptEvents = 0;
G4int eventID = -2; // (If no run manager, triggers ShowView as normal.)
if (currentRun) {
nEventsToBeProcessed = currentRun->GetNumberOfEventToBeProcessed();
eventID = currentEvent->GetEventID();
const std::vector<const G4Event*>* events =
currentRun->GetEventVector();
if (events) nKeptEvents = events->size();
}
if (fpScene->GetRefreshAtEndOfEvent()) {
// Unless last event (in which case wait end of run)...
if (eventID < nEventsToBeProcessed - 1) {
// ShowView guarantees the view comes to the screen. No action
// is taken for passive viewers like OGL*X, but it passes control to
// interactive viewers, such OGL*Xm and allows file-writing
// viewers to close the file.
fpViewer->ShowView();
fpSceneHandler->SetMarkForClearingTransientStore(true);
} else { // Last event...
// Keep, but only if user has not kept any...
if (!nKeptEvents) {
eventManager->KeepTheCurrentEvent();
fNKeepRequests++;
fKeptLastEvent = true;
}
}
} else { // Accumulating events...
G4int maxNumberOfKeptEvents = fpScene->GetMaxNumberOfKeptEvents();
if (maxNumberOfKeptEvents > 0 && fNKeepRequests >= maxNumberOfKeptEvents) {
fEventKeepingSuspended = true;
static G4bool warned = false;
if (!warned) {
if (fVerbosity >= warnings) {
G4cout <<
"WARNING: G4VisManager::EndOfEvent: Automatic event keeping suspended."
"\n The number of events exceeds the maximum, "
<< maxNumberOfKeptEvents <<
", that may be kept by\n the vis manager."
<< G4endl;
}
warned = true;
}
} else if (maxNumberOfKeptEvents != 0) {
// If not disabled nor suspended.
if (GetConcreteInstance() && !fEventKeepingSuspended) {
// G4cout << "Requesting keeping event " << currentEvent->GetEventID() << G4endl;
eventManager->KeepTheCurrentEvent();
fNKeepRequests++;
}
}
}
DrawEvent(currentEvent);
}
void G4VisManager::EndOfRun ()
@@ -1947,21 +1924,109 @@ void G4VisManager::EndOfRun ()
if (fpScene->GetRefreshAtEndOfRun()) {
fpSceneHandler->DrawEndOfRunModels();
// ShowView guarantees the view comes to the screen. No action
// is taken for passive viewers like OGL*X, but it passes control to
// interactive viewers, such OGL*Xm and allows file-writing
// viewers to close the file.
// is taken for passive viewers like OGL*X (without picking enabled),
// but it passes control to interactive viewers, such as OGL*X (with
// picking enabled) or OGL*Xm, and allows file-writing viewers to
// close the file.
fpViewer->ShowView();
// An extra refresh for auto-refresh viewers
// An extra refresh for auto-refresh viewers.
if (fpViewer->GetViewParameters().IsAutoRefresh()) {
fpViewer->RefreshView();
}
fpSceneHandler->SetMarkForClearingTransientStore(true);
} else {
if (fpGraphicsSystem->GetFunctionality() ==
G4VGraphicsSystem::fileWriter) {
if (fVerbosity >= warnings) {
G4cout << "\"/vis/viewer/update\" to close file." << G4endl;
}
}
}
}
}
fEventRefreshing = false;
}
void G4VisManager::DrawEvent(const G4Event* event)
{
G4EventManager* eventManager = G4EventManager::GetEventManager();
G4RunManager* runManager = G4RunManager::GetRunManager();
const G4Run* currentRun = runManager->GetCurrentRun();
if (!currentRun) return;
// We are about to draw the event (trajectories, etc.), but first we
// have to clear the previous event(s) if necessary. If this event
// needs to be drawn afresh, e.g., the first event or any event when
// "accumulate" is not requested, the old event has to be cleared.
// We have postponed this so that, for normal viewers like OGL, the
// previous event(s) stay on screen until this new event comes
// along. For a file-writing viewer the geometry has to be drawn.
// See, for example, G4HepRepFileSceneHandler::ClearTransientStore.
ClearTransientStoreIfMarked();
// Now draw the event...
fpSceneHandler->DrawEvent(event);
G4int nEventsToBeProcessed = 0;
G4int nKeptEvents = 0;
G4int eventID = -2; // (If no run manager, triggers ShowView as normal.)
if (currentRun) {
nEventsToBeProcessed = currentRun->GetNumberOfEventToBeProcessed();
eventID = event->GetEventID();
const std::vector<const G4Event*>* events =
currentRun->GetEventVector();
if (events) nKeptEvents = events->size();
}
if (fpScene->GetRefreshAtEndOfEvent()) {
// Unless last event (in which case wait end of run)...
if (eventID < nEventsToBeProcessed - 1) {
// ShowView guarantees the view comes to the screen. No action
// is taken for passive viewers like OGL*X (without picking enabled),
// but it passes control to interactive viewers, such as OGL*X (with
// picking enabled) or OGL*Xm, and allows file-writing viewers to
// close the file.
fpViewer->ShowView();
fpSceneHandler->SetMarkForClearingTransientStore(true);
} else { // Last event...
// Keep, but only if user has not kept any...
if (!nKeptEvents) {
eventManager->KeepTheCurrentEvent();
fNKeepRequests++;
fKeptLastEvent = true;
}
}
} else { // Accumulating events...
G4int maxNumberOfKeptEvents = fpScene->GetMaxNumberOfKeptEvents();
if (maxNumberOfKeptEvents > 0 && fNKeepRequests >= maxNumberOfKeptEvents) {
fEventKeepingSuspended = true;
static G4bool warned = false;
if (!warned) {
if (fVerbosity >= warnings) {
G4cout <<
"WARNING: G4VisManager::EndOfEvent: Automatic event keeping suspended."
"\n The number of events exceeds the maximum, "
<< maxNumberOfKeptEvents <<
", that may be kept by\n the vis manager."
<< G4endl;
}
warned = true;
}
} else if (maxNumberOfKeptEvents != 0) {
// If not disabled nor suspended.
if (GetConcreteInstance() && !fEventKeepingSuspended) {
// G4cout << "Requesting keeping event " << event->GetEventID() << G4endl;
eventManager->KeepTheCurrentEvent();
fNKeepRequests++;
}
}
}
}
#endif // End of sequential versions of Begin/EndOfRun/Event.
void G4VisManager::ClearTransientStoreIfMarked(){
@@ -2050,13 +2115,13 @@ G4VisManager::GetVerbosityValue(const G4String& verbosityString) {
std::istringstream is(ss);
is >> intVerbosity;
if (!is) {
G4cout << "ERROR: G4VisManager::GetVerbosityValue: invalid verbosity \""
G4cerr << "ERROR: G4VisManager::GetVerbosityValue: invalid verbosity \""
<< verbosityString << "\"";
for (size_t i = 0; i < VerbosityGuidanceStrings.size(); ++i) {
G4cout << '\n' << VerbosityGuidanceStrings[i];
G4cerr << '\n' << VerbosityGuidanceStrings[i];
}
verbosity = warnings;
G4cout << "\n Returning " << VerbosityString(verbosity)
G4cerr << "\n Returning " << VerbosityString(verbosity)
<< G4endl;
}
else {
@@ -2112,7 +2177,7 @@ G4bool G4VisManager::IsValidView () {
if ((!fpScene) || (!fpSceneHandler) || (!fpViewer)) {
if (fVerbosity >= errors) {
G4cout <<
G4cerr <<
"ERROR: G4VisManager::IsValidView(): Current view is not valid."
<< G4endl;
PrintInvalidPointers ();
@@ -2122,7 +2187,7 @@ G4bool G4VisManager::IsValidView () {
if (fpScene != fpSceneHandler -> GetScene ()) {
if (fVerbosity >= errors) {
G4cout << "ERROR: G4VisManager::IsValidView ():";
G4cerr << "ERROR: G4VisManager::IsValidView ():";
if (fpSceneHandler -> GetScene ()) {
G4cout <<
"\n The current scene \""
@@ -2158,7 +2223,7 @@ G4bool G4VisManager::IsValidView () {
const G4ViewerList& viewerList = fpSceneHandler -> GetViewerList ();
if (viewerList.size () == 0) {
if (fVerbosity >= errors) {
G4cout <<
G4cerr <<
"ERROR: G4VisManager::IsValidView (): the current scene handler\n \""
<< fpSceneHandler -> GetName ()
<< "\" has no viewers. Do /vis/viewer/create."
@@ -2173,11 +2238,12 @@ G4bool G4VisManager::IsValidView () {
G4bool successful = fpScene -> AddWorldIfEmpty (warn);
if (!successful || fpScene -> IsEmpty ()) { // If still empty...
if (fVerbosity >= errors) {
G4cout << "ERROR: G4VisManager::IsViewValid ():";
G4cout <<
G4cerr << "ERROR: G4VisManager::IsValidView ():";
G4cerr <<
"\n Attempt at some drawing operation when scene is empty."
"\n Maybe the geometry has not yet been defined."
" Try /run/initialize."
"\n Or use \"/vis/scene/add/extent\"."
<< G4endl;
}
isValid = false;