Import Geant4 11.4.0 source tree
This commit is contained in:
@@ -9,12 +9,6 @@
|
||||
#include <X11/CompositeP.h>
|
||||
#include <X11/StringDefs.h>
|
||||
|
||||
//#define TOOLX_XT_IMAGEAREA_DEBUG
|
||||
|
||||
#ifdef TOOLX_XT_IMAGEAREA_DEBUG
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
namespace toolx {
|
||||
namespace Xt {
|
||||
|
||||
@@ -81,37 +75,20 @@ public:
|
||||
}
|
||||
protected:
|
||||
static void initialize_class(void) {
|
||||
#ifdef TOOLX_XT_IMAGEAREA_DEBUG
|
||||
::printf("debug: toolx::Xt::ImageArea: initialize_class.\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
static void initialize_widget(Widget a_request,Widget a_this,ArgList,Cardinal*) {
|
||||
if(a_request->core.width<=0) a_this->core.width = 100;
|
||||
if(a_request->core.height<=0) a_this->core.height = 100;
|
||||
|
||||
#ifdef TOOLX_XT_IMAGEAREA_DEBUG
|
||||
::printf("debug: toolx::Xt::ImageArea: initialize_widget: %s\n",::XtName(a_this));
|
||||
#endif
|
||||
|
||||
::XtAddEventHandler
|
||||
(a_this,ButtonPressMask|ButtonReleaseMask|ButtonMotionMask|KeyPressMask|KeyReleaseMask,0,event_handler,NULL);
|
||||
|
||||
#ifdef TOOLX_XT_IMAGEAREA_DEBUG
|
||||
::printf("debug: toolx::Xt::ImageArea: initialize_widget: end\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
static void destroy_widget(Widget) {
|
||||
#ifdef TOOLX_XT_IMAGEAREA_DEBUG
|
||||
::printf("debug: toolx::Xt::ImageArea: destroy_widget.\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
static void change_widget_size(Widget a_this) {
|
||||
#ifdef TOOLX_XT_IMAGEAREA_DEBUG
|
||||
::printf("debug: toolx::Xt::ImageArea: change_widget_size: %s\n",XtName(a_this));
|
||||
#endif
|
||||
|
||||
if(widget_class()->core_class.superclass->core_class.resize!=NULL)
|
||||
(widget_class()->core_class.superclass->core_class.resize)(a_this);
|
||||
@@ -121,15 +98,9 @@ protected:
|
||||
value.event = 0;
|
||||
::XtCallCallbacks(a_this,XoN_resizeCallback(),(XtPointer)&value);
|
||||
|
||||
#ifdef TOOLX_XT_IMAGEAREA_DEBUG
|
||||
::printf("debug: toolx::Xt::ImageArea: change_widget_size: end\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
static void draw_widget(Widget a_this,XEvent* a_event,Region a_region) {
|
||||
#ifdef TOOLX_XT_IMAGEAREA_DEBUG
|
||||
::printf("debug: toolx::Xt::ImageArea: draw_widget: %s\n",XtName(a_this));
|
||||
#endif
|
||||
|
||||
if(widget_class()->core_class.superclass->core_class.expose!=NULL)
|
||||
(widget_class()->core_class.superclass->core_class.expose)(a_this,a_event,a_region);
|
||||
@@ -138,10 +109,6 @@ protected:
|
||||
value.reason = XoCR_PAINT();
|
||||
value.event = a_event;
|
||||
::XtCallCallbacks(a_this,XoN_paintCallback(),(XtPointer)&value);
|
||||
|
||||
#ifdef TOOLX_XT_IMAGEAREA_DEBUG
|
||||
::printf("debug: toolx::Xt::ImageArea: draw_widget: end\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
+10
-42
@@ -9,6 +9,16 @@
|
||||
#include <X11/CompositeP.h>
|
||||
#include <X11/StringDefs.h>
|
||||
|
||||
#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 <GL/glx.h>
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -97,10 +107,6 @@ protected:
|
||||
if(a_request->core.width<=0) a_this->core.width = 100;
|
||||
if(a_request->core.height<=0) a_this->core.height = 100;
|
||||
|
||||
#ifdef TOOLX_XT_OPENGLAREA_DEBUG
|
||||
::printf ("debug : OpenGLArea : InitializeWidget : %s\n",::XtName(a_this));
|
||||
#endif
|
||||
|
||||
OpenGLAreaPart& athis = _athis(a_this);
|
||||
athis.visual = CopyFromParent;
|
||||
athis.installColormap = False;
|
||||
@@ -196,16 +202,9 @@ protected:
|
||||
|
||||
::XtAddEventHandler
|
||||
(a_this,ButtonPressMask|ButtonReleaseMask|ButtonMotionMask|KeyPressMask|KeyReleaseMask,0,event_handler,NULL);
|
||||
|
||||
#ifdef TOOLX_XT_OPENGLAREA_DEBUG
|
||||
printf("debug : OpenGLArea : InitializeWidget : end\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
static void realize_widget(Widget a_this,XtValueMask* a_mask,XSetWindowAttributes* a_watbs) {
|
||||
#ifdef TOOLX_XT_OPENGLAREA_DEBUG
|
||||
printf("debug : OpenGLArea : realize_widget : %s\n",XtName(a_this));
|
||||
#endif
|
||||
|
||||
// Have to create window ourselves due to OpenGL that compells it's visual.
|
||||
// In principle colormap is correctly set in a_watbsy.
|
||||
@@ -221,17 +220,9 @@ protected:
|
||||
// If window is delete, all seems ok :
|
||||
if(athis.installColormap==True) install_colormap(a_this);
|
||||
|
||||
//make_current(a_this);
|
||||
|
||||
#ifdef TOOLX_XT_OPENGLAREA_DEBUG
|
||||
printf("debug : OpenGLArea : realize_widget : end\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
static void destroy_widget(Widget a_this) {
|
||||
#ifdef TOOLX_XT_OPENGLAREA_DEBUG
|
||||
printf("debug : OpenGLArea : destroy_widget : begin\n");
|
||||
#endif
|
||||
OpenGLAreaPart& athis = _athis(a_this);
|
||||
if(athis.installColormap==True) {
|
||||
uninstall_colormap (a_this);
|
||||
@@ -243,9 +234,6 @@ protected:
|
||||
::glXDestroyContext(XtDisplay(a_this),athis.glContext);
|
||||
athis.glContext = NULL;
|
||||
}
|
||||
#ifdef TOOLX_XT_OPENGLAREA_DEBUG
|
||||
printf("debug : OpenGLArea : destroy_widget : end\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
static Boolean set_values(Widget a_current,Widget,Widget a_this,ArgList,Cardinal*) {
|
||||
@@ -264,31 +252,16 @@ protected:
|
||||
}
|
||||
|
||||
static void change_widget_size(Widget a_this) {
|
||||
#ifdef TOOLX_XT_OPENGLAREA_DEBUG
|
||||
printf("debug : OpenGLArea : change_widget_size : %s\n",XtName(a_this));
|
||||
#endif
|
||||
|
||||
// Call the Resize procedure (XtInheritResize) :
|
||||
if(widget_class()->core_class.superclass->core_class.resize!=NULL)
|
||||
(widget_class()->core_class.superclass->core_class.resize)(a_this);
|
||||
|
||||
#ifdef TOOLX_XT_OPENGLAREA_DEBUG
|
||||
printf("debug : OpenGLArea : change_widget_size : end\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
static void draw_widget(Widget a_this,XEvent* a_event,Region a_region) {
|
||||
#ifdef TOOLX_XT_OPENGLAREA_DEBUG
|
||||
printf("debug : OpenGLArea : draw_widget : %s\n",XtName(a_this));
|
||||
#endif
|
||||
|
||||
if(widget_class()->core_class.superclass->core_class.expose!=NULL)
|
||||
(widget_class()->core_class.superclass->core_class.expose)(a_this,a_event,a_region);
|
||||
|
||||
if(make_current(a_this)==1) {
|
||||
#ifdef TOOLX_XT_OPENGLAREA_DEBUG
|
||||
printf("debug : OpenGLArea : draw_widget : %s : make_current ok : call paintCallback...\n",XtName(a_this));
|
||||
#endif
|
||||
XoAnyCallbackStruct value;
|
||||
value.reason = XoCR_PAINT;
|
||||
value.event = a_event;
|
||||
@@ -296,10 +269,6 @@ protected:
|
||||
::glXSwapBuffers(XtDisplay(a_this),XtWindow(a_this));
|
||||
::glXMakeCurrent(XtDisplay(a_this),None,NULL);
|
||||
}
|
||||
|
||||
#ifdef TOOLX_XT_OPENGLAREA_DEBUG
|
||||
printf("debug : OpenGLArea : draw_widget : end\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -485,5 +454,4 @@ public:
|
||||
|
||||
}}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
+26
-3
@@ -61,9 +61,6 @@ public:
|
||||
return true;
|
||||
}
|
||||
bool sync() {
|
||||
//if(!m_app_widget) return false;
|
||||
//Display* display = XtDisplay(m_app_widget);
|
||||
//::XSync(display,False);
|
||||
if(!m_app_context) return false;
|
||||
while(true) {
|
||||
XtInputMask input = ::XtAppPending(m_app_context);
|
||||
@@ -85,5 +82,31 @@ protected:
|
||||
|
||||
}}
|
||||
|
||||
#include <X11/IntrinsicP.h>
|
||||
|
||||
namespace toolx {
|
||||
namespace Xt {
|
||||
|
||||
inline bool post_expose(Widget a_widget) {
|
||||
if(!XtIsRealized(a_widget)) return false;
|
||||
XEvent event;
|
||||
event.type = Expose;
|
||||
event.xexpose.serial = 0;
|
||||
event.xexpose.send_event = True;
|
||||
event.xexpose.display = XtDisplay(a_widget);
|
||||
event.xexpose.window = XtWindow(a_widget);
|
||||
event.xexpose.x = 0;
|
||||
event.xexpose.y = 0;
|
||||
event.xexpose.width = a_widget->core.width;
|
||||
event.xexpose.height = a_widget->core.height;
|
||||
event.xexpose.count = 0;
|
||||
//locks
|
||||
Status stat = ::XSendEvent(event.xexpose.display,event.xexpose.window,False,0L,&event);
|
||||
::XFlush(event.xexpose.display);
|
||||
//unlock();
|
||||
return (stat==0?false:true);
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
+43
-15
@@ -6,8 +6,30 @@
|
||||
|
||||
#include "session"
|
||||
|
||||
#ifndef GL_GLEXT_LEGACY
|
||||
#define GL_GLEXT_LEGACY
|
||||
#endif
|
||||
#include <GL/gl.h>
|
||||
|
||||
#ifdef TOOLS_USE_GL_VERSION_3_2
|
||||
#ifndef GL_GLEXT_PROTOTYPES
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#endif
|
||||
#include <GL/glext.h>
|
||||
#endif
|
||||
|
||||
#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 "OpenGLArea"
|
||||
|
||||
#include <X11/Shell.h>
|
||||
@@ -62,9 +84,6 @@ public:
|
||||
::XtAddCallback(m_shell,XtNdestroyCallback,destroy_shell_callback,(XtPointer)this);
|
||||
|
||||
::XtRealizeWidget(m_shell);
|
||||
|
||||
//Atom WM_DELETE_WINDOW_atom = ::XInternAtom(XtDisplay(m_shell),"WM_DELETE_WINDOW",False);
|
||||
//::XSetWMProtocols(XtDisplay(m_shell),XtWindow(m_shell),&WM_DELETE_WINDOW_atom,1);
|
||||
}
|
||||
virtual ~sg_viewer() {
|
||||
if(m_shell) {
|
||||
@@ -105,7 +124,14 @@ public:
|
||||
}
|
||||
|
||||
void win_render() {
|
||||
if(m_glarea) OpenGLArea::paint(m_glarea);
|
||||
if(!m_glarea) return;
|
||||
OpenGLArea::paint(m_glarea);
|
||||
m_session.sync();
|
||||
}
|
||||
|
||||
void emit_win_render() {
|
||||
if(!m_glarea) return;
|
||||
if(!post_expose(m_glarea)) {}
|
||||
}
|
||||
|
||||
bool window_size(unsigned int& a_w,unsigned int& a_h) {
|
||||
@@ -125,7 +151,6 @@ protected:
|
||||
static void paint_cbk(Widget a_widget,XtPointer a_tag,XtPointer){
|
||||
unsigned int width = a_widget->core.width;
|
||||
unsigned int height = a_widget->core.height;
|
||||
//::printf("debug : toolx::Xt::sg_viewer::paint_cbk : %d %d\n",width,height);
|
||||
sg_viewer* _this = (sg_viewer*)a_tag;
|
||||
_this->set_size(width,height);
|
||||
_this->render();
|
||||
@@ -157,22 +182,26 @@ protected:
|
||||
} else if(xevent->xbutton.button==Button5) { //5=wheel up, or move up double touch on trackpad = zoom out.
|
||||
tools::sg::wheel_rotate_event event(-8,xevent->xbutton.x,xevent->xbutton.y,shift_modifier,control_modifier); //8=cooking.
|
||||
_this->m_interactor->wheel_rotate(event);
|
||||
} else {
|
||||
} else if(xevent->xbutton.button==Button1) {
|
||||
tools::sg::mouse_down_event event(xevent->xbutton.x,xevent->xbutton.y,shift_modifier,control_modifier);
|
||||
_this->m_interactor->mouse_press(event);
|
||||
}
|
||||
}return;
|
||||
case ButtonRelease:{
|
||||
bool shift_modifier = xevent->xkey.state & ShiftMask;
|
||||
bool control_modifier = xevent->xkey.state & ControlMask;
|
||||
tools::sg::mouse_up_event event(xevent->xbutton.x,xevent->xbutton.y,shift_modifier,control_modifier);
|
||||
_this->m_interactor->mouse_release(event);
|
||||
if(xevent->xbutton.button==Button1) {
|
||||
bool shift_modifier = xevent->xkey.state & ShiftMask;
|
||||
bool control_modifier = xevent->xkey.state & ControlMask;
|
||||
tools::sg::mouse_up_event event(xevent->xbutton.x,xevent->xbutton.y,shift_modifier,control_modifier);
|
||||
_this->m_interactor->mouse_release(event);
|
||||
}
|
||||
}return;
|
||||
case MotionNotify:{
|
||||
bool shift_modifier = xevent->xkey.state & ShiftMask;
|
||||
bool control_modifier = xevent->xkey.state & ControlMask;
|
||||
tools::sg::mouse_move_event event(xevent->xmotion.x,xevent->xmotion.y,shift_modifier,control_modifier,0,0,false);
|
||||
_this->m_interactor->mouse_move(event);
|
||||
if((xevent->xmotion.state & Button1MotionMask)==Button1MotionMask) {
|
||||
bool shift_modifier = xevent->xkey.state & ShiftMask;
|
||||
bool control_modifier = xevent->xkey.state & ControlMask;
|
||||
tools::sg::mouse_move_event event(xevent->xmotion.x,xevent->xmotion.y,shift_modifier,control_modifier,0,0,false);
|
||||
_this->m_interactor->mouse_move(event);
|
||||
}
|
||||
}return;
|
||||
default:return;}
|
||||
}
|
||||
@@ -197,4 +226,3 @@ protected:
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+9
-8
@@ -69,9 +69,6 @@ public:
|
||||
iscreen = XScreenNumberOfScreen(screen);
|
||||
m_pixwin = new toolx::X11::pixwin(a_session.out(),iscreen,XtDisplay(app_widget));
|
||||
m_pixwin->set_size(m_image_area->core.width,m_image_area->core.height);}
|
||||
|
||||
//Atom WM_DELETE_WINDOW_atom = ::XInternAtom(XtDisplay(m_shell),"WM_DELETE_WINDOW",False);
|
||||
//::XSetWMProtocols(XtDisplay(m_shell),XtWindow(m_shell),&WM_DELETE_WINDOW_atom,1);
|
||||
}
|
||||
virtual ~zb_viewer() {
|
||||
delete m_pixwin;
|
||||
@@ -113,7 +110,14 @@ public:
|
||||
}
|
||||
|
||||
void win_render() {
|
||||
if(m_image_area) ImageArea::paint(m_image_area);
|
||||
if(!m_image_area) return;
|
||||
ImageArea::paint(m_image_area);
|
||||
m_session.sync();
|
||||
}
|
||||
|
||||
void emit_win_render() {
|
||||
if(!m_image_area) return;
|
||||
if(!post_expose(m_image_area)) {}
|
||||
}
|
||||
|
||||
bool window_size(unsigned int& a_w,unsigned int& a_h) {
|
||||
@@ -133,7 +137,6 @@ protected:
|
||||
if(!XtIsRealized(a_widget)) return;
|
||||
unsigned int width = a_widget->core.width;
|
||||
unsigned int height = a_widget->core.height;
|
||||
//::printf("debug: toolx::Xt::zb_viewer::resize_cbk: %d %d\n",width,height);
|
||||
zb_viewer* _this = (zb_viewer*)a_tag;
|
||||
_this->set_size(width,height);
|
||||
_this->m_pixwin->set_size(width,height);
|
||||
@@ -142,11 +145,9 @@ protected:
|
||||
if(!XtIsRealized(a_widget)) return;
|
||||
unsigned int width = a_widget->core.width;
|
||||
unsigned int height = a_widget->core.height;
|
||||
//::printf("debug: toolx::Xt::zb_viewer::paint_cbk: %d %d\n",width,height);
|
||||
zb_viewer* _this = (zb_viewer*)a_tag;
|
||||
if(!_this->render(tools::sg::zb_viewer::get_rgbas,false)) return; //rgbas because Qt wants an image 32 bits aligned.
|
||||
_this->m_pixwin->put_buffer(XtWindow(a_widget),width,height,tools::vec_data(_this->out_buffer()));
|
||||
//parent::after_render();
|
||||
_this->m_pixwin->put_buffer(XtWindow(a_widget),width,height,_this->out_buffer().data());
|
||||
_this->out_buffer_clear();
|
||||
}
|
||||
static void event_cbk(Widget,XtPointer a_tag,XtPointer a_data){
|
||||
|
||||
Reference in New Issue
Block a user