Import Geant4 10.4.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2017-06-30 10:49:55 +02:00
parent 3a5407696b
commit 1a1316fea4
2180 changed files with 237880 additions and 59109 deletions
+28 -2
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4Scene.cc 99418 2016-09-21 09:18:42Z gcosmo $
// $Id: G4Scene.cc 101958 2016-12-12 08:04:35Z gcosmo $
//
//
// Scene data John Allison 19th July 1996.
@@ -37,6 +37,8 @@
#include "G4PhysicalVolumeModel.hh"
#include "G4TransportationManager.hh"
#include <set>
G4Scene::G4Scene (const G4String& name):
fName (name),
fRefreshAtEndOfEvent(true),
@@ -46,7 +48,8 @@ G4Scene::G4Scene (const G4String& name):
G4Scene::~G4Scene () {}
G4bool G4Scene::AddRunDurationModel (G4VModel* pModel, G4bool warn) {
G4bool G4Scene::AddRunDurationModel (G4VModel* pModel, G4bool warn)
{
std::vector<Model>::const_iterator i;
for (i = fRunDurationModelList.begin ();
i != fRunDurationModelList.end (); ++i) {
@@ -64,8 +67,31 @@ G4bool G4Scene::AddRunDurationModel (G4VModel* pModel, G4bool warn) {
}
return false;
}
for (i = fRunDurationModelList.begin ();
i != fRunDurationModelList.end (); ++i) {
if (pModel -> GetGlobalTag () ==
i->fpModel->GetGlobalTag ()) break;
}
if (i != fRunDurationModelList.end ()) {
if (warn) {
G4cout
<< "G4Scene::AddRunDurationModel: The tag \""
<< pModel->GetGlobalTag()
<< "\"\n duplicates one already in scene \""
<< fName
<<
"\".\n This may be intended but if not, you may inspect the scene with"
"\n \"/vis/scene/list\" and deactivate unwanted models with"
"\n \"/vis/scene/activateModel\". Or create a new scene."
<< G4endl;
}
}
fRunDurationModelList.push_back (Model(pModel));
CalculateExtent ();
return true;
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VSceneHandler.cc 101714 2016-11-22 08:53:13Z gcosmo $
// $Id: G4VSceneHandler.cc 102802 2017-02-22 15:19:00Z gcosmo $
//
//
// John Allison 19th July 1996
@@ -136,7 +136,8 @@ const G4VisExtent& G4VSceneHandler::GetExtent() const
if (fpScene) {
return fpScene->GetExtent();
} else {
return G4VisExtent::NullExtent;
static const G4VisExtent defaultExtent = G4VisExtent();
return defaultExtent;
}
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VVisCommand.cc 95006 2016-01-15 08:26:18Z gcosmo $
// $Id: G4VVisCommand.cc 104163 2017-05-15 06:52:42Z gcosmo $
// Base class for visualization commands - John Allison 9th August 1998
// It is really a messenger - we have one command per messenger.
@@ -35,14 +35,16 @@
#include "G4UImanager.hh"
#include "G4UnitsTable.hh"
#include <sstream>
#include <cctype>
G4int G4VVisCommand::fErrorCode = 0;
G4Colour G4VVisCommand::fCurrentColour = G4Colour::White();
G4Colour G4VVisCommand::fCurrentTextColour = G4Colour::Blue();
G4Text::Layout G4VVisCommand::fCurrentTextLayout = G4Text::left;
G4double G4VVisCommand::fCurrentTextSize = 12.; // pixels
G4double G4VVisCommand::fCurrentLineWidth = 1.; // pixels
G4int G4VVisCommand::fCurrentArrow3DLineSegmentsPerCircle = 6;
G4Colour G4VVisCommand::fCurrentColour = G4Colour::White();
G4Colour G4VVisCommand::fCurrentTextColour = G4Colour::Blue();
G4Text::Layout G4VVisCommand::fCurrentTextLayout = G4Text::left;
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;
@@ -64,21 +66,95 @@ G4String G4VVisCommand::ConvertToString
return oss.str();
}
void G4VVisCommand::ConvertToDoublePair(const G4String& paramString,
G4bool G4VVisCommand::ConvertToDoublePair(const G4String& paramString,
G4double& xval,
G4double& yval)
{
G4double x, y;
char unts[30];
G4String unit;
std::istringstream is(paramString);
is >> x >> y >> unts;
G4String unt = unts;
is >> x >> y >> unit;
xval = x*G4UIcommand::ValueOf(unt);
yval = y*G4UIcommand::ValueOf(unt);
if (G4UnitDefinition::IsUnitDefined(unit)) {
xval = x*G4UIcommand::ValueOf(unit);
yval = y*G4UIcommand::ValueOf(unit);
} else {
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
if (verbosity >= G4VisManager::errors) {
G4cout << "ERROR: Unrecognised unit" << G4endl;
}
return false;
}
return;
return true;
}
const G4String& G4VVisCommand::ConvertToColourGuidance()
{
static G4String guidance
("Accepts (a) RGB triplet. e.g., \".3 .4 .5\", or"
"\n(b) string such as \"white\", \"black\", \"grey\", \"red\"..."
"\n(c) an additional number for opacity, e.g., \".3 .4 .5 .6\""
"\n or \"grey ! ! .6\" (note \"!\"'s for unused green and blue parameters),"
"\n e.g. \"! ! ! 0.\" for a transparent colour.");
return guidance;
}
void G4VVisCommand::ConvertToColour
(G4Colour& colour,
const G4String& redOrString, G4double green, G4double blue, G4double opacity)
{
// Note: colour is supplied by the caller and becomes the default if the
// remaining parameters cannot be parsed.
// Note: redOrString is either a number or string. If a string it must be
// one of the recognised colours.
// Thus the arguments can be, for example:
// (colour,"red",...,...,0.5): will give the colour red with opacity 0.5 (the
// third and fourth arguments are ignored), or
// (1.,0.,0.,0.5): this also will be red with opacity 0.5.
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
const size_t iPos0 = 0;
if (std::isalpha(redOrString[iPos0])) {
// redOrString is probably alphabetic characters defining the colour
if (!G4Colour::GetColour(redOrString, colour)) {
// Not a recognised string
if (verbosity >= G4VisManager::warnings) {
G4cout << "WARNING: Colour \"" << redOrString
<< "\" not found. Defaulting to " << colour
<< G4endl;
}
return;
} else {
// It was a recognised string. Now add opacity.
colour.SetAlpha(opacity);
return;
}
} else {
// redOrString is probably numeric defining the red component
std::istringstream iss(redOrString);
G4double red;
iss >> red;
if (iss.fail()) {
if (verbosity >= G4VisManager::warnings) {
G4cout << "WARNING: String \"" << redOrString
<< "\" cannot be parsed. Defaulting to " << colour
<< G4endl;
}
return;
} else {
colour = G4Colour(red,green,blue,opacity);
return;
}
}
}
void G4VVisCommand::UpdateVisManagerScene
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VisCommandsGeometrySet.cc 98797 2016-08-09 15:12:22Z gcosmo $
// $Id: G4VisCommandsGeometrySet.cc 104123 2017-05-11 13:51:32Z gcosmo $
// /vis/geometry commands - John Allison 31st January 2006
@@ -36,7 +36,6 @@
#include "G4UImanager.hh"
#include <sstream>
#include <cctype>
void G4VVisCommandGeometrySet::Set
(G4String requestedName,
@@ -155,21 +154,7 @@ void G4VisCommandGeometrySetColour::SetNewValue
std::istringstream iss(newValue);
iss >> name >> requestedDepth >> redOrString >> green >> blue >> opacity;
G4Colour colour(1,1,1,1); // Default white and opaque.
const size_t iPos0 = 0;
if (std::isalpha(redOrString[iPos0])) {
if (!G4Colour::GetColour(redOrString, colour)) {
if (fpVisManager->GetVerbosity() >= G4VisManager::warnings) {
G4cout << "WARNING: Colour \"" << redOrString
<< "\" not found. Defaulting to white and opaque."
<< G4endl;
}
}
} else {
colour = G4Colour(G4UIcommand::ConvertToDouble(redOrString), green, blue);
}
colour = G4Colour
(colour.GetRed(), colour.GetGreen(), colour.GetBlue(), opacity);
ConvertToColour(colour, redOrString, green, blue, opacity);
G4VisCommandGeometrySetColourFunction setColour(colour);
Set(name, setColour, requestedDepth);
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VisCommandsSceneAdd.cc 98766 2016-08-09 14:17:17Z gcosmo $
// $Id: G4VisCommandsSceneAdd.cc 104163 2017-05-15 06:52:42Z gcosmo $
// /vis/scene/add commands - John Allison 9th August 1998
#include "G4VisCommandsSceneAdd.hh"
@@ -36,6 +36,7 @@
#include "G4ModelingParameters.hh"
#include "G4HitsModel.hh"
#include "G4DigiModel.hh"
#include "G4GPSModel.hh"
#include "G4MagneticFieldModel.hh"
#include "G4PSHitsModel.hh"
#include "G4TrajectoriesModel.hh"
@@ -77,6 +78,7 @@
#include "G4UnitsTable.hh"
#include "G4PhysicalConstants.hh"
#include "G4SystemOfUnits.hh"
#include "G4GeneralParticleSourceData.hh"
#include <sstream>
@@ -151,7 +153,8 @@ void G4VisCommandSceneAddArrow::SetNewValue (G4UIcommand*, G4String newValue)
G4VModel* model = new G4ArrowModel
(x1, y1, z1, x2, y2, z2,
arrowWidth, fCurrentColour, newValue);
arrowWidth, fCurrentColour, newValue,
fCurrentArrow3DLineSegmentsPerCircle);
const G4String& currentSceneName = pScene -> GetName ();
G4bool successful = pScene -> AddRunDurationModel (model, warn);
@@ -515,7 +518,7 @@ void G4VisCommandSceneAddDigis::SetNewValue (G4UIcommand*, G4String) {
return;
}
G4DigiModel* model = new G4DigiModel;
G4VModel* model = new G4DigiModel;
const G4String& currentSceneName = pScene -> GetName ();
G4bool successful = pScene -> AddEndOfEventModel (model, warn);
if (successful) {
@@ -787,7 +790,7 @@ void G4VisCommandSceneAddExtent::Extent::operator()
G4VisCommandSceneAddFrame::G4VisCommandSceneAddFrame () {
fpCommand = new G4UIcommand("/vis/scene/add/frame", this);
fpCommand -> SetGuidance ("Adds frame to current scene.");
fpCommand -> SetGuidance ("Add frame to current scene.");
G4bool omitable;
G4UIparameter* parameter;
parameter = new G4UIparameter ("size", 'd', omitable = true);
@@ -859,6 +862,75 @@ void G4VisCommandSceneAddFrame::Frame::operator()
sceneHandler.EndPrimitives2D();
}
////////////// /vis/scene/add/gps ///////////////////////////////////////
G4VisCommandSceneAddGPS::G4VisCommandSceneAddGPS () {
G4bool omitable;
G4UIparameter* parameter;
fpCommand = new G4UIcommand ("/vis/scene/add/gps", this);
fpCommand -> SetGuidance
("A representation of the source(s) of the General Particle Source"
"\nwill be added to current scene and drawn, if applicable.");
fpCommand->SetGuidance(ConvertToColourGuidance());
fpCommand->SetGuidance("Default: red and transparent.");
parameter = new G4UIparameter("red_or_string", 's', omitable = true);
parameter -> SetDefaultValue ("1.");
fpCommand -> SetParameter (parameter);
parameter = new G4UIparameter("green", 'd', omitable = true);
parameter -> SetDefaultValue (0.);
fpCommand -> SetParameter (parameter);
parameter = new G4UIparameter ("blue", 'd', omitable = true);
parameter -> SetDefaultValue (0.);
fpCommand -> SetParameter (parameter);
parameter = new G4UIparameter ("opacity", 'd', omitable = true);
parameter -> SetDefaultValue (0.3);
fpCommand -> SetParameter (parameter);
}
G4VisCommandSceneAddGPS::~G4VisCommandSceneAddGPS () {
delete fpCommand;
}
G4String G4VisCommandSceneAddGPS::GetCurrentValue (G4UIcommand*) {
return "";
}
void G4VisCommandSceneAddGPS::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;
}
G4String redOrString;
G4double green, blue, opacity;
std::istringstream iss(newValue);
iss >> redOrString >> green >> blue >> opacity;
G4Colour colour(1.,0.,0.,0.3); // Default red and transparent.
ConvertToColour(colour, redOrString, green, blue, opacity);
G4VModel* model = new G4GPSModel(colour);
const G4String& currentSceneName = pScene -> GetName ();
G4bool successful = pScene -> AddRunDurationModel (model, warn);
if (successful) {
if (verbosity >= G4VisManager::confirmations) {
G4cout <<
"A representation of the source(s) of the General Particle Source will be drawn"
"\n in colour " << colour << " for scene \""
<< currentSceneName << "\" if applicable."
<< G4endl;
}
}
else G4VisCommandsSceneAddUnsuccessful(verbosity);
UpdateVisManagerScene (currentSceneName);
}
////////////// /vis/scene/add/hits ///////////////////////////////////////
G4VisCommandSceneAddHits::G4VisCommandSceneAddHits () {
@@ -890,7 +962,7 @@ void G4VisCommandSceneAddHits::SetNewValue (G4UIcommand*, G4String) {
return;
}
G4HitsModel* model = new G4HitsModel;
G4VModel* model = new G4HitsModel;
const G4String& currentSceneName = pScene -> GetName ();
G4bool successful = pScene -> AddEndOfEventModel (model, warn);
if (successful) {
@@ -1745,7 +1817,7 @@ G4VisCommandSceneAddMagneticField::G4VisCommandSceneAddMagneticField () {
"\nthe default number of data points, so try reducing to 2 or 3, e.g:"
"\n /vis/scene/add/magneticField 3"
"\nor, if only a small part of the scene has a field:"
"\n /vis/scene/add/magneticField 50 # or more");
"\n /vis/scene/add/magneticField 50 or more");
fpCommand -> SetGuidance
("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"
@@ -1791,8 +1863,9 @@ void G4VisCommandSceneAddMagneticField::SetNewValue
if (representation == "lightArrow") {
modelRepresentation = G4MagneticFieldModel::lightArrow;
}
G4MagneticFieldModel* model =
new G4MagneticFieldModel(nDataPointsPerHalfScene,modelRepresentation);
G4VModel* model =
new G4MagneticFieldModel(nDataPointsPerHalfScene,modelRepresentation,
fCurrentArrow3DLineSegmentsPerCircle);
const G4String& currentSceneName = pScene -> GetName ();
G4bool successful = pScene -> AddRunDurationModel (model, warn);
if (successful) {
@@ -1850,7 +1923,7 @@ void G4VisCommandSceneAddPSHits::SetNewValue
return;
}
G4PSHitsModel* model = new G4PSHitsModel(newValue);
G4VModel* model = new G4PSHitsModel(newValue);
const G4String& currentSceneName = pScene -> GetName ();
G4bool successful = pScene -> AddEndOfRunModel (model, warn);
if (successful) {
@@ -2553,7 +2626,7 @@ void G4VisCommandSceneAddTrajectories::SetNewValue (G4UIcommand*,
}
}
G4TrajectoriesModel* model = new G4TrajectoriesModel();
G4VModel* model = new G4TrajectoriesModel();
const G4String& currentSceneName = pScene -> GetName ();
pScene -> AddEndOfEventModel (model, warn);
@@ -32,11 +32,50 @@
#include "G4VisCommandsSet.hh"
#include "G4UIcommand.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4UIcmdWithADouble.hh"
#include "G4UIcmdWithAString.hh"
#include <cctype>
#include <sstream>
////////////// /vis/set/arrow3DLineSegmentsPerCircle ////////////////////////////////////
G4VisCommandSetArrow3DLineSegmentsPerCircle::G4VisCommandSetArrow3DLineSegmentsPerCircle ()
{
G4bool omitable;
fpCommand = new G4UIcmdWithAnInteger("/vis/set/arrow3DLineSegmentsPerCircle", this);
fpCommand->SetGuidance
("Defines number of line segments per circle for drawing 3D arrows"
" for future \"/vis/scene/add/\" commands.");
fpCommand->SetParameterName ("number", omitable = true);
fpCommand->SetDefaultValue (6);
fpCommand->SetRange("number >= 3");
}
G4VisCommandSetArrow3DLineSegmentsPerCircle::~G4VisCommandSetArrow3DLineSegmentsPerCircle ()
{
delete fpCommand;
}
G4String G4VisCommandSetArrow3DLineSegmentsPerCircle::GetCurrentValue (G4UIcommand*)
{
return G4String();
}
void G4VisCommandSetArrow3DLineSegmentsPerCircle::SetNewValue (G4UIcommand*, G4String newValue)
{
G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
fCurrentArrow3DLineSegmentsPerCircle = fpCommand->GetNewIntValue(newValue);
if (verbosity >= G4VisManager::confirmations) {
G4cout <<
"Number of line segments per circle for drawing 3D arrows for future"
"\n \"/vis/scene/add/\" commands has been set to "
<< fCurrentArrow3DLineSegmentsPerCircle
<< G4endl;
}
}
////////////// /vis/set/colour ////////////////////////////////////
G4VisCommandSetColour::G4VisCommandSetColour ()
@@ -47,6 +86,7 @@ G4VisCommandSetColour::G4VisCommandSetColour ()
("Defines colour and opacity for future \"/vis/scene/add/\" commands.");
fpCommand->SetGuidance
("(Except \"/vis/scene/add/text\" commands - see \"/vis/set/textColour\".)");
fpCommand->SetGuidance(ConvertToColourGuidance());
fpCommand->SetGuidance("Default: white and opaque.");
G4UIparameter* parameter;
parameter = new G4UIparameter ("red", 's', omitable = true);
@@ -85,22 +125,7 @@ void G4VisCommandSetColour::SetNewValue (G4UIcommand*, G4String newValue)
std::istringstream iss(newValue);
iss >> redOrString >> green >> blue >> opacity;
G4Colour colour(1,1,1,1); // Default white and opaque.
if (std::isalpha(redOrString(0))) {
if (!G4Colour::GetColour(redOrString, colour)) {
if (verbosity >= G4VisManager::warnings) {
G4cout << "WARNING: Colour \"" << redOrString
<< "\" not found. Defaulting to white and opaque."
<< G4endl;
}
}
} else {
colour = G4Colour
(G4UIcommand::ConvertToDouble(redOrString), green, blue);
}
// Add opacity
fCurrentColour = G4Colour
(colour.GetRed(), colour.GetGreen(), colour.GetBlue(), opacity);
ConvertToColour(fCurrentColour, redOrString, green, blue, opacity);
if (verbosity >= G4VisManager::confirmations) {
G4cout <<
@@ -156,6 +181,7 @@ G4VisCommandSetTextColour::G4VisCommandSetTextColour ()
fpCommand = new G4UIcommand("/vis/set/textColour", this);
fpCommand->SetGuidance
("Defines colour and opacity for future \"/vis/scene/add/text\" commands.");
fpCommand->SetGuidance(ConvertToColourGuidance());
fpCommand->SetGuidance("Default: blue and opaque.");
G4UIparameter* parameter;
parameter = new G4UIparameter ("red", 's', omitable = true);
@@ -194,22 +220,7 @@ void G4VisCommandSetTextColour::SetNewValue (G4UIcommand*, G4String newValue)
std::istringstream iss(newValue);
iss >> redOrString >> green >> blue >> opacity;
G4Colour colour(0,0,1,1); // Default blue and opaque.
if (std::isalpha(redOrString(0))) {
if (!G4Colour::GetColour(redOrString, colour)) {
if (verbosity >= G4VisManager::warnings) {
G4cout << "WARNING: Text colour \"" << redOrString
<< "\" not found. Defaulting to blue and opaque."
<< G4endl;
}
}
} else {
colour = G4Colour
(G4UIcommand::ConvertToDouble(redOrString), green, blue);
}
// Add opacity
fCurrentTextColour = G4Colour
(colour.GetRed(), colour.GetGreen(), colour.GetBlue(), opacity);
ConvertToColour(fCurrentTextColour, redOrString, green, blue, opacity);
if (verbosity >= G4VisManager::confirmations) {
G4cout <<
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VisCommandsTouchableSet.cc 99418 2016-09-21 09:18:42Z gcosmo $
// $Id: G4VisCommandsTouchableSet.cc 104163 2017-05-15 06:52:42Z gcosmo $
// /vis/touchable/set commands - John Allison 8th October 2012
@@ -38,7 +38,6 @@
#include "G4UIcmdWithAString.hh"
#include <sstream>
#include <cctype>
////////////// /vis/touchable/set/colour ///////////////////////////////////////
@@ -52,9 +51,7 @@ G4VisCommandsTouchableSet::G4VisCommandsTouchableSet()
fpCommandSetColour->SetGuidance("Set colour of current touchable.");
fpCommandSetColour->SetGuidance
("Use \"/vis/set/touchable\" to set current touchable.");
fpCommandSetColour->SetGuidance
("If \"red\" is a string understood by the vis system it will be taken."
"\n Otherwise the values of \red\", \"green\", etc., are used.");
fpCommandSetColour->SetGuidance(ConvertToColourGuidance());
parameter = new G4UIparameter("red", 's', omitable = true);
parameter->SetDefaultValue("1.");
fpCommandSetColour->SetParameter(parameter);
@@ -184,21 +181,7 @@ void G4VisCommandsTouchableSet::SetNewValue
std::istringstream iss(newValue);
iss >> redOrString >> green >> blue >> opacity;
G4Colour colour(1,1,1,1); // Default white and opaque.
const size_t iPos0 = 0;
if (std::isalpha(redOrString[iPos0])) {
if (!G4Colour::GetColour(redOrString, colour)) {
if (fpVisManager->GetVerbosity() >= G4VisManager::warnings) {
G4cout << "WARNING: Colour \"" << redOrString
<< "\" not found. Defaulting to white and opaque."
<< G4endl;
}
}
} else {
colour = G4Colour(G4UIcommand::ConvertToDouble(redOrString), green, blue);
}
colour = G4Colour
(colour.GetRed(), colour.GetGreen(), colour.GetBlue(), opacity);
ConvertToColour(colour, redOrString, green, blue, opacity);
workingVisAtts.SetColour(colour);
workingVP.AddVisAttributesModifier
(G4ModelingParameters::VisAttributesModifier
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VisCommandsViewer.cc 102575 2017-02-09 09:07:12Z gcosmo $
// $Id: G4VisCommandsViewer.cc 104163 2017-05-15 06:52:42Z gcosmo $
// /vis/viewer commands - John Allison 25th October 1998
@@ -567,8 +567,8 @@ G4VisCommandViewerCopyViewFrom::G4VisCommandViewerCopyViewFrom () {
fpCommand -> SetGuidance
("Copy the camera-specific parameters from the specified viewer.");
fpCommand -> SetGuidance
("Note: To copy scene modifications - style, etc. - please use"
"\n\"/vis/viewer/set/all\"");
("Note: To copy ALL view parameters, including scene modifications,"
"\nuse \"/vis/viewer/set/all\"");
fpCommand -> SetParameterName ("from-viewer-name", omitable = false);
}
@@ -1174,8 +1174,11 @@ void G4VisCommandViewerInterpolate::SetNewValue (G4UIcommand*, G4String newValue
currentViewer->SetViewParameters(*vp);
currentViewer->RefreshView();
if (exportString == "export" &&
currentViewer->GetName().contains("OpenGL"))
currentViewer->GetName().contains("OpenGL")) {
uiManager->ApplyCommand("/vis/ogl/export");
}
// File-writing viewers need to close the file
currentViewer->ShowView();
#ifdef G4VIS_USE_STD11
if (waitTimePerPointmilliseconds > 0)
std::this_thread::sleep_for(std::chrono::milliseconds(waitTimePerPointmilliseconds));
@@ -1684,6 +1687,7 @@ void G4VisCommandViewerSave::SetNewValue (G4UIcommand*, G4String newValue) {
const G4Point3D& stp = currentScene->GetStandardTargetPoint();
G4String filename = newValue;
if (newValue.length() == 0) {
// Null filename - generate a filename
const G4int maxNoOfFiles = 100;
@@ -1707,7 +1711,11 @@ void G4VisCommandViewerSave::SetNewValue (G4UIcommand*, G4String newValue) {
// Write to standard output
WriteCommands(G4cout,vp,stp);
} else {
// Write to file
// Write to file - but add extension if not prescribed
if (!filename.contains('.')) {
// No extension supplied - add .g4view
filename += ".g4view";
}
std::ofstream ofs(filename);
if (!ofs) {
if (verbosity >= G4VisManager::errors) {
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VisCommandsViewerSet.cc 101035 2016-11-04 08:48:17Z gcosmo $
// $Id: G4VisCommandsViewerSet.cc 104163 2017-05-15 06:52:42Z gcosmo $
// /vis/viewer/set commands - John Allison 16th May 2000
@@ -42,7 +42,6 @@
#include "G4SystemOfUnits.hh"
#include <sstream>
#include <cctype>
G4VisCommandsViewerSet::G4VisCommandsViewerSet ():
fLightsVector (G4ThreeVector(1.,1.,1.)),
@@ -56,8 +55,11 @@ G4VisCommandsViewerSet::G4VisCommandsViewerSet ():
fpCommandAll->SetGuidance
("Copies view parameters.");
fpCommandAll->SetGuidance
("Copies view parameters (except the autoRefresh status) from"
"\nfrom-viewer to current viewer.");
("Copies ALL view parameters (except the autoRefresh status) from"
"\nfrom-viewer to current viewer. You may need \"/vis/viewer/rebuild\".");
fpCommandAll->SetGuidance
("Note: to copy only the camera-specific parameters use"
"\n\"/vis/viewer/copyfrom\".");
fpCommandAll->SetParameterName ("from-viewer-name",omitable = false);
fpCommandAutoRefresh = new G4UIcmdWithABool
@@ -82,12 +84,7 @@ G4VisCommandsViewerSet::G4VisCommandsViewerSet ():
("/vis/viewer/set/background",this);
fpCommandBackground->SetGuidance
("Set background colour and transparency (default black and opaque).");
fpCommandBackground->SetGuidance
("Accepts (a) RGB triplet. e.g., \".3 .4 .5\", or"
"\n(b) string such as \"white\", \"black\", \"grey\", \"red\"..."
"\n(c) an additional number for opacity, e.g., \".3 .4 .5 .6\""
"\n or \"grey ! ! .6\" (note \"!\"'s for unused green and blue parameters),"
"\n e.g. \"! ! ! 0.\" for a transparent background.");
fpCommandBackground->SetGuidance(ConvertToColourGuidance());
parameter = new G4UIparameter("red_or_string", 's', omitable = true);
parameter -> SetDefaultValue ("0.");
fpCommandBackground -> SetParameter (parameter);
@@ -146,12 +143,7 @@ G4VisCommandsViewerSet::G4VisCommandsViewerSet ():
("/vis/viewer/set/defaultColour",this);
fpCommandDefaultColour->SetGuidance
("Set defaultColour colour and transparency (default white and opaque).");
fpCommandDefaultColour->SetGuidance
("Accepts (a) RGB triplet. e.g., \".3 .4 .5\", or"
"\n(b) string such as \"white\", \"black\", \"grey\", \"red\"..."
"\n(c) an additional number for opacity, e.g., \".3 .4 .5 .6\""
"\n or \"grey ! ! .6\" (note \"!\"'s for unused green and blue parameters),"
"\n e.g. \"! ! ! 0.\" for a transparent colour.");
fpCommandDefaultColour->SetGuidance(ConvertToColourGuidance());
parameter = new G4UIparameter("red_or_string", 's', omitable = true);
parameter -> SetDefaultValue ("1.");
fpCommandDefaultColour -> SetParameter (parameter);
@@ -168,18 +160,13 @@ G4VisCommandsViewerSet::G4VisCommandsViewerSet ():
fpCommandDefaultTextColour = new G4UIcommand
("/vis/viewer/set/defaultTextColour",this);
fpCommandDefaultTextColour->SetGuidance
("Set defaultTextColour colour and transparency (default white and opaque).");
fpCommandDefaultTextColour->SetGuidance
("Accepts (a) RGB triplet. e.g., \".3 .4 .5\", or"
"\n(b) string such as \"white\", \"black\", \"grey\", \"red\"..."
"\n(c) an additional number for opacity, e.g., \".3 .4 .5 .6\""
"\n or \"grey ! ! .6\" (note \"!\"'s for unused green and blue parameters),"
"\n e.g. \"! ! ! 0.\" for a transparent colour.");
("Set defaultTextColour colour and transparency (default blue and opaque).");
fpCommandDefaultTextColour->SetGuidance(ConvertToColourGuidance());
parameter = new G4UIparameter("red_or_string", 's', omitable = true);
parameter -> SetDefaultValue ("1.");
parameter -> SetDefaultValue ("0.");
fpCommandDefaultTextColour -> SetParameter (parameter);
parameter = new G4UIparameter("green", 'd', omitable = true);
parameter -> SetDefaultValue (1.);
parameter -> SetDefaultValue (0.);
fpCommandDefaultTextColour -> SetParameter (parameter);
parameter = new G4UIparameter ("blue", 'd', omitable = true);
parameter -> SetDefaultValue (1.);
@@ -549,6 +536,10 @@ void G4VisCommandsViewerSet::SetNewValue
<< "\"."
<< G4endl;
}
if (verbosity >= G4VisManager::warnings) {
G4cout << "You may need \"/vis/viewer/rebuild\"."
<< G4endl;
}
}
else if (command == fpCommandAutoRefresh) {
@@ -593,20 +584,7 @@ void G4VisCommandsViewerSet::SetNewValue
std::istringstream iss(newValue);
iss >> redOrString >> green >> blue >> opacity;
G4Colour colour(0.,0.,0.); // Default black and opaque.
const size_t iPos0 = 0;
if (std::isalpha(redOrString[iPos0])) {
if (!G4Colour::GetColour(redOrString, colour)) {
if (verbosity >= G4VisManager::warnings) {
G4cout << "WARNING: Text colour \"" << redOrString
<< "\" not found. Defaulting to black and opaque."
<< G4endl;
}
}
} else {
colour = G4Colour(G4UIcommand::ConvertTo3Vector(newValue));
}
// Add opacity
colour = G4Colour(colour.GetRed(), colour.GetGreen(), colour.GetBlue(), opacity);
ConvertToColour(colour, redOrString, green, blue, opacity);
vp.SetBackgroundColour(colour);
if (verbosity >= G4VisManager::confirmations) {
G4cout << "Background colour "
@@ -710,20 +688,7 @@ void G4VisCommandsViewerSet::SetNewValue
std::istringstream iss(newValue);
iss >> redOrString >> green >> blue >> opacity;
G4Colour colour(1.,1.,1.); // Default white and opaque.
const size_t iPos0 = 0;
if (std::isalpha(redOrString[iPos0])) {
if (!G4Colour::GetColour(redOrString, colour)) {
if (verbosity >= G4VisManager::warnings) {
G4cout << "WARNING: Text colour \"" << redOrString
<< "\" not found. Defaulting to white and opaque."
<< G4endl;
}
}
} else {
colour = G4Colour(G4UIcommand::ConvertTo3Vector(newValue));
}
// Add opacity
colour = G4Colour(colour.GetRed(), colour.GetGreen(), colour.GetBlue(), opacity);
ConvertToColour(colour, redOrString, green, blue, opacity);
G4VisAttributes va = vp.GetDefaultVisAttributes();
va.SetColour(colour);
vp.SetDefaultVisAttributes(va);
@@ -741,20 +706,7 @@ void G4VisCommandsViewerSet::SetNewValue
std::istringstream iss(newValue);
iss >> redOrString >> green >> blue >> opacity;
G4Colour colour(1.,1.,1.); // Default white and opaque.
const size_t iPos0 = 0;
if (std::isalpha(redOrString[iPos0])) {
if (!G4Colour::GetColour(redOrString, colour)) {
if (verbosity >= G4VisManager::warnings) {
G4cout << "WARNING: Text colour \"" << redOrString
<< "\" not found. Defaulting to white and opaque."
<< G4endl;
}
}
} else {
colour = G4Colour(G4UIcommand::ConvertTo3Vector(newValue));
}
// Add opacity
colour = G4Colour(colour.GetRed(), colour.GetGreen(), colour.GetBlue(), opacity);
ConvertToColour(colour, redOrString, green, blue, opacity);
G4VisAttributes va = vp.GetDefaultTextVisAttributes();
va.SetColour(colour);
vp.SetDefaultTextVisAttributes(va);
@@ -906,15 +858,16 @@ void G4VisCommandsViewerSet::SetNewValue
else if (command == fpCommandLightsThetaPhi) {
G4double theta, phi;
ConvertToDoublePair(newValue, theta, phi);
G4double x = std::sin (theta) * std::cos (phi);
G4double y = std::sin (theta) * std::sin (phi);
G4double z = std::cos (theta);
fLightsVector = G4ThreeVector (x, y, z);
vp.SetLightpointDirection(fLightsVector);
if (verbosity >= G4VisManager::confirmations) {
G4cout << "Lights direction set to "
<< vp.GetLightpointDirection() << G4endl;
if (ConvertToDoublePair(newValue, theta, phi)) {
G4double x = std::sin (theta) * std::cos (phi);
G4double y = std::sin (theta) * std::sin (phi);
G4double z = std::cos (theta);
fLightsVector = G4ThreeVector (x, y, z);
vp.SetLightpointDirection(fLightsVector);
if (verbosity >= G4VisManager::confirmations) {
G4cout << "Lights direction set to "
<< vp.GetLightpointDirection() << G4endl;
}
}
}
@@ -1129,14 +1082,15 @@ void G4VisCommandsViewerSet::SetNewValue
else if (command == fpCommandUpThetaPhi) {
G4double theta, phi;
ConvertToDoublePair(newValue, theta, phi);
G4double x = std::sin (theta) * std::cos (phi);
G4double y = std::sin (theta) * std::sin (phi);
G4double z = std::cos (theta);
fUpVector = G4ThreeVector (x, y, z);
vp.SetUpVector(fUpVector);
if (verbosity >= G4VisManager::confirmations) {
G4cout << "Up direction set to " << vp.GetUpVector() << G4endl;
if (ConvertToDoublePair(newValue, theta, phi)) {
G4double x = std::sin (theta) * std::cos (phi);
G4double y = std::sin (theta) * std::sin (phi);
G4double z = std::cos (theta);
fUpVector = G4ThreeVector (x, y, z);
vp.SetUpVector(fUpVector);
if (verbosity >= G4VisManager::confirmations) {
G4cout << "Up direction set to " << vp.GetUpVector() << G4endl;
}
}
}
@@ -1150,18 +1104,19 @@ void G4VisCommandsViewerSet::SetNewValue
else if (command == fpCommandViewpointThetaPhi) {
G4double theta, phi;
ConvertToDoublePair(newValue, theta, phi);
G4double x = std::sin (theta) * std::cos (phi);
G4double y = std::sin (theta) * std::sin (phi);
G4double z = std::cos (theta);
fViewpointVector = G4ThreeVector (x, y, z);
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;
if (ConvertToDoublePair(newValue, theta, phi)) {
G4double x = std::sin (theta) * std::cos (phi);
G4double y = std::sin (theta) * std::sin (phi);
G4double z = std::cos (theta);
fViewpointVector = G4ThreeVector (x, y, z);
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;
}
}
}
}
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VisManager.cc 102575 2017-02-09 09:07:12Z gcosmo $
// $Id: G4VisManager.cc 103926 2017-05-03 13:43:27Z gcosmo $
//
//
// GEANT4 Visualization Manager - John Allison 02/Jan/1996.
@@ -414,6 +414,7 @@ void G4VisManager::RegisterMessengers () {
directory -> SetGuidance
("Set quantities for use in future commands where appropriate.");
fDirectoryList.push_back (directory);
RegisterMessenger(new G4VisCommandSetArrow3DLineSegmentsPerCircle);
RegisterMessenger(new G4VisCommandSetColour);
RegisterMessenger(new G4VisCommandSetLineWidth);
RegisterMessenger(new G4VisCommandSetTextColour);
@@ -443,6 +444,7 @@ void G4VisManager::RegisterMessengers () {
RegisterMessenger(new G4VisCommandSceneAddEventID);
RegisterMessenger(new G4VisCommandSceneAddExtent);
RegisterMessenger(new G4VisCommandSceneAddFrame);
RegisterMessenger(new G4VisCommandSceneAddGPS);
RegisterMessenger(new G4VisCommandSceneAddHits);
RegisterMessenger(new G4VisCommandSceneAddLine);
RegisterMessenger(new G4VisCommandSceneAddLine2D);
@@ -1056,7 +1058,7 @@ void G4VisManager::CreateViewer
if (!p) {
if (fVerbosity >= errors) {
G4cerr << "ERROR in G4VisManager::CreateViewer during "
G4cerr << "ERROR in G4VisManager::CreateViewer: null pointer during "
<< fpGraphicsSystem -> GetName ()
<< " viewer creation.\n No action taken."
<< G4endl;
@@ -1068,7 +1070,7 @@ void G4VisManager::CreateViewer
if (fVerbosity >= errors) {
G4cerr << "ERROR in G4VisManager::CreateViewer during "
<< fpGraphicsSystem -> GetName ()
<< " viewer initialisation.\n No action taken."
<< " viewer instantiation.\n No action taken."
<< G4endl;
}
return;
@@ -1081,6 +1083,15 @@ void G4VisManager::CreateViewer
initialvp.SetXGeometryString(XGeometry); //parse string and store parameters
p -> SetViewParameters(initialvp);
p -> Initialise (); // (Viewer itself may change view parameters further.)
if (p -> GetViewId() < 0) {
if (fVerbosity >= errors) {
G4cerr << "ERROR in G4VisManager::CreateViewer during "
<< fpGraphicsSystem -> GetName ()
<< " viewer initialisation.\n No action taken."
<< G4endl;
}
return;
}
fpViewer = p; // Make current.
fpSceneHandler -> AddViewerToList (fpViewer);
@@ -1269,6 +1280,17 @@ void G4VisManager::DispatchToModel(const G4VTrajectory& trajectory)
}
}
void G4VisManager::SetUserAction
(G4VUserVisAction* pVisAction,
const G4VisExtent& extent) {
if (fVerbosity >= warnings) {
G4cout <<
"WARNING: SetUserAction is deprecated. Use RegisterRunDurationUserVisAction."
<< G4endl;
}
RegisterRunDurationUserVisAction("SetUserAction",pVisAction,extent);
}
void G4VisManager::RegisterRunDurationUserVisAction
(const G4String& name,
G4VUserVisAction* pVisAction,