Import Geant4 11.1.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2022-07-01 10:44:02 +02:00
parent b3bf75a2a1
commit c07cea1fe0
2172 changed files with 183300 additions and 123938 deletions
@@ -27,16 +27,17 @@
#include "G4ToolsSGQtGLES.hh"
//
#define G4TOOLSSG_QT_VIEWER_IN_TAB
#ifdef G4TOOLSSG_QT_VIEWER_IN_TAB
#include "G4ToolsSGQtViewer.hh"
#else
#include "G4ToolsSGViewer.hh"
#include <tools/Qt/sg_viewer>
#include <toolx/Qt/sg_viewer>
#endif
#include "G4UIbatch.hh"
#include <tools/argcv>
G4ToolsSGQtGLES::G4ToolsSGQtGLES():
@@ -59,7 +60,7 @@ void G4ToolsSGQtGLES::Initialise() {
char** argv = nullptr;
std::vector<std::string> args;args.push_back("");
tools::new_argcv(args,*argc,argv);
fSGSession = new tools::Qt::session(G4cout,*argc,argv);
fSGSession = new toolx::Qt::session(G4cout,*argc,argv);
if(!fSGSession->is_valid()) {
G4cerr << "G4ToolsSGQtGLES::Initialise : session::is_valid() failed." << G4endl;
delete fSGSession;
@@ -80,7 +81,7 @@ G4VViewer* G4ToolsSGQtGLES::CreateViewer(G4VSceneHandler& a_scene,const G4String
#ifdef G4TOOLSSG_QT_VIEWER_IN_TAB
new G4ToolsSGQtViewer(*fSGSession,(G4ToolsSGSceneHandler&)a_scene,a_name);
#else
new G4ToolsSGViewer<tools::Qt::session,tools::Qt::sg_viewer>(*fSGSession,(G4ToolsSGSceneHandler&)a_scene,a_name);
new G4ToolsSGViewer<toolx::Qt::session,toolx::Qt::sg_viewer>(*fSGSession,(G4ToolsSGSceneHandler&)a_scene,a_name);
#endif
if (pView) {
if (pView->GetViewId() < 0) {
@@ -101,27 +102,27 @@ G4VViewer* G4ToolsSGQtGLES::CreateViewer(G4VSceneHandler& a_scene,const G4String
G4bool G4ToolsSGQtGLES::IsUISessionCompatible () const
{
G4bool isCompatible = false;
// G4UImanager* ui = G4UImanager::GetUIpointer();
// G4UIsession* session = ui->GetSession();
//
// // If session is a batch session, it may be:
// // a) this is a batch job (the user has not instantiated any UI session);
// // b) we are currently processing a UI command, in which case the UI
// // manager creates a temporary batch session and to find out if there is
// // a genuine UI session that the user has instantiated we must drill
// // down through previous sessions to a possible non-batch session.
// while (G4UIbatch* batch = dynamic_cast<G4UIbatch*>(session)) {
// session = batch->GetPreviousSession();
// }
//
// // Qt windows are only appropriate in a Qt session.
// if (session) {
// // If non-zero, this is the originating non-batch session
// // The user has instantiated a UI session...
// if (dynamic_cast<G4UIQt*>(session)) {
// // ...and it's a G4UIQt session, which is OK.
G4UImanager* ui = G4UImanager::GetUIpointer();
G4UIsession* session = ui->GetSession();
// If session is a batch session, it may be:
// a) this is a batch job (the user has not instantiated any UI session);
// b) we are currently processing a UI command, in which case the UI
// manager creates a temporary batch session and to find out if there is
// a genuine UI session that the user has instantiated we must drill
// down through previous sessions to a possible non-batch session.
while (G4UIbatch* batch = dynamic_cast<G4UIbatch*>(session)) {
session = batch->GetPreviousSession();
}
// Qt windows are only appropriate in a Qt session.
if (session) {
// If non-zero, this is the originating non-batch session
// The user has instantiated a UI session...
if (dynamic_cast<G4UIQt*>(session)) {
// ...and it's a G4UIQt session, which is OK.
isCompatible = true;
// }
// }
}
}
return isCompatible;
}
@@ -1,3 +1,28 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
#include "G4ToolsSGQtViewer.hh"
#include "moc_G4ToolsSGQtViewer.cpp"
@@ -36,6 +36,7 @@
#include "G4Square.hh"
#include "G4Polyhedron.hh"
#include "G4Text.hh"
#include "G4Mesh.hh"
#include "G4PlotterManager.hh"
#include <tools/sg/separator>
@@ -45,11 +46,11 @@
#include <tools/sg/atb_vertices>
#include <tools/sg/markers>
#ifdef TOOLS_USE_FREETYPE
#include <tools/sg/text_freetype>
#include <toolx/sg/text_freetype>
#include <tools/sg/strings>
#include <tools/font/lato_regular_ttf>
#include <tools/font/roboto_bold_ttf>
#include <tools/sg/text_freetype_marker>
#include <toolx/sg/text_freetype_marker>
#else
#include <tools/sg/dummy_freetype>
#include <tools/sg/text_hershey_marker>
@@ -80,7 +81,7 @@ G4ToolsSGSceneHandler::G4ToolsSGSceneHandler
//::printf("debug : G4ToolsSGSceneHandler : %lu, %s\n",this,name.c_str());
EstablishBaseNodes();
#if defined(TOOLS_USE_FREETYPE)
fFreetypeNode = new tools::sg::text_freetype();
fFreetypeNode = new toolx::sg::text_freetype();
fFreetypeNode->add_embedded_font(tools::sg::font_lato_regular_ttf(),tools::font::lato_regular_ttf);
fFreetypeNode->add_embedded_font(tools::sg::font_roboto_bold_ttf(),tools::font::roboto_bold_ttf);
#else
@@ -286,15 +287,17 @@ void G4ToolsSGSceneHandler::AddPrimitive (const G4Polymarker& a_polymarker)
float(colour.GetAlpha()));
currentNode->add(mat);}
MarkerSizeType markerSizeType;
G4double markerSize = GetMarkerSize(a_polymarker, markerSizeType);
switch (a_polymarker.GetMarkerType()) {
default:
case G4Polymarker::dots:{
//::printf("debug : GB : Add Markers : +++++++++++++++++++++++++++++++++++++++++++ : dots\n");
tools::sg::draw_style* ds = new tools::sg::draw_style;
ds->style = tools::sg::draw_points;
ds->point_size = 10;
ds->point_size = 1;
currentNode->add(ds);
tools::sg::vertices* vtxs = new tools::sg::vertices;
vtxs->mode = tools::gl::points();
{for (size_t i = 0; i < a_polymarker.size(); ++i) {
@@ -305,7 +308,12 @@ void G4ToolsSGSceneHandler::AddPrimitive (const G4Polymarker& a_polymarker)
case G4Polymarker::circles:{
//::printf("debug : GB : Add Markers : +++++++++++++++++++++++++++++++++++++++++++ : circles\n");
{tools::sg::markers* markers = new tools::sg::markers;
markers->size = 10;
G4double diameter = markerSize; // OK for "screen-size" (the usual case)
if (markerSizeType == G4VSceneHandler::world ) {
const G4double scale = 200.; // Roughly pixels per scene
diameter *= fpScene->GetExtent().GetExtentRadius()/scale;
}
markers->size = diameter;
markers->style = tools::sg::marker_circle_line;
for (size_t i = 0; i < a_polymarker.size(); ++i) {
markers->add(float(a_polymarker[i].x()),float(a_polymarker[i].y()),float(a_polymarker[i].z()));
@@ -315,7 +323,12 @@ void G4ToolsSGSceneHandler::AddPrimitive (const G4Polymarker& a_polymarker)
case G4Polymarker::squares:{
//::printf("debug : GB : Add Markers : +++++++++++++++++++++++++++++++++++++++++++ : square\n");
{tools::sg::markers* markers = new tools::sg::markers;
markers->size = 10;
G4double side = markerSize; // OK for "screen-size" (the usual case)
if (markerSizeType == G4VSceneHandler::world ) {
const G4double scale = 200.; // Roughly pixels per scene
side *= fpScene->GetExtent().GetExtentRadius()/scale;
}
markers->size = side;
markers->style = tools::sg::marker_square_line;
for (size_t i = 0; i < a_polymarker.size(); ++i) {
markers->add(float(a_polymarker[i].x()),float(a_polymarker[i].y()),float(a_polymarker[i].z()));
@@ -371,7 +384,7 @@ void G4ToolsSGSceneHandler::AddPrimitive(const G4Text& a_text)
parentNode->add(mat);}
#ifdef TOOLS_USE_FREETYPE
tools::sg::text_freetype_marker* text = new tools::sg::text_freetype_marker;
toolx::sg::text_freetype_marker* text = new toolx::sg::text_freetype_marker;
text->add_embedded_font(tools::sg::font_lato_regular_ttf(),tools::font::lato_regular_ttf);
text->font = tools::sg::font_lato_regular_ttf();
text->front_face = tools::sg::winding_cw;
@@ -440,11 +453,11 @@ void G4ToolsSGSceneHandler::AddPrimitive(const G4Polyhedron& a_polyhedron)
typedef std::pair<G4Point3D,G4Point3D> Line;
std::vector<Line> lines;
auto insertIfNew = [&lines](const Line& newLine) {
for (const auto& line: lines) {
if ((newLine.first==line.first && newLine.second==line.second) ||
(newLine.first==line.second && newLine.second==line.first))
return;
}
// for (const auto& line: lines) {
// if ((newLine.first==line.first && newLine.second==line.second) ||
// (newLine.first==line.second && newLine.second==line.first))
// return;
// }
lines.push_back(newLine);
};
@@ -570,6 +583,11 @@ void G4ToolsSGSceneHandler::AddPrimitive(const G4Polyhedron& a_polyhedron)
}
}
void G4ToolsSGSceneHandler::AddCompound(const G4Mesh& mesh)
{
StandardSpecialMeshRendering(mesh);
}
//plotting:
inline void SetRegionStyles(tools::xml::styles& a_styles,
tools::sg::plots& a_plots,
@@ -699,7 +717,10 @@ void G4ToolsSGSceneHandler::SetPlotterHistograms(tools::sg::plots& a_plots) {
os << hid;
std::string cmd("/analysis/h1/get ");
cmd += std::string(os.str());
auto keepControlVerbose = UI->GetVerboseLevel();
UI->SetVerboseLevel(0);
G4int status = UI->ApplyCommand(cmd.c_str());
UI->SetVerboseLevel(keepControlVerbose);
if(status==G4UIcommandStatus::fCommandSucceeded) {
G4String hexString = UI->GetCurrentValues("/analysis/h1/get");
if(hexString.size()) {
@@ -710,6 +731,11 @@ void G4ToolsSGSceneHandler::SetPlotterHistograms(tools::sg::plots& a_plots) {
tools::sg::plottable* p = new tools::sg::h1d2plot_cp(*_h);
_plotter->add_plottable(p); //give ownership of p to sg::plotter.
}
} else {
G4cerr <<
"G4ToolsSGSceneHandler::SetPlotterHistograms: cannot get histogram - maybe doesn't exist?"
"\n Maybe this app does not do analysis at all?"
<< G4endl;
}
}
}}
@@ -721,7 +747,10 @@ void G4ToolsSGSceneHandler::SetPlotterHistograms(tools::sg::plots& a_plots) {
os << hid;
std::string cmd("/analysis/h2/get ");
cmd += std::string(os.str());
auto keepControlVerbose = UI->GetVerboseLevel();
UI->SetVerboseLevel(0);
G4int status = UI->ApplyCommand(cmd.c_str());
UI->SetVerboseLevel(keepControlVerbose);
if(status==G4UIcommandStatus::fCommandSucceeded) {
G4String hexString = UI->GetCurrentValues("/analysis/h2/get");
if(hexString.size()) {
@@ -732,6 +761,11 @@ void G4ToolsSGSceneHandler::SetPlotterHistograms(tools::sg::plots& a_plots) {
tools::sg::plottable* p = new tools::sg::h2d2plot_cp(*_h);
_plotter->add_plottable(p); //give ownership of p to sg::plotter.
}
} else {
G4cerr <<
"G4ToolsSGSceneHandler::SetPlotterHistograms: cannot get histogram - maybe doesn't exist?"
"\n Maybe this app does not do analysis at all?"
<< G4endl;
}
}
}}
@@ -813,7 +847,7 @@ void G4ToolsSGSceneHandler::AddPrimitive(const G4Plotter& a_plotter)
}
void G4ToolsSGSceneHandler::Messenger::SetNewValue(G4UIcommand* a_cmd,G4String) {
G4VSceneHandler* pSceneHandler = fpVisManager->GetCurrentSceneHandler();
G4VSceneHandler* pSceneHandler = GetVisManager()->GetCurrentSceneHandler();
if (!pSceneHandler) {
G4cout << "G4ToolsSGSceneHandler::Messenger::SetNewValue: no current sceneHandler. Please create one." << G4endl;
return;
@@ -29,7 +29,7 @@
#include "G4ToolsSGWindowsGLES.hh"
#include "G4ToolsSGViewer.hh"
#include <tools/Windows/sg_viewer>
#include <toolx/Windows/sg_viewer>
G4ToolsSGWindowsGLES::G4ToolsSGWindowsGLES():
parent
@@ -47,7 +47,7 @@ G4ToolsSGWindowsGLES::~G4ToolsSGWindowsGLES() {
void G4ToolsSGWindowsGLES::Initialise() {
if(fSGSession) return; //done.
fSGSession = new tools::Windows::session(G4cout);
fSGSession = new toolx::Windows::session(G4cout);
if(!fSGSession->is_valid()) {
G4cerr << "G4ToolsSGWindowsGLES::Initialise : session::is_valid() failed." << G4endl;
delete fSGSession;
@@ -65,7 +65,7 @@ G4VViewer* G4ToolsSGWindowsGLES::CreateViewer(G4VSceneHandler& a_scene,const G4S
if(!fSGSession) Initialise();
if(!fSGSession) return nullptr;
G4VViewer* pView =
new G4ToolsSGViewer<tools::Windows::session,tools::Windows::sg_viewer>(*fSGSession,(G4ToolsSGSceneHandler&)a_scene,a_name);
new G4ToolsSGViewer<toolx::Windows::session,toolx::Windows::sg_viewer>(*fSGSession,(G4ToolsSGSceneHandler&)a_scene,a_name);
if (pView) {
if (pView->GetViewId() < 0) {
G4cerr <<
@@ -29,7 +29,7 @@
#include "G4ToolsSGViewer.hh"
#include <tools/X11/sg_viewer>
#include <toolx/X11/sg_viewer>
G4ToolsSGX11GLES::G4ToolsSGX11GLES():
parent
@@ -47,7 +47,7 @@ G4ToolsSGX11GLES::~G4ToolsSGX11GLES() {
void G4ToolsSGX11GLES::Initialise() {
if(fSGSession) return; //done.
fSGSession = new tools::X11::session(G4cout);
fSGSession = new toolx::X11::session(G4cout);
if(!fSGSession->is_valid()) {
G4cerr << "G4ToolsSGX11GLES::Initialise : session::is_valid() failed." << G4endl;
delete fSGSession;
@@ -65,7 +65,7 @@ G4VViewer* G4ToolsSGX11GLES::CreateViewer(G4VSceneHandler& a_scene,const G4Strin
if(!fSGSession) Initialise();
if(!fSGSession) return nullptr;
G4VViewer* pView =
new G4ToolsSGViewer<tools::X11::session,tools::X11::sg_viewer>
new G4ToolsSGViewer<toolx::X11::session,toolx::X11::sg_viewer>
(*fSGSession,(G4ToolsSGSceneHandler&)a_scene,a_name);
if (pView) {
if (pView->GetViewId() < 0) {
@@ -28,12 +28,12 @@
#include "G4ToolsSGXtGLES.hh"
#include "G4ToolsSGViewer.hh"
#include <tools/Xt/sg_viewer>
#include <toolx/Xt/sg_viewer>
#include "G4Xt.hh"
class session : public tools::Xt::session {
typedef tools::Xt::session parent;
class session : public toolx::Xt::session {
typedef toolx::Xt::session parent;
public:
session(std::ostream& a_out,int a_argc,char** a_argv)
:parent(a_out,a_argc,a_argv)
@@ -88,7 +88,7 @@ G4VViewer* G4ToolsSGXtGLES::CreateViewer(G4VSceneHandler& a_scene,const G4String
if(!fSGSession) Initialise();
if(!fSGSession) return nullptr;
G4VViewer* pView =
new G4ToolsSGViewer<tools::Xt::session,tools::Xt::sg_viewer>(*fSGSession,(G4ToolsSGSceneHandler&)a_scene,a_name);
new G4ToolsSGViewer<toolx::Xt::session,toolx::Xt::sg_viewer>(*fSGSession,(G4ToolsSGSceneHandler&)a_scene,a_name);
if (pView) {
if (pView->GetViewId() < 0) {
G4cerr <<