37#include <qcoreapplication.h>
41#include <qopenglcontext.h>
42#include <qpushbutton.h>
44#include <qtreewidget.h>
47#include <vtkCylinderSource.h>
48#include <vtkGenericOpenGLRenderWindow.h>
49#include <vtkNamedColors.h>
51#include <vtkPolyDataMapper.h>
52#include <vtkProperty.h>
53#include <vtkRenderer.h>
54#include <vtkVersion.h>
72 lWaitForVisSubThreadQtOpenGLContextInitialized =
73 new G4AutoLock(mWaitForVisSubThreadQtOpenGLContextInitialized, std::defer_lock);
74 lWaitForVisSubThreadQtOpenGLContextMoved =
75 new G4AutoLock(mWaitForVisSubThreadQtOpenGLContextMoved, std::defer_lock);
83 delete lWaitForVisSubThreadQtOpenGLContextInitialized;
84 delete lWaitForVisSubThreadQtOpenGLContextMoved;
102 renderer->SetUseHiddenLineRemoval(0);
109 this->interactor()->SetInteractorStyle(style);
117 vtkWidget->setAttribute(Qt::WA_AcceptTouchEvents,
false);
118 fGLWidget = vtkWidget;
122#ifdef G4MULTITHREADED
124void G4VtkQtViewer::DoneWithMasterThread()
130 if (!lWaitForVisSubThreadQtOpenGLContextInitialized->
owns_lock())
131 lWaitForVisSubThreadQtOpenGLContextInitialized->
lock();
134void G4VtkQtViewer::SwitchToVisSubThread()
138 auto qGLW =
dynamic_cast<QVTKOpenGLNativeWidget*
>(fGLWidget);
139 if (qGLW ==
nullptr) {
144 SetQGLContextVisSubThread(QThread::currentThread());
150 if (!lWaitForVisSubThreadQtOpenGLContextMoved->
owns_lock())
151 lWaitForVisSubThreadQtOpenGLContextMoved->
lock();
154 G4CONDITIONWAIT(&c2_VisSubThreadQtOpenGLContextMoved, lWaitForVisSubThreadQtOpenGLContextMoved);
160void G4VtkQtViewer::DoneWithVisSubThread()
163 auto qGLW =
dynamic_cast<QVTKOpenGLNativeWidget*
>(fGLWidget);
164 if (qGLW ==
nullptr) {
172 qGLW->context()->moveToThread(fQGLContextMainThread);
175void G4VtkQtViewer::SwitchToMasterThread()
179 auto qGLW =
dynamic_cast<QVTKOpenGLNativeWidget*
>(fGLWidget);
180 if (qGLW ==
nullptr) {
186 if (lWaitForVisSubThreadQtOpenGLContextInitialized->
owns_lock())
187 lWaitForVisSubThreadQtOpenGLContextInitialized->
unlock();
192void G4VtkQtViewer::MovingToVisSubThread()
196 auto qGLW =
dynamic_cast<QVTKOpenGLNativeWidget*
>(fGLWidget);
197 if (qGLW ==
nullptr) {
203 if (!lWaitForVisSubThreadQtOpenGLContextInitialized->
owns_lock())
204 lWaitForVisSubThreadQtOpenGLContextInitialized->
lock();
208 lWaitForVisSubThreadQtOpenGLContextInitialized);
211 SetQGLContextMainThread(QThread::currentThread());
215 qGLW->context()->moveToThread(fQGLContextVisSubThread);
227 auto qGLW =
dynamic_cast<QVTKOpenGLNativeWidget*
>(fGLWidget);
228 qGLW->interactor()->Initialize();
229 qGLW->interactor()->Start();
238 int ,
int ,
const QString& ,
239 Qt::CheckState , QTreeWidgetItem* ,
242 QTreeWidgetItem* newItem =
nullptr;
257 QString modelShortName;
258 return modelShortName;
274 auto qGLW =
dynamic_cast<QVTKOpenGLNativeWidget*
>(fGLWidget);
275 qGLW->interactor()->Initialize();
280 auto qGLW =
dynamic_cast<QVTKOpenGLNativeWidget*
>(fGLWidget);
281 widget->SetInteractor(qGLW->interactor());
G4TemplateAutoLock< G4Mutex > G4AutoLock
#define G4CONDITION_INITIALIZER
#define G4MUTEX_INITIALIZER
#define G4CONDITIONWAIT(cond, mutex)
#define G4CONDITIONBROADCAST(cond)
static G4Qt * getInstance()
bool owns_lock() const noexcept
G4bool AddTabWidget(QWidget *, QString)
G4UIsession * GetG4UIWindow() const
static G4UImanager * GetUIpointer()
const G4String & GetName() const
G4VSceneHandler & fSceneHandler
void addNonPVSceneTreeElement(const G4String &model, G4Visible &visible, int currentPOIndex)
void createSceneTreeWidget()
~G4VtkQtViewer() override
virtual void CreateMainWindow(QVTKOpenGLNativeWidget *, const QString &)
bool parseAndInsertInSceneTree(QTreeWidgetItem *parentItem, G4PhysicalVolumeModel *pPVModel, unsigned int fullPathIndex, const QString &parentRoot, unsigned int currentIndexInTreeSceneHandler, int currentPVPOIndex)
QString getModelShortName(const G4String &model)
void Initialise() override
G4VtkQtViewer(G4VSceneHandler &, const G4String &name)
std::vector< PVNodeID > PVPath
void SetWidgetInteractor(vtkAbstractWidget *widget) override
void EnableClipperWidget() override
void createSceneTreeComponent()
void addPVSceneTreeElement(const G4String &model, G4PhysicalVolumeModel *pPVModel, int currentPOIndex)
void FinishView() override
QTreeWidgetItem * createTreeWidgetItem(const PVPath &fullPath, const QString &name, int copyNb, int POIndex, const QString &logicalName, Qt::CheckState state, QTreeWidgetItem *parentTreeNode, const G4Colour &color)
vtkNew< vtkGeant4Callback > geant4Callback
virtual void EnableClipperWidget()
vtkNew< vtkRenderer > renderer
vtkRenderWindow * _renderWindow