Import Geant4 11.2.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2023-06-30 09:09:57 +02:00
parent aef78ca386
commit dd1f179cda
3780 changed files with 212808 additions and 142780 deletions
-55
View File
@@ -1,55 +0,0 @@
name := G4ToolsSG
ifndef G4INSTALL
G4INSTALL = ../../..
endif
GLOBLIBS = libG4vis_management.lib libG4modeling.lib
GLOBLIBS += libG4run.lib libG4event.lib
GLOBLIBS += libG4tracking.lib libG4processes.lib libG4digits_hits.lib
GLOBLIBS += libG4track.lib libG4particles.lib libG4geometry.lib
GLOBLIBS += libG4materials.lib libG4graphics_reps.lib
GLOBLIBS += libG4intercoms.lib libG4global.lib
include $(G4INSTALL)/config/architecture.gmk
include $(G4INSTALL)/config/interactivity.gmk
CPPFLAGS += -I$(G4BASE)/visualization/management/include
CPPFLAGS += -I$(G4BASE)/visualization/modeling/include
CPPFLAGS += -I$(G4BASE)/global/management/include
CPPFLAGS += -I$(G4BASE)/global/HEPGeometry/include
CPPFLAGS += -I$(G4BASE)/graphics_reps/include
CPPFLAGS += -I$(G4BASE)/intercoms/include
CPPFLAGS += -I$(G4BASE)/geometry/management/include
CPPFLAGS += -I$(G4BASE)/geometry/navigation/include
CPPFLAGS += -I$(G4BASE)/geometry/solids/CSG/include
CPPFLAGS += -I$(G4BASE)/geometry/solids/specific/include
CPPFLAGS += -I$(G4BASE)/geometry/volumes/include
CPPFLAGS += -I$(G4BASE)/tracking/include
CPPFLAGS += -I$(G4BASE)/digits_hits/hits/include
# Locally adjust source list before including common.gmk
sources := src/G4ToolsSGSceneHandler.cc
CPPFLAGS += -I$(G4BASE)/externals/g4tools/include
sources += src/G4ToolsSGOffscreen.cc
ifdef G4VIS_BUILD_TOOLSSG_X11_GLES_DRIVER
sources += src/G4ToolsSGX11GLES.cc
endif
ifdef G4VIS_BUILD_TOOLSSG_WINDOWS_GLES_DRIVER
sources += src/G4ToolsSGWindowsGLES.cc
endif
ifdef G4VIS_BUILD_TOOLSSG_XT_GLES_DRIVER
sources += src/G4ToolsSGXtGLES.cc
endif
ifdef G4VIS_BUILD_TOOLSSG_QT_GLES_DRIVER
sources += src/G4ToolsSGQtGLES.cc src/G4ToolsSGQtViewer.cc
endif
include $(G4INSTALL)/config/moc.gmk
include $(G4INSTALL)/config/common.gmk
+45
View File
@@ -6,6 +6,51 @@ It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2023-06-04 John Allison (vis_toolssg-V11-01-08)
- IsUISessionCompatible: Remove the function where not necessary and tidy.
## 2023-05-29 Guy Barrand (vis_toolssg-V11-01-07)
- sources.cmake: declare the G4*ZB.hh, G4*ZB.cc files.
- new ToolsSG Qt ZB sub-driver: new files: G4ToolsSGQtZB.hh, G4ToolsSGQtZB.cc, G4ToolsSGQtZBViewer.hh, G4ToolsSGQtZBViewer.cc.
- new ToolsSG X11 sub-driver. New files: G4ToolsSGX11ZB.hh, G4ToolsSGX11ZB.cc.
- new ToolsSG Xt sub-driver. New files: G4ToolsSGXtZB.hh, G4ToolsSGXtZB.cc.
- new ToolsSG Windows sub-driver. New files: G4ToolsSGWindowsZB.hh, G4ToolsSGWindowsZB.cc.
- sources.cmake: in if(GEANT4_USE_TOOLSSG_XT_GLES), PUBLIC G4VIS_USE_TOOLSSG_X11_GLES should be PUBLIC G4VIS_USE_TOOLSSG_XT_GLES.
- src/G4ToolsSGQtGLES.cc, G4ToolsSGXtGLES.cc: avoid the "tools::argcv" logic by using the "get argcv" from G4Qt, G4Xt. This should fix a Coverity issue.
## 2023-04-27 Ben Morgan (vis_toolssg-V11-01-06)
- Link to Qt6OpenGLWidgets library when using Qt6 to access QOpenGLWidget.
## 2023-04-14 John Allison (vis_toolssg-V11-01-05)
- Co-working: visman-V11-01-04, greps-V11-01-03, interfaces-V11-01-11,
opengl-V11-01-06, openinventor-V11-01-04.
- New Scene Tree Phase 2 - first implementation of a no-frills GUI-side
- See visualization/management/History for full description.
- Revert earlier changes for the new scene tree.
- After the introduction of virtual G4VInteractiveSession::UpdateSceneTree
they are no loner necessary.
## 2023-04-02 Ben Morgan (vis_toolssg-V11-01-04)
- No longer link to QtPrintSupport, which is not used in the toolkit.
## 2023-03-28 John Allison (vis_toolssg-V11-01-03)
- G4ToolsSGViewer.hh:
- Call UpdateGUISceneTree() if (kernelVisitWasNeeded).
- G4ToolsSGQtViewer.hh:
- uiQt becomes fUIQt, i.e., a data member.
- Implement virtual void UpdateGUISceneTree() {
- if (fUIQt) fUIQt->UpdateSceneTree(fSceneTree);
## 2023-03-22 Ben Morgan (vis_toolssg-V11-01-02)
- Export public compile definitions to indicate availablity of specific drivers. Moves to
"use on link" model.
## 2023-02-06 Ben Morgan (vis_toolssg-V11-01-01)
- Isolate private headers and update dependencies
## 2023-01-30 Ben Morgan (vis_toolssg-V11-01-00)
- Link to new G4UIcore/UIimplementation modules in place of former G4UIbasic/UIcommon
## 2022-11-25 Gabriele Cosmo (vis_toolssg-V11-00-15)
- Fixed compilation warnings for implicit type conversions on macOS/XCode 14.1.
@@ -43,7 +43,6 @@ protected:
public:
G4VSceneHandler* CreateSceneHandler(const G4String& name = "");
G4VViewer* CreateViewer (G4VSceneHandler&, const G4String& name = "");
G4bool IsUISessionCompatible () const;
protected:
void Initialise();
protected:
@@ -0,0 +1,53 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// Guy Barrand 13th April 2023
#ifndef G4TOOLSSGQTZB_HH
#define G4TOOLSSGQTZB_HH
#include "G4VGraphicsSystem.hh"
namespace toolx {namespace Qt {class session;}}
class G4ToolsSGQtZB: public G4VGraphicsSystem {
using parent = G4VGraphicsSystem;
public:
G4ToolsSGQtZB();
virtual ~G4ToolsSGQtZB();
protected:
G4ToolsSGQtZB(const G4ToolsSGQtZB& a_from):parent(a_from){}
G4ToolsSGQtZB& operator=(const G4ToolsSGQtZB&) {return *this;}
public:
G4VSceneHandler* CreateSceneHandler(const G4String& name = "");
G4VViewer* CreateViewer (G4VSceneHandler&, const G4String& name = "");
G4bool IsUISessionCompatible () const;
protected:
void Initialise();
protected:
toolx::Qt::session* fSGSession;
};
#endif
@@ -43,7 +43,6 @@ protected:
public:
G4VSceneHandler* CreateSceneHandler(const G4String& name = "");
G4VViewer* CreateViewer (G4VSceneHandler&, const G4String& name = "");
G4bool IsUISessionCompatible () const;
protected:
void Initialise();
protected:
@@ -0,0 +1,52 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// Guy Barrand 17th April 2023
#ifndef G4TOOLSSGWINDOWSZB_HH
#define G4TOOLSSGWINDOWSZB_HH
#include "G4VGraphicsSystem.hh"
namespace toolx {namespace Windows {class session;}}
class G4ToolsSGWindowsZB: public G4VGraphicsSystem {
using parent = G4VGraphicsSystem;
public:
G4ToolsSGWindowsZB();
virtual ~G4ToolsSGWindowsZB();
protected:
G4ToolsSGWindowsZB(const G4ToolsSGWindowsZB& a_from):parent(a_from){}
G4ToolsSGWindowsZB& operator=(const G4ToolsSGWindowsZB&) {return *this;}
public:
G4VSceneHandler* CreateSceneHandler(const G4String& name = "");
G4VViewer* CreateViewer (G4VSceneHandler&, const G4String& name = "");
protected:
void Initialise();
protected:
toolx::Windows::session* fSGSession;
};
#endif
@@ -43,7 +43,6 @@ protected:
public:
G4VSceneHandler* CreateSceneHandler(const G4String& name = "");
G4VViewer* CreateViewer (G4VSceneHandler&, const G4String& name = "");
G4bool IsUISessionCompatible () const;
protected:
void Initialise();
protected:
@@ -0,0 +1,52 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// Guy Barrand 14th April 2023
#ifndef G4TOOLSSGX11ZB_HH
#define G4TOOLSSGX11ZB_HH
#include "G4VGraphicsSystem.hh"
namespace toolx {namespace X11 {class base_session;}}
class G4ToolsSGX11ZB: public G4VGraphicsSystem {
using parent = G4VGraphicsSystem;
public:
G4ToolsSGX11ZB();
virtual ~G4ToolsSGX11ZB();
protected:
G4ToolsSGX11ZB(const G4ToolsSGX11ZB& a_from):parent(a_from){}
G4ToolsSGX11ZB& operator=(const G4ToolsSGX11ZB&) {return *this;}
public:
G4VSceneHandler* CreateSceneHandler(const G4String& name = "");
G4VViewer* CreateViewer (G4VSceneHandler&, const G4String& name = "");
protected:
void Initialise();
protected:
toolx::X11::base_session* fSGSession;
};
#endif
@@ -43,7 +43,6 @@ protected:
public:
G4VSceneHandler* CreateSceneHandler(const G4String& name = "");
G4VViewer* CreateViewer (G4VSceneHandler&, const G4String& name = "");
G4bool IsUISessionCompatible () const;
protected:
void Initialise();
protected:
@@ -0,0 +1,52 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// Guy Barrand 14th April 2023
#ifndef G4TOOLSSGXTZB_HH
#define G4TOOLSSGXTZB_HH
#include "G4VGraphicsSystem.hh"
namespace toolx {namespace Xt {class session;}}
class G4ToolsSGXtZB: public G4VGraphicsSystem {
using parent = G4VGraphicsSystem;
public:
G4ToolsSGXtZB();
virtual ~G4ToolsSGXtZB();
protected:
G4ToolsSGXtZB(const G4ToolsSGXtZB& a_from):parent(a_from){}
G4ToolsSGXtZB& operator=(const G4ToolsSGXtZB&) {return *this;}
public:
G4VSceneHandler* CreateSceneHandler(const G4String& name = "");
G4VViewer* CreateViewer (G4VSceneHandler&, const G4String& name = "");
protected:
void Initialise();
protected:
toolx::Xt::session* fSGSession;
};
#endif
@@ -87,15 +87,15 @@ public:
{G4UImanager* ui = G4UImanager::GetUIpointer();
G4UIsession* session = ui->GetG4UIWindow();
G4UIQt* uiQt = session? dynamic_cast<G4UIQt*>(session) :nullptr;
if(uiQt) {
fUIQt = session? dynamic_cast<G4UIQt*>(session) :nullptr;
if(fUIQt) {
G4Qt* interactorManager = G4Qt::getInstance ();
if (!interactorManager->IsExternalApp()) {
fSGViewer->set_own_shell(false);
uiQt->AddTabWidget(fSGQWidget,QString(GetName()));
fUIQt->AddTabWidget(fSGQWidget,QString(GetName()));
QObject::connect(fSGQWidget,SIGNAL(destroyed()),fDestroyCallback,SLOT(execute()));
QMainWindow* main_window = uiQt->GetMainWindow();
QMainWindow* main_window = fUIQt->GetMainWindow();
if(main_window) {
main_window->show();
interactorManager->FlushAndWaitExecution();
@@ -122,8 +122,13 @@ public:
#endif
parent::SetView();
}
virtual void UpdateGUISceneTree() {
if (fUIQt) fUIQt->UpdateSceneTree(fSceneTree);
}
protected:
G4UIQt* fUIQt = nullptr;
QWidget* fSGQWidget;
G4ToolsSGQtDestroyCallback* fDestroyCallback;
};
@@ -0,0 +1,135 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// Guy Barrand 13th April 2023
#ifndef G4TOOLSSGQTZBVIEWER_HH
#define G4TOOLSSGQTZBVIEWER_HH
#include "G4ToolsSGViewer.hh"
#include "G4Qt.hh"
#include "G4UIQt.hh"
#include "G4UImanager.hh"
#include <toolx/Qt/zb_viewer>
#include <qmainwindow.h>
class G4ToolsSGQtZBDestroyCallback : public QObject {
Q_OBJECT
public:
G4ToolsSGQtZBDestroyCallback(G4VViewer* a_viewer):fViewer(a_viewer) {}
virtual ~G4ToolsSGQtZBDestroyCallback() {}
private:
G4ToolsSGQtZBDestroyCallback(const G4ToolsSGQtZBDestroyCallback&);
G4ToolsSGQtZBDestroyCallback& operator=(const G4ToolsSGQtZBDestroyCallback&);
public slots:
void execute(){
delete fViewer;
}
private:
G4VViewer* fViewer;
};
class G4ToolsSGQtZBViewer : public G4ToolsSGViewer<toolx::Qt::session,toolx::Qt::zb_viewer> {
using parent = G4ToolsSGViewer<toolx::Qt::session,toolx::Qt::zb_viewer>;
public:
G4ToolsSGQtZBViewer(toolx::Qt::session& a_session,G4ToolsSGSceneHandler& a_scene_handler, const G4String& a_name)
:parent(a_session,a_scene_handler,a_name)
,fSGQWidget(nullptr)
,fDestroyCallback(0)
{
fDestroyCallback = new G4ToolsSGQtZBDestroyCallback(this);
}
virtual ~G4ToolsSGQtZBViewer() {
delete fDestroyCallback; //it will remove the below signal/slot connection.
}
protected:
G4ToolsSGQtZBViewer(const G4ToolsSGQtZBViewer& a_from):parent(a_from){}
G4ToolsSGQtZBViewer& operator=(const G4ToolsSGQtZBViewer&) {return *this;}
public:
virtual void Initialise() {
if(fSGQWidget) return; //done.
parent::Initialise();
if(!fSGViewer) {
G4cerr << "G4ToolsSGQtZBViewer::Initialise: ERROR: G4ToolsSGQtZBViewer has no toolx::Qt::zb_viewer." << G4endl;
return;
}
fSGQWidget = fSGViewer->shell();
if (!fSGQWidget) {
G4cerr << "G4ToolsSGQtZBViewer::Initialise: ERROR: toolx::Qt::zb_viewer has no QWidget shell." << G4endl;
return;
}
{G4UImanager* ui = G4UImanager::GetUIpointer();
G4UIsession* session = ui->GetG4UIWindow();
fUIQt = session? dynamic_cast<G4UIQt*>(session) :nullptr;
if(fUIQt) {
G4Qt* interactorManager = G4Qt::getInstance ();
if (!interactorManager->IsExternalApp()) {
fSGViewer->set_own_shell(false);
fUIQt->AddTabWidget(fSGQWidget,QString(GetName()));
QObject::connect(fSGQWidget,SIGNAL(destroyed()),fDestroyCallback,SLOT(execute()));
QMainWindow* main_window = fUIQt->GetMainWindow();
if(main_window) {
main_window->show();
interactorManager->FlushAndWaitExecution();
}
}
}}
fSGViewer->enable_keyboard_focus();
}
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();
}
virtual void UpdateGUISceneTree() {
if (fUIQt) fUIQt->UpdateSceneTree(fSceneTree);
}
protected:
G4UIQt* fUIQt = nullptr;
QWidget* fSGQWidget;
G4ToolsSGQtZBDestroyCallback* fDestroyCallback;
};
#endif
+77 -28
View File
@@ -2,10 +2,11 @@
# Define the Geant4 Module.
geant4_add_module(G4ToolsSG
PUBLIC_HEADERS
G4ToolsSGOffscreen.hh
PRIVATE_HEADERS
G4ToolsSGNode.hh
G4ToolsSGSceneHandler.hh
G4ToolsSGViewer.hh
G4ToolsSGOffscreen.hh
G4ToolsSGOffscreenViewer.hh
SOURCES
G4ToolsSGSceneHandler.cc
@@ -13,13 +14,13 @@ geant4_add_module(G4ToolsSG
geant4_module_link_libraries(G4ToolsSG
PUBLIC
G4intercoms
G4modeling
G4vis_management
G4tools
PRIVATE
G4graphics_reps
G4navigation)
G4intercoms
G4modeling
G4navigation
G4tools)
# Freetype support if selected
if(GEANT4_USE_FREETYPE)
@@ -30,63 +31,111 @@ endif()
# X11 sources if selected
if(GEANT4_USE_TOOLSSG_X11_GLES)
geant4_module_sources(G4ToolsSG PUBLIC_HEADERS G4ToolsSGX11GLES.hh SOURCES G4ToolsSGX11GLES.cc)
geant4_module_compile_definitions(G4ToolsSG PUBLIC G4VIS_USE_TOOLSSG_X11_GLES)
endif()
if(GEANT4_USE_TOOLSSG_X11_ZB)
geant4_module_sources(G4ToolsSG PUBLIC_HEADERS G4ToolsSGX11ZB.hh SOURCES G4ToolsSGX11ZB.cc)
geant4_module_compile_definitions(G4ToolsSG PUBLIC G4VIS_USE_TOOLSSG_X11_ZB)
endif()
# Xt sources if selected
if(GEANT4_USE_TOOLSSG_XT_GLES)
geant4_module_sources(G4ToolsSG PUBLIC_HEADERS G4ToolsSGXtGLES.hh SOURCES G4ToolsSGXtGLES.cc)
geant4_module_compile_definitions(G4ToolsSG PRIVATE TOOLS_USE_GL_GL_H)
geant4_module_compile_definitions(G4ToolsSG
PUBLIC G4VIS_USE_TOOLSSG_XT_GLES
PRIVATE TOOLS_USE_GL_GL_H)
geant4_module_link_libraries(G4ToolsSG PRIVATE G4UIimplementation)
endif()
# A minor hack around a likely issue in geant4_module_link_libraries
# When Qt is activated, G4UIcommon is a public dependency. CMake will deduplicate
# this (in favour of PUBLIC at final library link time, but geant4_module_link_libraries
# does not do this internally yet (To be checked). We then get validation
# warnings on duplicated deps. NB: Also demonstrates awkward vis system of more than
# one driver per library...
if(GEANT4_USE_TOOLSSG_QT_GLES)
geant4_module_link_libraries(G4ToolsSG PUBLIC G4UIcommon)
else()
geant4_module_link_libraries(G4ToolsSG PRIVATE G4UIcommon)
endif()
if(GEANT4_USE_TOOLSSG_XT_ZB)
geant4_module_sources(G4ToolsSG PUBLIC_HEADERS G4ToolsSGXtZB.hh SOURCES G4ToolsSGXtZB.cc)
geant4_module_compile_definitions(G4ToolsSG PUBLIC G4VIS_USE_TOOLSSG_XT_ZB)
geant4_module_link_libraries(G4ToolsSG PRIVATE G4UIimplementation)
endif()
# X11/Xt links if selected
if(GEANT4_USE_TOOLSSG_X11_GLES OR GEANT4_USE_TOOLSSG_XT_GLES)
geant4_module_link_libraries(G4ToolsSG PUBLIC X11::SM X11::ICE X11::X11 X11::Xext X11::Xmu)
geant4_module_link_libraries(G4ToolsSG PRIVATE X11::SM X11::ICE X11::X11 X11::Xext X11::Xmu)
if(APPLE)
geant4_module_link_libraries(G4ToolsSG PUBLIC XQuartzGL::GL)
geant4_module_link_libraries(G4ToolsSG PRIVATE XQuartzGL::GL)
else()
geant4_module_link_libraries(G4ToolsSG PUBLIC OpenGL::GL)
geant4_module_link_libraries(G4ToolsSG PRIVATE OpenGL::GL)
endif()
endif()
if(GEANT4_USE_TOOLSSG_X11_ZB OR GEANT4_USE_TOOLSSG_XT_ZB)
geant4_module_link_libraries(G4ToolsSG PRIVATE X11::SM X11::ICE X11::X11 X11::Xext X11::Xmu)
endif()
# Qt sources/links if selected
if(GEANT4_USE_TOOLSSG_QT_GLES)
geant4_module_sources(G4ToolsSG
PUBLIC_HEADERS
G4ToolsSGQtViewer.hh
G4ToolsSGQtGLES.hh
PRIVATE_HEADERS
G4ToolsSGQtViewer.hh
SOURCES
G4ToolsSGQtGLES.cc
G4ToolsSGQtViewer.cc)
geant4_module_compile_definitions(G4ToolsSG PUBLIC G4VIS_USE_TOOLSSG_QT_GLES)
geant4_module_link_libraries(G4ToolsSG
PUBLIC
PRIVATE
Qt${QT_VERSION_MAJOR}::OpenGL
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::PrintSupport
Qt${QT_VERSION_MAJOR}::Widgets
OpenGL::GL
G4UIbasic
G4UIcommon)
G4UIimplementation)
if(QT_VERSION_MAJOR GREATER 5)
geant4_module_link_libraries(G4ToolsSG PRIVATE Qt${QT_VERSION_MAJOR}::OpenGLWidgets)
endif()
# Minor hack for MOC-ing. Qt's moc requires visibility of the private headers
# - Will not affect external consumers and should be minimal impact interanally
# as this is a leaf category
geant4_module_include_directories(G4ToolsSG
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/private>)
endif()
if(GEANT4_USE_TOOLSSG_QT_ZB)
geant4_module_sources(G4ToolsSG
PUBLIC_HEADERS
G4ToolsSGQtZB.hh
PRIVATE_HEADERS
G4ToolsSGQtZBViewer.hh
SOURCES
G4ToolsSGQtZB.cc
G4ToolsSGQtZBViewer.cc)
geant4_module_compile_definitions(G4ToolsSG PUBLIC G4VIS_USE_TOOLSSG_QT_ZB)
geant4_module_link_libraries(G4ToolsSG
PRIVATE
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets
G4UIimplementation)
# Minor hack for MOC-ing. Qt's moc requires visibility of the private headers
# - Will not affect external consumers and should be minimal impact interanally
# as this is a leaf category
geant4_module_include_directories(G4ToolsSG
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/private>)
endif()
# Windows sources if selected
if(GEANT4_USE_TOOLSSG_WINDOWS_GLES)
geant4_module_sources(G4ToolsSG PUBLIC_HEADERS G4ToolsSGWindowsGLES.hh SOURCES G4ToolsSGWindowsGLES.cc)
geant4_module_link_libraries(G4ToolsSG PUBLIC OpenGL::GL)
geant4_module_compile_definitions(G4ToolsSG PUBLIC G4VIS_USE_TOOLSSG_WINDOWS_GLES)
geant4_module_link_libraries(G4ToolsSG PRIVATE OpenGL::GL)
endif()
if(GEANT4_USE_TOOLSSG_WINDOWS_ZB)
geant4_module_sources(G4ToolsSG PUBLIC_HEADERS G4ToolsSGWindowsZB.hh SOURCES G4ToolsSGWindowsZB.cc)
geant4_module_compile_definitions(G4ToolsSG PUBLIC G4VIS_USE_TOOLSSG_WINDOWS_ZB)
endif()
@@ -83,10 +83,3 @@ G4VViewer* G4ToolsSGOffscreen::CreateViewer(G4VSceneHandler& a_scene,const G4Str
}
return pView;
}
G4bool G4ToolsSGOffscreen::IsUISessionCompatible () const
{
//G4bool isCompatible = true;
//return isCompatible;
return true;
}
@@ -27,19 +27,12 @@
#include "G4ToolsSGQtGLES.hh"
#define G4TOOLSSG_QT_VIEWER_IN_TAB
#ifdef G4TOOLSSG_QT_VIEWER_IN_TAB
#include "G4ToolsSGQtViewer.hh"
#else
#include "G4ToolsSGViewer.hh"
#include <toolx/Qt/sg_viewer>
#endif
#include "G4Qt.hh"
#include "G4UIbatch.hh"
#include <tools/argcv>
G4ToolsSGQtGLES::G4ToolsSGQtGLES():
parent
("TOOLSSG_QT_GLES",
@@ -56,11 +49,13 @@ G4ToolsSGQtGLES::~G4ToolsSGQtGLES() {
void G4ToolsSGQtGLES::Initialise() {
if(fSGSession) return; //done.
int* argc = new int;
char** argv = nullptr;
std::vector<std::string> args;args.push_back("");
tools::new_argcv(args,*argc,argv);
fSGSession = new toolx::Qt::session(G4cout,*argc,argv);
G4Qt* interactorManager = G4Qt::getInstance();
auto* _qapp = (QApplication*)interactorManager->GetMainInteractor();
if(!_qapp) {
G4cerr << "G4ToolsSGQtGLES::Initialise : G4Qt::GetMainInteractor() returns null." << G4endl;
return;
}
fSGSession = new toolx::Qt::session(G4cout,_qapp);
if(!fSGSession->is_valid()) {
G4cerr << "G4ToolsSGQtGLES::Initialise : session::is_valid() failed." << G4endl;
delete fSGSession;
@@ -77,12 +72,7 @@ G4VSceneHandler* G4ToolsSGQtGLES::CreateSceneHandler(const G4String& a_name) {
G4VViewer* G4ToolsSGQtGLES::CreateViewer(G4VSceneHandler& a_scene,const G4String& a_name) {
if(!fSGSession) Initialise();
if(!fSGSession) return nullptr;
G4VViewer* pView =
#ifdef G4TOOLSSG_QT_VIEWER_IN_TAB
new G4ToolsSGQtViewer(*fSGSession,(G4ToolsSGSceneHandler&)a_scene,a_name);
#else
new G4ToolsSGViewer<toolx::Qt::session,toolx::Qt::sg_viewer>(*fSGSession,(G4ToolsSGSceneHandler&)a_scene,a_name);
#endif
G4VViewer* pView = new G4ToolsSGQtViewer(*fSGSession,(G4ToolsSGSceneHandler&)a_scene,a_name);
if (pView) {
if (pView->GetViewId() < 0) {
G4cerr << "G4ToolsSGQtGLES::CreateViewer:"
@@ -116,13 +106,10 @@ G4bool G4ToolsSGQtGLES::IsUISessionCompatible () const
}
// 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;
}
// This is the originating non-batch session...
if (dynamic_cast<G4UIQt*>(session)) {
// ...and it's a G4UIQt session, which is OK.
isCompatible = true;
}
return isCompatible;
}
@@ -0,0 +1,115 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// Guy Barrand 13th April 2023
#include "G4ToolsSGQtZB.hh"
#include "G4ToolsSGQtZBViewer.hh"
#include "G4Qt.hh"
#include "G4UIbatch.hh"
G4ToolsSGQtZB::G4ToolsSGQtZB():
parent
("TOOLSSG_QT_ZB",
"TSG_QT_ZB",
"TOOLSSG_QT_ZB is a graphics driver based on the g4tools tools/sg scene graph logic where\n\
the rendering is done with the g4tools zbuffer and the windowing is done with Qt.",
parent::threeDInteractive)
,fSGSession(nullptr)
{}
G4ToolsSGQtZB::~G4ToolsSGQtZB() {
delete fSGSession;
}
void G4ToolsSGQtZB::Initialise() {
if(fSGSession) return; //done.
G4Qt* interactorManager = G4Qt::getInstance();
QApplication* _qapp = (QApplication*)interactorManager->GetMainInteractor();
if(!_qapp) {
G4cerr << "G4ToolsSGQtZB::Initialise : G4Qt::GetMainInteractor() returns null." << G4endl;
return;
}
fSGSession = new toolx::Qt::session(G4cout,_qapp);
if(!fSGSession->is_valid()) {
G4cerr << "G4ToolsSGQtZB::Initialise : session::is_valid() failed." << G4endl;
delete fSGSession;
fSGSession = nullptr;
return;
}
}
G4VSceneHandler* G4ToolsSGQtZB::CreateSceneHandler(const G4String& a_name) {
G4VSceneHandler* pScene = new G4ToolsSGSceneHandler(*this, a_name);
return pScene;
}
G4VViewer* G4ToolsSGQtZB::CreateViewer(G4VSceneHandler& a_scene,const G4String& a_name) {
if(!fSGSession) Initialise();
if(!fSGSession) return nullptr;
G4VViewer* pView = new G4ToolsSGQtZBViewer(*fSGSession,(G4ToolsSGSceneHandler&)a_scene,a_name);
if (pView) {
if (pView->GetViewId() < 0) {
G4cerr << "G4ToolsSGQtZB::CreateViewer:"
<< " ERROR flagged by negative view id in G4ToolsSGViewer creation."
<< "\n Destroying view and returning null pointer." << G4endl;
delete pView;
pView = nullptr;
}
}
if (!pView) {
G4cerr << "G4ToolsSGQtZB::CreateViewer: ERROR: null pointer on new G4ToolsSGViewer." << G4endl;
return nullptr;
}
return pView;
}
G4bool G4ToolsSGQtZB::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.
// This is the originating non-batch session...
if (dynamic_cast<G4UIQt*>(session)) {
// ...and it's a G4UIQt session, which is OK.
isCompatible = true;
}
return isCompatible;
}
@@ -0,0 +1,29 @@
//
// ********************************************************************
// * 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 "G4ToolsSGQtZBViewer.hh"
#include "moc_G4ToolsSGQtZBViewer.cpp"
@@ -84,31 +84,3 @@ G4VViewer* G4ToolsSGWindowsGLES::CreateViewer(G4VSceneHandler& a_scene,const G4S
}
return pView;
}
G4bool G4ToolsSGWindowsGLES::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.
isCompatible = true;
// }
// }
return isCompatible;
}
@@ -0,0 +1,87 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// Guy Barrand 18th April 2023
#include "G4ToolsSGWindowsZB.hh"
#include "G4ToolsSGViewer.hh"
#include <toolx/Windows/zb_viewer>
G4ToolsSGWindowsZB::G4ToolsSGWindowsZB():
parent
("TOOLSSG_WINDOWS_ZB",
"TSG_WINDOWS_ZB",
"TOOLSSG_WINDOWS_ZB is a graphics driver based on the g4tools tools/sg scene graph logic where\n\
the rendering is done with the g4tools zbuffer and the windowing is done with Microsoft Windows.",
parent::threeDInteractive)
,fSGSession(nullptr)
{}
G4ToolsSGWindowsZB::~G4ToolsSGWindowsZB() {
delete fSGSession;
}
void G4ToolsSGWindowsZB::Initialise() {
if(fSGSession) return; //done.
fSGSession = new toolx::Windows::session(G4cout);
if(!fSGSession->is_valid()) {
G4cerr << "G4ToolsSGWindowsZB::Initialise : session::is_valid() failed." << G4endl;
delete fSGSession;
fSGSession = nullptr;
return;
}
}
G4VSceneHandler* G4ToolsSGWindowsZB::CreateSceneHandler(const G4String& a_name) {
G4VSceneHandler* pScene = new G4ToolsSGSceneHandler(*this, a_name);
return pScene;
}
G4VViewer* G4ToolsSGWindowsZB::CreateViewer(G4VSceneHandler& a_scene,const G4String& a_name) {
if(!fSGSession) Initialise();
if(!fSGSession) return nullptr;
G4VViewer* pView =
new G4ToolsSGViewer<toolx::Windows::session,toolx::Windows::zb_viewer>(*fSGSession,(G4ToolsSGSceneHandler&)a_scene,a_name);
if (pView) {
if (pView->GetViewId() < 0) {
G4cerr <<
"G4ToolsSGWindowsZB::CreateViewer: ERROR flagged by negative"
" view id in G4ToolsSGViewer creation."
"\n Destroying view and returning null pointer."
<< G4endl;
delete pView;
pView = nullptr;
}
}
if (!pView) {
G4cerr <<
"G4ToolsSGWindowsZB::CreateViewer: ERROR: null pointer on new G4ToolsSGViewer."
<< G4endl;
}
return pView;
}
@@ -85,31 +85,3 @@ G4VViewer* G4ToolsSGX11GLES::CreateViewer(G4VSceneHandler& a_scene,const G4Strin
}
return pView;
}
G4bool G4ToolsSGX11GLES::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.
isCompatible = true;
// }
// }
return isCompatible;
}
@@ -0,0 +1,87 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// Guy Barrand 14th April 2023
#include "G4ToolsSGX11ZB.hh"
#include "G4ToolsSGViewer.hh"
#include <toolx/X11/zb_viewer>
G4ToolsSGX11ZB::G4ToolsSGX11ZB():
parent
("TOOLSSG_X11_ZB",
"TSG_X11_ZB",
"TOOLSSG_X11_ZB is a graphics driver based on the g4tools tools/sg scene graph logic where\n\
the rendering is done with the g4tools zbuffer and the windowing is done with X11.",
parent::threeDInteractive)
,fSGSession(nullptr)
{}
G4ToolsSGX11ZB::~G4ToolsSGX11ZB() {
delete fSGSession;
}
void G4ToolsSGX11ZB::Initialise() {
if(fSGSession) return; //done.
fSGSession = new toolx::X11::base_session(G4cout);
if(!fSGSession->is_valid()) {
G4cerr << "G4ToolsSGX11ZB::Initialise : base_session::is_valid() failed." << G4endl;
delete fSGSession;
fSGSession = nullptr;
return;
}
}
G4VSceneHandler* G4ToolsSGX11ZB::CreateSceneHandler(const G4String& a_name) {
G4VSceneHandler* pScene = new G4ToolsSGSceneHandler(*this,a_name);
return pScene;
}
G4VViewer* G4ToolsSGX11ZB::CreateViewer(G4VSceneHandler& a_scene,const G4String& a_name) {
if(!fSGSession) Initialise();
if(!fSGSession) return nullptr;
G4VViewer* pView =
new G4ToolsSGViewer<toolx::X11::base_session,toolx::X11::zb_viewer>
(*fSGSession,(G4ToolsSGSceneHandler&)a_scene,a_name);
if (pView) {
if (pView->GetViewId() < 0) {
G4cerr <<
"G4ToolsSGX11ZB::CreateViewer: ERROR flagged by negative"
" view id in G4ToolsSGViewer creation."
"\n Destroying view and returning null pointer."
<< G4endl;
delete pView;
pView = nullptr;
}
}
if (!pView) {
G4cerr <<
"G4ToolsSGX11ZB::CreateViewer: ERROR: null pointer on new G4ToolsSGViewer."
<< G4endl;
}
return pView;
}
@@ -33,15 +33,14 @@
#include "G4Xt.hh"
class session : public toolx::Xt::session {
typedef toolx::Xt::session parent;
using parent = toolx::Xt::session;
public:
session(std::ostream& a_out,int a_argc,char** a_argv)
:parent(a_out,a_argc,a_argv)
session(std::ostream& a_out)
:parent(a_out)
{
if(m_app_widget) {::XtDestroyWidget(m_app_widget);m_app_widget = nullptr;}
if(m_app_context) {::XtDestroyApplicationContext(m_app_context);m_app_context = nullptr;}
m_app_widget = (Widget)G4Xt::getInstance()->GetMainInteractor();
m_app_context = ::XtWidgetToApplicationContext(m_app_widget);
m_app_owner = false;
}
virtual ~session() {}
protected:
@@ -49,8 +48,6 @@ protected:
session& operator=(const session& a_from){parent::operator=(a_from);return *this;}
};
#include <tools/argcv>
G4ToolsSGXtGLES::G4ToolsSGXtGLES():
parent
("TOOLSSG_XT_GLES",
@@ -67,10 +64,7 @@ G4ToolsSGXtGLES::~G4ToolsSGXtGLES() {
void G4ToolsSGXtGLES::Initialise() {
if(fSGSession) return; //done.
int* argc = new int;
char** argv = nullptr;
tools::new_argcv(std::vector<std::string>(),*argc,argv);
fSGSession = new session(G4cout,*argc,argv);
fSGSession = new session(G4cout);
if(!fSGSession->is_valid()) {
G4cerr << "G4ToolsSGXtGLES::Initialise : session::is_valid() failed." << G4endl;
delete fSGSession;
@@ -107,31 +101,3 @@ G4VViewer* G4ToolsSGXtGLES::CreateViewer(G4VSceneHandler& a_scene,const G4String
}
return pView;
}
G4bool G4ToolsSGXtGLES::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.
isCompatible = true;
// }
// }
return isCompatible;
}
@@ -0,0 +1,103 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// Guy Barrand 14th April 2023
#include "G4ToolsSGXtZB.hh"
#include "G4ToolsSGViewer.hh"
#include "G4Xt.hh"
#include <toolx/Xt/zb_viewer>
class session : public toolx::Xt::session {
using parent = toolx::Xt::session;
public:
session(std::ostream& a_out)
:parent(a_out)
{
m_app_widget = (Widget)G4Xt::getInstance()->GetMainInteractor();
m_app_context = ::XtWidgetToApplicationContext(m_app_widget);
m_app_owner = false;
}
virtual ~session() {}
protected:
session(const session& a_from):parent(a_from){}
session& operator=(const session& a_from){parent::operator=(a_from);return *this;}
};
G4ToolsSGXtZB::G4ToolsSGXtZB():
parent
("TOOLSSG_XT_ZB",
"TSG_XT_ZB",
"TOOLSSG_XT_ZB is a graphics driver based on the g4tools tools/sg scene graph logic where\n\
the rendering is done with the g4tools zbuffer and the windowing is done with the Xt toolkit.",
parent::threeDInteractive)
,fSGSession(nullptr)
{}
G4ToolsSGXtZB::~G4ToolsSGXtZB() {
delete fSGSession;
}
void G4ToolsSGXtZB::Initialise() {
if(fSGSession) return; //done.
fSGSession = new session(G4cout);
if(!fSGSession->is_valid()) {
G4cerr << "G4ToolsSGXtZB::Initialise : session::is_valid() failed." << G4endl;
delete fSGSession;
fSGSession = nullptr;
return;
}
}
G4VSceneHandler* G4ToolsSGXtZB::CreateSceneHandler(const G4String& a_name) {
G4VSceneHandler* pScene = new G4ToolsSGSceneHandler(*this, a_name);
return pScene;
}
G4VViewer* G4ToolsSGXtZB::CreateViewer(G4VSceneHandler& a_scene,const G4String& a_name) {
if(!fSGSession) Initialise();
if(!fSGSession) return nullptr;
G4VViewer* pView =
new G4ToolsSGViewer<toolx::Xt::session,toolx::Xt::zb_viewer>(*fSGSession,(G4ToolsSGSceneHandler&)a_scene,a_name);
if (pView) {
if (pView->GetViewId() < 0) {
G4cerr <<
"G4ToolsSGXtZB::CreateViewer: ERROR flagged by negative"
" view id in G4ToolsSGViewer creation."
"\n Destroying view and returning null pointer."
<< G4endl;
delete pView;
pView = nullptr;
}
}
if (!pView) {
G4cerr <<
"G4ToolsSGXtZB::CreateViewer: ERROR: null pointer on new G4ToolsSGViewer."
<< G4endl;
}
return pView;
}