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
+24 -39
View File
@@ -20,15 +20,6 @@ namespace toolx {
namespace X11 {
class base_session {
public:
//virtual bool make_current(Window) const {
// if(!m_display) return false;
// return true;
//}
//virtual bool swap_buffers(Window) const {
// if(!m_display) return false;
// return true;
//}
public:
base_session(std::ostream& a_out,unsigned int a_monitor = 0)
:m_out(a_out)
@@ -74,7 +65,6 @@ public:
clear_dispatchers();
if(m_display) ::XCloseDisplay(m_display);
m_display = 0;
//std::cout << "debug : ~base_session" << std::endl;
}
protected:
base_session(const base_session& a_from)
@@ -116,7 +106,6 @@ public:
bool sync() {
if(!m_display) return false;
//::glXWaitX();
::XSync(m_display,False);
while(true) {
XEvent xevent;
@@ -277,7 +266,6 @@ public:
unsigned long status;
} prop;
//unsigned long mwm_hints_functions = 1L << 0;
unsigned long mwm_hints_decorations = 1L << 1;
Atom atom = ::XInternAtom(m_display,"_MOTIF_WM_HINTS",False);
@@ -308,10 +296,8 @@ public:
event.xclient.data.l[2] = a_2;
event.xclient.data.l[3] = a_3;
event.xclient.data.l[4] = a_4;
//lock();
Status stat = ::XSendEvent(m_display,a_win,False,0L,&event);
::XFlush(m_display);
//unlock();
return (stat==0?false:true);
}
@@ -319,6 +305,27 @@ public:
return post(a_win,SESSION_EXIT_STEER_atom());
}
bool post_expose(Window a_win) const {
int width,height;
if(!window_size(a_win,width,height)) return false;
XEvent event;
event.type = Expose;
event.xexpose.serial = 0;
event.xexpose.send_event = True;
event.xexpose.display = m_display;
event.xexpose.window = a_win;
event.xexpose.x = 0;
event.xexpose.y = 0;
event.xexpose.width = width;
event.xexpose.height = height;
event.xexpose.count = 0;
//locks
Status stat = ::XSendEvent(m_display,a_win,False,0L,&event);
::XFlush(m_display);
//unlock();
return (stat==0?false:true);
}
//////////////////////////////////////////////////
//////////////////////////////////////////////////
//////////////////////////////////////////////////
@@ -333,7 +340,7 @@ public:
}
void remove_dispatchers_with_window(Window a_win){
tools_vforit_npp(dispatcher*,m_dispatchers,it) {
for(auto it = m_dispatchers.begin(); it != m_dispatchers.end();) {
if((*it)->window()==a_win) {
dispatcher* obj = *it;
it = m_dispatchers.erase(it);
@@ -345,7 +352,7 @@ public:
}
bool dispatch(XEvent& a_event) {
{tools_vforit_npp(dispatcher*,m_dispatchers,it) {
{for(auto it = m_dispatchers.begin(); it != m_dispatchers.end();) {
if(!(*it)->is_valid()) {
dispatcher* obj = *it;
it = m_dispatchers.erase(it);
@@ -369,30 +376,8 @@ protected:
return (a_event->type == UnmapNotify) && (a_event->xmap.window == (Window)a_arg);
}
/*
void wait_xxx(Window a_window) {
if(!m_display) return;
{wait_what arg;
arg.m_event_type = ConfigureNotify;
arg.m_window = a_window;
XEvent event;
::XIfEvent(m_display,&event,wait_for,(char*)&arg);
dispatch(event);}
}
struct wait_what {
int m_event_type;
Window m_window;
};
static Bool wait_for(Display*,XEvent* a_event,char* a_arg){
wait_what* arg = (wait_what*)a_arg;
return (a_event->type == arg->m_event_type) &&
(a_event->xmap.window == arg->m_window);
}
*/
void clear_dispatchers() {
tools_vforit_npp(dispatcher*,m_dispatchers,it) {
for(auto it = m_dispatchers.begin(); it != m_dispatchers.end();) {
dispatcher* obj = *it;
it = m_dispatchers.erase(it);
delete obj;
-20
View File
@@ -6,41 +6,21 @@
#include <X11/Xlib.h>
#ifdef TOOLS_MEM
#include <tools/mem>
#endif
namespace toolx {
namespace X11 {
class dispatcher {
protected:
#ifdef TOOLS_MEM
static const std::string& s_class() {
static const std::string s_v("toolx::X11::dispatcher");
return s_v;
}
#endif
public:
virtual bool dispatch(XEvent&) = 0;
virtual Window window() const = 0;
virtual dispatcher* copy() const = 0;
public:
dispatcher():m_is_valid(true){
#ifdef TOOLS_MEM
tools::mem::increment(s_class().c_str());
#endif
}
virtual ~dispatcher(){
#ifdef TOOLS_MEM
tools::mem::decrement(s_class().c_str());
#endif
}
public:
dispatcher(const dispatcher& a_from):m_is_valid(a_from.m_is_valid){
#ifdef TOOLS_MEM
tools::mem::increment(s_class().c_str());
#endif
}
dispatcher& operator=(const dispatcher& a_from) { m_is_valid = a_from.m_is_valid;return *this;}
public:
-4
View File
@@ -6,7 +6,6 @@
#include "colors"
#include <tools/sg/zb_viewer>
//#include <tools/sys/atime>
#include <X11/Xlib.h>
#include <X11/Xutil.h> //XPutPixel
@@ -53,7 +52,6 @@ public:
if(!m_GC) return;
if(!m_image) alloc_XImage(a_ww,a_wh);
if(!m_image) return;
//tools::atime start = tools::atime::now();
const unsigned int* pos = (const unsigned int*)a_rgbas;
unsigned int row,col;
toolx::X11::Pixel pixel;
@@ -63,9 +61,7 @@ public:
pos++;
XPutPixel(m_image,col,row,pixel);
}}
//::printf("debug : map::colors %lu, pixels %lu\n",m_colors.size(),m_pixels.size());
::XPutImage(m_display,a_win,m_GC,m_image,0,0,0,0,a_ww,a_wh);
//m_out << "pu_buffer : XImage " << tools::atime::elapsed(start) << std::endl;
}
void set_size(unsigned int a_ww,unsigned int a_wh) {
free_XImage();
-27
View File
@@ -13,20 +13,6 @@ namespace X11 {
class session : public base_session {
typedef base_session parent;
public:
//virtual bool make_current(Window a_window) const {
// if(!m_display) return false;
// if(::glXMakeCurrent(m_display,a_window,m_ctx)==False) {
// m_out << "toolx::X11::session::make_current : glXMakeCurrent failed." << std::endl;
// return false;
// }
// return true;
//}
//virtual bool swap_buffers(Window a_window) const {
// if(!m_display) return false;
// ::glXSwapBuffers(m_display,a_window);
// return true;
//}
public:
session(std::ostream& a_out,unsigned int a_monitor = 0)
:parent(a_out,a_monitor)
@@ -60,13 +46,6 @@ public:
//NOTE : macOS : glXChooseVisual leaks 640 bytes.
m_vinfo = ::glXChooseVisual(m_display,m_monitor,(int*)atbs_alpha);
if(!m_vinfo) {
//m_out << "toolx::X11::session::initialize :"
// << " can't get a visual with alpha on screen " << m_monitor << ". Try without alpha..."
// << std::endl;
//m_out << "toolx::X11::session::initialize :"
// << " DefaultScreen(m_display): " << DefaultScreen(m_display) << "."
// << std::endl;
static const int atbs[] = {
GLX_RGBA,
GLX_RED_SIZE, 1,
@@ -105,15 +84,10 @@ public:
m_ctx = 0;
return;
}
//} else {
//m_out << "toolx::X11::session::session :"
// << " glX context with direct rendering created."
// << std::endl;
}
// It is better to create a colormap adapted to the visual.
m_colormap = ::XCreateColormap(m_display,::XRootWindow(m_display,m_monitor),m_vinfo->visual,AllocNone);
//m_colormap = ::XDefaultColormap(m_display,m_monitor);
if(m_colormap==0L) {
m_out << "toolx::X11::session::session : XCreateColormap failed." << std::endl;
::XCloseDisplay(m_display);
@@ -140,7 +114,6 @@ public:
::XFree(m_vinfo);
m_vinfo = 0;
}
//std::cout << "debug : ~session" << std::endl;
}
protected:
session(const session& a_from)
+74 -13
View File
@@ -4,44 +4,95 @@
#ifndef toolx_X11_sg_viewer
#define toolx_X11_sg_viewer
// not pure X11 version. The class inherits tools::sg::viewer that uses GL.
#ifndef GL_GLEXT_LEGACY
#define GL_GLEXT_LEGACY
#endif
#include <GL/gl.h>
#ifndef GL_GLEXT_PROTOTYPES
#define GL_GLEXT_PROTOTYPES
#endif
#include <GL/glext.h>
#include "session"
#include "../GL/gl_functions"
#include "../sg/GL_action"
#include "../sg/GL_viewer"
namespace toolx {
namespace sg {
using GL_action = GL_action_T<GL::gl_functions>;
using GL_manager = GL_manager_T<GL::gl_functions>;
using GL_viewer = GL_viewer_T<GL_manager,GL_action>;
}}
#include "simple_dispatcher"
namespace tools{namespace sg{class device_interactor;}}
#include <tools/sg/device_interactor>
namespace toolx {
namespace X11 {
class sg_viewer : public sg::GL_viewer {
class sg_viewer: public sg::GL_viewer {
typedef sg::GL_viewer parent;
private:
class dispatcher : public simple_dispatcher {
typedef simple_dispatcher parent;
public:
virtual void win_render() {m_sg_viewer.win_render();}
virtual void set_size(unsigned int a_width,unsigned int a_height) {m_sg_viewer.set_size(a_width,a_height);}
virtual bool dispatch(XEvent& a_event) {
if(parent::dispatch(a_event)) return true;
bool shift_modifier = a_event.xkey.state & ShiftMask;
bool control_modifier = a_event.xkey.state & ControlMask;
if(a_event.type==ButtonPress && a_event.xbutton.button==1) {
if(!m_viewer.device_interactor()) return false;
tools::sg::mouse_down_event event(a_event.xbutton.x,a_event.xbutton.y,shift_modifier,control_modifier);
m_viewer.device_interactor()->mouse_press(event);
return true;
} else if(a_event.type==ButtonRelease && a_event.xbutton.button==1) {
if(!m_viewer.device_interactor()) return false;
tools::sg::mouse_up_event event(a_event.xbutton.x,a_event.xbutton.y,shift_modifier,control_modifier);
m_viewer.device_interactor()->mouse_release(event);
return true;
} else if(a_event.type==MotionNotify) {
if(!m_viewer.device_interactor()) return false;
if((a_event.xmotion.state & Button1MotionMask)==Button1MotionMask) {
tools::sg::mouse_move_event event(a_event.xmotion.x,a_event.xmotion.y,shift_modifier,control_modifier,0,0,false);
m_viewer.device_interactor()->mouse_move(event);
}
} else if((a_event.type==ButtonPress)&&(a_event.xbutton.button==4)) { // mouse scrollwheel down :
if(!m_viewer.device_interactor()) return false;
tools::sg::wheel_rotate_event event(8,a_event.xbutton.x,a_event.xbutton.y,shift_modifier,control_modifier); //8=cooking.
m_viewer.device_interactor()->wheel_rotate(event);
return true;
} else if((a_event.type==ButtonPress)&&(a_event.xbutton.button==5)) { // mouse scrollwheel up :
if(!m_viewer.device_interactor()) return false;
tools::sg::wheel_rotate_event event(-8,a_event.xbutton.x,a_event.xbutton.y,shift_modifier,control_modifier); //8=cooking.
m_viewer.device_interactor()->wheel_rotate(event);
return true;
}
return false;
}
virtual void win_render() {m_viewer.win_render();}
virtual void set_size(unsigned int a_width,unsigned int a_height) {m_viewer.set_size(a_width,a_height);}
virtual dispatcher* copy() const {return new dispatcher(*this);}
public:
dispatcher(sg_viewer& a_sg_viewer)
:parent(a_sg_viewer.m_session,a_sg_viewer.m_win)
,m_sg_viewer(a_sg_viewer){}
dispatcher(sg_viewer& a_viewer)
:parent(a_viewer.m_session,a_viewer.m_win)
,m_viewer(a_viewer){}
virtual ~dispatcher(){}
protected:
dispatcher(const dispatcher& a_from)
:parent(a_from)
,m_sg_viewer(a_from.m_sg_viewer)
,m_viewer(a_from.m_viewer)
{}
dispatcher& operator=(const dispatcher& a_from) {
parent::operator=(a_from);
return *this;
}
protected:
sg_viewer& m_sg_viewer;
sg_viewer& m_viewer;
};
public:
@@ -52,6 +103,7 @@ public:
:parent(a_session.out(),a_width,a_height)
,m_session(a_session)
,m_win(0)
,m_interactor(0)
{
if(!m_session.display()) return; //throw
m_win = m_session.create_window(a_win_title.c_str(),a_x,a_y,a_width,a_height);
@@ -65,11 +117,12 @@ public:
m_session.sync();
}
}
public:
protected:
sg_viewer(const sg_viewer& a_from)
:parent(a_from)
,m_session(a_from.m_session)
,m_win(a_from.m_win)
,m_interactor(0)
{}
sg_viewer& operator=(const sg_viewer& a_from){
parent::operator=(a_from);
@@ -98,6 +151,12 @@ public:
if(::glXMakeCurrent(m_session.display(),None,NULL)==False){
m_session.out() << "toolx::X11::sg_viewer::win_render : glXMakeCurrent(None,NULL) failed." << std::endl;
}
m_session.sync();
}
void emit_win_render() {
if(!m_win) return;
m_session.post_expose(m_win);
}
bool window_size(unsigned int& a_w,unsigned int& a_h) {
@@ -113,14 +172,16 @@ public:
a_h = parent::height();
}
void set_device_interactor(tools::sg::device_interactor* a_interactor) {m_interactor = a_interactor;}
public:
void set_device_interactor(tools::sg::device_interactor*) {}
tools::sg::device_interactor* device_interactor() {return m_interactor;}
protected:
session& m_session;
Window m_win;
tools::sg::device_interactor* m_interactor;
};
}}
#endif
@@ -6,8 +6,6 @@
#include "base_session"
#include <tools/saui>
namespace toolx {
namespace X11 {
+7 -1
View File
@@ -133,8 +133,14 @@ public:
void win_render() {
if(!m_win) return;
if(!render(get_rgbas,false)) return;
put_buffer(m_win,m_ww,m_wh,tools::vec_data(m_out_buffer));
put_buffer(m_win,m_ww,m_wh,m_out_buffer.data());
m_out_buffer.clear();
m_session.sync();
}
void emit_win_render() {
if(!m_win) return;
m_session.post_expose(m_win);
}
bool window_size(unsigned int& a_w,unsigned int& a_h) {