Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4VtkQtViewer.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25
26#ifndef G4VTKQTVIEWER_HH
27#define G4VTKQTVIEWER_HH
28
29// #define G4VTKDEBUG // Comment this out to suppress debug code.
30
31#include "G4VViewer.hh"
32
33class G4UIManager;
34class G4UIQt;
35
36class QString;
37class QWidget;
38class QLineEdit;
39class QSlider;
40class QTreeWidget;
41class QTreeWidgetItem;
42
43#include "G4VtkViewer.hh"
44
45#include "QVTKOpenGLNativeWidget.h"
46
47#include <map>
48#include <vector>
49
50class G4VtkQtViewer : public QVTKOpenGLNativeWidget, public G4VtkViewer
51{
52 public:
54 using PVPath = std::vector<PVNodeID>;
55
56 public:
58 ~G4VtkQtViewer() override;
59 void Initialise() override;
60 virtual void CreateMainWindow(QVTKOpenGLNativeWidget*, const QString&);
61#ifdef G4MULTITHREADED
62 // In MT mode these functions are called in the following order for each run:
63 // Called on the master thread before starting the vis sub-thread.
64 void DoneWithMasterThread() override;
65 // Called on the master thread after starting the vis sub-thread.
66 void MovingToVisSubThread() override;
67 // Called on the vis sub-thread when waiting for events.
68 void SwitchToVisSubThread() override;
69 // Called on the vis sub-thread when all events have been processed.
70 void DoneWithVisSubThread() override;
71 // Called on the vis sub-thread when all events have been processed.
72 // virtual void MovingToMasterThread (); Not used in G4OpenGLQtViewer.
73 // Called on the master thread after the vis sub-thread has terminated.
74 void SwitchToMasterThread() override;
75
76 inline void SetQGLContextVisSubThread(QThread* th) { fQGLContextVisSubThread = th; }
77 inline void SetQGLContextMainThread(QThread* th) { fQGLContextMainThread = th; }
78#endif
79
80 void FinishView() override;
83 QTreeWidgetItem* createTreeWidgetItem(const PVPath& fullPath, const QString& name, int copyNb,
84 int POIndex, const QString& logicalName,
85 Qt::CheckState state, QTreeWidgetItem* parentTreeNode,
86 const G4Colour& color);
87 void addNonPVSceneTreeElement(const G4String& model, G4Visible& visible, int currentPOIndex);
88 void addPVSceneTreeElement(const G4String& model, G4PhysicalVolumeModel* pPVModel,
89 int currentPOIndex);
90
91 QString getModelShortName(const G4String& model);
92 bool parseAndInsertInSceneTree(QTreeWidgetItem* parentItem, G4PhysicalVolumeModel* pPVModel,
93 unsigned int fullPathIndex, const QString& parentRoot,
94 unsigned int currentIndexInTreeSceneHandler,
95 int currentPVPOIndex);
96
97 void EnableClipperWidget() override;
98
99 void SetWidgetInteractor(vtkAbstractWidget* widget) override;
100
101 private:
102 G4UIQt* fUiQt;
103 QWidget* fGLWidget;
104
105#ifdef G4MULTITHREADED
106 QThread* fQGLContextVisSubThread;
107 QThread* fQGLContextMainThread;
108#endif
109
110 // safe to use in serial mode
111 G4AutoLock* lWaitForVisSubThreadQtOpenGLContextInitialized;
112 G4AutoLock* lWaitForVisSubThreadQtOpenGLContextMoved;
113};
114
115#endif
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)