Import Geant4 11.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2021-12-10 14:46:44 +01:00
committed by Ben Morgan
parent 6399a014b6
commit 80e2389dd8
3932 changed files with 202519 additions and 246221 deletions
@@ -25,36 +25,56 @@
//
// Guy Barrand 8th April 2021
#if defined (G4VIS_BUILD_TOOLSSG_QT_GLES_DRIVER) || defined (G4VIS_USE_TOOLSSG_QT_GLES)
#ifndef G4TOOLSSGQTVIEWER_HH
#define G4TOOLSSGQTVIEWER_HH
#include "G4ToolsSGViewer.hh"
#include <tools/Qt/sg_viewer>
#include "G4Qt.hh"
#include "G4UIQt.hh"
#include "G4UImanager.hh"
#include <tools/Qt/sg_viewer>
#include <qmainwindow.h>
class G4ToolsSGQtDestroyCallback : public QObject {
Q_OBJECT
public:
G4ToolsSGQtDestroyCallback(G4VViewer* a_viewer):fViewer(a_viewer) {}
virtual ~G4ToolsSGQtDestroyCallback() {}
private:
G4ToolsSGQtDestroyCallback(const G4ToolsSGQtDestroyCallback&);
G4ToolsSGQtDestroyCallback& operator=(const G4ToolsSGQtDestroyCallback&);
public slots:
void execute(){
//::printf("debug : G4ToolsSGQtDestroyCallback::execute\n");
delete fViewer;
}
private:
G4VViewer* fViewer;
};
class G4ToolsSGQtViewer : public G4ToolsSGViewer<tools::Qt::session,tools::Qt::sg_viewer> {
typedef G4ToolsSGViewer<tools::Qt::session,tools::Qt::sg_viewer> parent;
public:
G4ToolsSGQtViewer(tools::Qt::session& a_session,G4ToolsSGSceneHandler& a_scene_handler, const G4String& a_name)
:parent(a_session,a_scene_handler,a_name)
,fInTab(false)
,fSGQWidget(nullptr)
{}
virtual ~G4ToolsSGQtViewer() = default;
,fDestroyCallback(0)
{
fDestroyCallback = new G4ToolsSGQtDestroyCallback(this);
}
virtual ~G4ToolsSGQtViewer() {
delete fDestroyCallback; //it will remove the below signal/slot connection.
}
protected:
G4ToolsSGQtViewer(const G4ToolsSGQtViewer& a_from):parent(a_from),fInTab(false){}
G4ToolsSGQtViewer(const G4ToolsSGQtViewer& a_from):parent(a_from){}
G4ToolsSGQtViewer& operator=(const G4ToolsSGQtViewer&) {return *this;}
public:
virtual void Initialise() {
if(fSGQWidget) return; //done.
parent::Initialise();
fInTab = false;
if(!fSGViewer) {
G4cerr << "G4ToolsSGQtViewer::Initialise: ERROR: G4ToolsSGQtViewer has no tools::Qt::sg_viewer." << G4endl;
return;
@@ -64,45 +84,48 @@ public:
G4cerr << "G4ToolsSGQtViewer::Initialise: ERROR: tools::Qt::sg_viewer has no QWidget shell." << G4endl;
return;
}
{G4UImanager* ui = G4UImanager::GetUIpointer();
G4UIsession* session = ui->GetG4UIWindow();
G4UIQt* uiQt = session? dynamic_cast<G4UIQt*>(session) :nullptr;
if(uiQt) {
G4Qt* interactorManager = G4Qt::getInstance ();
if (!interactorManager->IsExternalApp()) {
uiQt->AddTabWidget(fSGQWidget,QString(GetName()));
fInTab = true;
fSGViewer->set_own_shell(false);
uiQt->AddTabWidget(fSGQWidget,QString(GetName()));
QObject::connect(fSGQWidget,SIGNAL(destroyed()),fDestroyCallback,SLOT(execute()));
QMainWindow* main_window = uiQt->GetMainWindow();
if(main_window) {
main_window->show();
interactorManager->FlushAndWaitExecution();
}
}
}}
fSGViewer->enable_keyboard_focus();
}
virtual void ShowView() {
if(fInTab) {
if(!fSGViewer) return;
fSGViewer->win_render();
fSGSession.sync();
} else {
parent::ShowView();
}
}
virtual void FinishView() {
if(fInTab) {
if(!fSGViewer) return;
fSGViewer->win_render();
fSGSession.sync();
} else {
parent::FinishView();
virtual void SetView() {
#ifdef __APPLE__
if(fSGQWidget && fSGViewer) {
if( (2*fSGQWidget->width() == int(fSGViewer->width())) &&
(2*fSGQWidget->height() == int(fSGViewer->height())) ){
// With Qt/Cocoa, the received size in
// tools::sg::glarea::resizeGL is twice the QWidget::[width(),height()]!
// In general it does not pose problem, except when rendering 2D texts.
// In order to have similar sizes than other platforms, we have to double
// their pixel heights.
fVP.SetGlobalMarkerScale(2);
}
}
#endif
parent::SetView();
}
protected:
bool fInTab;
QWidget* fSGQWidget;
G4ToolsSGQtDestroyCallback* fDestroyCallback;
};
#endif
#endif