Import Geant4 11.4.0 source tree

This commit is contained in:
Gabriele Cosmo
2025-12-05 08:54:02 +01:00
parent a499fb82e9
commit b4a16de652
6484 changed files with 232674 additions and 221097 deletions
+31
View File
@@ -5,6 +5,37 @@ which **must** added in reverse chronological order (newest at the top).
It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2025-10-24 Guy Barrand (vis_toolssg-V11-03-12)
- implementation/sources.cmake: handle "-DTOOLS_USE_GL_VERSION_3_2" in case "GEANT4_USE_VTK".
## 2025-10-13 Guy Barrand (vis_toolssg-V11-03-11)
- G4ToolsSceneHandler.cc/AddPrimitive(G4Polymarker):
- G4Polymarker::dots: handle "dot smoothing".
- G4Polymarker::circles, squares: by default, have them "filled" instead of "line" to match OGLI/OGLS style.
- G4ToolsSceneHandler.cc/ClearTransientStore: have a "viewer EmitWindowRender()" to fix a "missing refresh" with
extended/runAndEvent/RE03/run.mac.
- G4ToolsSGViewer.hh: have a G4ToolsSG_viewer base class with a virtual EmitWindowRender() method
to be used in G4ToolsSceneHander::ClearTransientStore.
- G4ToolsSceneHandler.cc: two corrections to quiet Coverity.
## 2025-10-01 John Allison (vis_toolssg-V11-03-10)
- G4ToolsSGViewer.hh:
- CompareForKernelVisit():
- Include dotsSize and dotsSmooth for decision on kernel visit.
- G4ToolsSGSceneHandler.cc:
- AddPrimitive(G4Polymarker&):
- Respect marker size for dots.
## 2025-08-12 Guy Barrand (vis_toolssg-V11-03-09)
- G4ToolsSGViewer.hh: in CreateSG(), for 3D scenes, have a tools::sg::shade_model node set to "smooth" so that
TSG_GLES have the same "/vis/viewer/set/style surface" rendering as in OGLI/OGLS. (Then issuing Gouraud shading
on surfaces by default, as for OGLI/OGLS). Note that for TSG_ZB, the rendering of surfaces will be still "flat",
since we have not (yet) Gouraud shading on triangles for this TSG sub driver.
## 2025-06-18 Andrea Barresi (vis_toolssg-V11-03-08)
- G4ToolsSGViewer.hh:
- Modified wheel_rotate function to call ZoomFromMouseWheel of G4VViewer
- Added method GetSceneNearWidth
## 2025-06-17 Guy Barrand (vis_toolssg-V11-03-07)
- G4ToolsSGViewer.hh: in mouse_move(), use the event.shift_modifier() method, introduced
@@ -41,6 +41,7 @@
#include <tools/sg/separator>
#include <tools/sg/ortho>
#include <tools/sg/perspective>
#include <tools/sg/shade_model>
#include <tools/sg/torche>
#include <tools/sg/blend>
#include <tools/sg/noderef>
@@ -49,9 +50,21 @@
#include <tools/tokenize>
#include <tools/sg/write_paper>
class G4ToolsSG_viewer {
public:
G4ToolsSG_viewer() {}
virtual ~G4ToolsSG_viewer() {}
protected:
G4ToolsSG_viewer(const G4ToolsSG_viewer&){}
G4ToolsSG_viewer& operator=(const G4ToolsSG_viewer&){return *this;}
public:
virtual void EmitWindowRender() {}
};
template <class SG_SESSION,class SG_VIEWER>
class G4ToolsSGViewer : public G4VViewer, tools::sg::device_interactor {
class G4ToolsSGViewer : public G4VViewer, public G4ToolsSG_viewer, tools::sg::device_interactor {
typedef G4VViewer parent;
typedef G4ToolsSG_viewer parent_viewer;
typedef tools::sg::device_interactor parent_interactor;
public: //tools::sg::device_interactor interface.
virtual void key_press(const tools::sg::key_down_event&) {}
@@ -103,14 +116,9 @@ public: //tools::sg::device_interactor interface.
DrawView();
}
virtual void wheel_rotate(const tools::sg::wheel_rotate_event& a_event) {
const G4double angleY = a_event.angle();
if (fVP.GetFieldHalfAngle() == 0.) { // Orthographic projection
const G4double scale = 500; // Empirically chosen
fVP.MultiplyZoomFactor(1.+angleY/scale);
} else { // Perspective projection
const G4double delta = fSceneHandler.GetExtent().GetExtentRadius()/200.; // Empirical
fVP.SetDolly(fVP.GetDolly()+angleY*delta);
}
ZoomFromMouseWheel(a_event.angle(), a_event.shift_modifier(), a_event.x(), a_event.y());
SetView();
DrawView();
}
@@ -124,7 +132,6 @@ public:
,fMousePressedX(0)
,fMousePressedY(0)
{
//::printf("debug : G4ToolsSGViewer::G4ToolsSGViewer: %lu, %s\n",this,a_name.c_str());
Messenger::Create();
}
@@ -138,6 +145,7 @@ public:
protected:
G4ToolsSGViewer(const G4ToolsSGViewer& a_from)
:parent(a_from)
,parent_viewer(a_from)
,parent_interactor(a_from)
,fSGSession(a_from.fSGSession)
,fSGSceneHandler(a_from.fSGSceneHandler)
@@ -253,14 +261,14 @@ public:
} else {
//G4cout << "debug : camera : perspec : heightAngle " << float(2*fVP.GetFieldHalfAngle()) << std::endl;
tools::sg::perspective* perspective_camera = new tools::sg::perspective;
perspective_camera->height_angle.value(float(2*fVP.GetFieldHalfAngle()));
perspective_camera->height_angle.value(2 * std::atan(std::tan(fVP.GetFieldHalfAngle()) / fVP.GetZoomFactor()));
_camera = perspective_camera;
}
_camera->position.value
(tools::vec3f(float(cameraPosition.x()),
float(cameraPosition.y()),
float(cameraPosition.z())));
float(cameraPosition.y()),
float(cameraPosition.z())));
_camera->znear.value(float(pnear));
_camera->zfar.value(float(pfar));
@@ -272,7 +280,7 @@ public:
const G4Vector3D& actualLightDirection = fVP.GetActualLightpointDirection();
G4cout << "debug : actualLightDirection : " << actualLightDirection.x() << " " << actualLightDirection.y() << " " << actualLightDirection.z() << std::endl;
*/
CreateSG(_camera,fVP.GetActualLightpointDirection());
{G4Color background = fVP.GetBackgroundColour ();
@@ -308,21 +316,26 @@ public:
fSGSceneHandler.TouchPlotters(fSGViewer->sg());
fSGViewer->show();
fSGViewer->win_render();
fSGSession.sync();
}
}
public:
G4bool GetWindowSize(unsigned int& a_w,unsigned int& a_h) {
if(!fSGViewer) {a_w = 0;a_h = 0;return false;}
if(!fSGViewer) {a_w = 0; a_h = 0; return false;}
return fSGViewer->window_size(a_w,a_h);
}
G4bool GetRenderAreaSize(unsigned int& a_w,unsigned int& a_h) {
if(!fSGViewer) {a_w = 0;a_h = 0;return false;}
fSGViewer->render_area_size(a_w,a_h);
G4bool GetRenderAreaSize(unsigned int& a_w, unsigned int& a_h) {
if (!fSGViewer) {a_w = 0; a_h = 0; return false;}
fSGViewer->render_area_size(a_w, a_h);
return true;
}
//SG_VIEWER* sg_viewer() {return fSGViewer;}
virtual void EmitWindowRender() {
if(!fSGViewer) return;
fSGViewer->emit_win_render();
}
protected:
void KernelVisitDecision () {
if (CompareForKernelVisit(fLastVP)) {
@@ -367,7 +380,9 @@ protected:
(vp.GetVisAttributesModifiers() != fVP.GetVisAttributesModifiers()) ||
(vp.IsSpecialMeshRendering() != fVP.IsSpecialMeshRendering()) ||
(vp.GetSpecialMeshRenderingOption()!= fVP.GetSpecialMeshRenderingOption())||
(vp.GetTransparencyByDepth() != fVP.GetTransparencyByDepth())
(vp.GetTransparencyByDepth() != fVP.GetTransparencyByDepth()) ||
(vp.IsDotsSmooth() != fVP.IsDotsSmooth()) ||
(vp.GetDotsSize() != fVP.GetDotsSize())
)
return true;
@@ -436,6 +451,10 @@ protected:
scene_3D->add(a_camera);
{tools::sg::shade_model* shade_model = new tools::sg::shade_model;
shade_model->model = tools::sg::shade_smooth;
scene_3D->add(shade_model);}
{tools::sg::torche* light = new tools::sg::torche;
light->on = true;
light->direction = tools::vec3f(-a_light_dir.x(),-a_light_dir.y(),-a_light_dir.z());
@@ -465,6 +484,27 @@ protected:
}
}
G4double GetSceneNearWidth() {
if (!fSGSceneHandler.GetScene()) {
return 0;
}
const G4Point3D targetPoint =
fSGSceneHandler.GetScene()->GetStandardTargetPoint() + fVP.GetCurrentTargetPoint();
G4double radius = fSGSceneHandler.GetScene()->GetExtent().GetExtentRadius();
if (radius <= 0.) radius = 1.;
const G4double cameraDistance = fVP.GetCameraDistance(radius);
const G4double pnear = fVP.GetNearDistance(cameraDistance, radius);
G4double frontHalfHeight;
if (fVP.GetFieldHalfAngle() == 0.) {
frontHalfHeight = radius / fVP.GetZoomFactor();
} else {
// Code from G4ViewParameters adapted to the different zoom behavior in TSG (angle)
frontHalfHeight = pnear * std::tan(fVP.GetFieldHalfAngle() / fVP.GetZoomFactor());
}
return 2 * frontHalfHeight;
}
protected:
class Messenger: public G4VVisCommand {
public:
@@ -473,6 +513,7 @@ protected:
Messenger() {
G4UIparameter* parameter;
//////////////////////////////////////////////////////////
/// /vis/tsg/export : ////////////////////////////////////
//////////////////////////////////////////////////////////
write_scene = new G4UIcommand("/vis/tsg/export", this);
write_scene->SetGuidance("Write the content of the current viewer in a file at various formats.");
@@ -490,15 +531,15 @@ protected:
parameter = new G4UIparameter("format",'s',true);
parameter->SetDefaultValue("gl2ps_eps");
write_scene->SetParameter (parameter);
write_scene->SetParameter(parameter);
parameter = new G4UIparameter("file",'s',true);
parameter->SetDefaultValue("out.eps");
write_scene->SetParameter (parameter);
write_scene->SetParameter(parameter);
parameter = new G4UIparameter ("do_transparency", 'b', true);
parameter->SetDefaultValue ("true");
write_scene->SetParameter (parameter);
parameter->SetDefaultValue("true");
write_scene->SetParameter(parameter);
}
virtual ~Messenger() {
@@ -514,7 +555,7 @@ protected:
}
G4ToolsSGViewer* tsg_viewer = dynamic_cast<G4ToolsSGViewer*>(viewer);
if(!tsg_viewer) {
G4cout << "G4ToolsSGViewer::SetNewValue:"
G4cout << "G4ToolsSGViewer::Messenger::SetNewValue:"
<< " current viewer is not a G4ToolsSGViewer." << G4endl;
return;
}
@@ -128,3 +128,7 @@ if(WIN32)
geant4_module_sources(G4ToolsSG PUBLIC_HEADERS G4ToolsSGWindowsZB.hh SOURCES G4ToolsSGWindowsZB.cc)
geant4_module_compile_definitions(G4ToolsSG PUBLIC G4VIS_USE_TOOLSSG_WINDOWS_ZB)
endif()
if(GEANT4_USE_VTK)
geant4_module_compile_definitions(G4ToolsSG PRIVATE TOOLS_USE_GL_VERSION_3_2)
endif()
@@ -200,10 +200,16 @@ void G4ToolsSGSceneHandler::ClearStore ()
EstablishBaseNodes();
}
#include "G4ToolsSGViewer.hh"
void G4ToolsSGSceneHandler::ClearTransientStore ()
{
fpTransient2DObjects.clear();
fpTransient3DObjects.clear();
if(fpViewer) {
G4ToolsSG_viewer* tsg_viewer = dynamic_cast<G4ToolsSG_viewer*>(fpViewer);
if(tsg_viewer) tsg_viewer->EmitWindowRender();
}
}
void G4ToolsSGSceneHandler::AddPrimitive(const G4Polyline& a_polyline)
@@ -290,11 +296,12 @@ void G4ToolsSGSceneHandler::AddPrimitive (const G4Polymarker& a_polymarker)
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 = 1;
ds->point_size = markerSize;
ds->point_smooth = fpViewer->GetViewParameters().IsDotsSmooth()?true:false;
currentNode->add(ds);
tools::sg::vertices* vtxs = new tools::sg::vertices;
vtxs->mode = tools::gl::points();
{for (const auto& i : a_polymarker) {
@@ -303,7 +310,6 @@ void G4ToolsSGSceneHandler::AddPrimitive (const G4Polymarker& a_polymarker)
currentNode->add(vtxs);
}break;
case G4Polymarker::circles:{
//::printf("debug : GB : Add Markers : +++++++++++++++++++++++++++++++++++++++++++ : circles\n");
{tools::sg::markers* markers = new tools::sg::markers;
G4double diameter = markerSize; // OK for "screen-size" (the usual case)
if (markerSizeType == G4VSceneHandler::world ) {
@@ -311,14 +317,13 @@ void G4ToolsSGSceneHandler::AddPrimitive (const G4Polymarker& a_polymarker)
diameter *= fpScene->GetExtent().GetExtentRadius()/scale;
}
markers->size = diameter;
markers->style = tools::sg::marker_circle_line;
markers->style = tools::sg::marker_circle_filled;
for (const auto& i : a_polymarker) {
markers->add(float(i.x()),float(i.y()),float(i.z()));
}
currentNode->add(markers);}
}break;
case G4Polymarker::squares:{
//::printf("debug : GB : Add Markers : +++++++++++++++++++++++++++++++++++++++++++ : square\n");
{tools::sg::markers* markers = new tools::sg::markers;
G4double side = markerSize; // OK for "screen-size" (the usual case)
if (markerSizeType == G4VSceneHandler::world ) {
@@ -326,7 +331,7 @@ void G4ToolsSGSceneHandler::AddPrimitive (const G4Polymarker& a_polymarker)
side *= fpScene->GetExtent().GetExtentRadius()/scale;
}
markers->size = side;
markers->style = tools::sg::marker_square_line;
markers->style = tools::sg::marker_square_filled;
for (const auto& i : a_polymarker) {
markers->add(float(i.x()),float(i.y()),float(i.z()));
}
@@ -495,9 +500,9 @@ void G4ToolsSGSceneHandler::AddPrimitive(const G4Polyhedron& a_polyhedron)
if(isAuxilaryEdgeVisible||edgeFlag[3]>0)insertIfNew(Line(vertex[3],vertex[0]));
} else {
G4cerr
<< "ERROR: polyhedron face with unexpected number of edges (" << nEdges << ')'
<< "\n Tag: " << fpModel->GetCurrentTag()
<< G4endl;
<< "G4ToolsSGSceneHandler::AddPrimitive(G4Polyhedron): WARNING:"
<< "\n G4Polyhedron facet with unexpected number of edges (" << nEdges << ")."
<< G4endl;
return;
}
} while (notLastFace);
@@ -774,6 +779,7 @@ class plots_cbk : public tools::sg::ecbk {
TOOLS_CBK(plots_cbk,plots_cbk,tools::sg::ecbk)
public:
virtual tools::sg::return_action action() {
if(!m_event) return tools::sg::return_none;
if(const tools::sg::size_event* sz_evt = tools::sg::event_cast<tools::sg::event,tools::sg::size_event>(*m_event)){
m_plots.adjust_size(sz_evt->width(),sz_evt->height());
m_event_action->set_done(true);