Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4VtkQtViewer.cc
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#include "G4VSceneHandler.hh"
27
28#include "G4VtkQtViewer.hh"
30
31#include "G4UImanager.hh"
32#include "G4UIQt.hh"
33#include "G4Qt.hh"
34
35#include <array>
36#include "vtkVersion.h"
37#include "vtkNew.h"
38#include "vtkNamedColors.h"
39#include "vtkCylinderSource.h"
40#include "vtkPolyDataMapper.h"
41#include "vtkProperty.h"
42#include "vtkCamera.h"
43#include "vtkActor.h"
44#include "vtkRenderer.h"
45#include "vtkGenericOpenGLRenderWindow.h"
46
48 G4VtkViewer(sceneHandler, name) {
49}
50
52
54{
55 CreateMainWindow(this, QString(GetName()));
56
57 // Specific GL render window and interactor for Qt
58 _renderWindow = vtkGenericOpenGLRenderWindow::New();
59 renderWindowInteractor = vtkRenderWindowInteractor::New();
60
61 _renderWindow->AddRenderer(renderer);
62#if VTK_MAJOR_VERSION == 8
63 this->SetRenderWindow(_renderWindow);
64#else
65 this->setRenderWindow(_renderWindow);
66#endif
67
68 // Set callback to match VTK parameters to Geant4
69 geant4Callback->SetGeant4ViewParameters(&fVP);
70 renderer->AddObserver(vtkCommand::EndEvent, geant4Callback);
71}
72
73void G4VtkQtViewer::CreateMainWindow(QVTKOpenGLNativeWidget *vtkWidget,
74 const QString& name) {
75 // G4Qt* interactorManager = G4Qt::getInstance ();
77 fUiQt = static_cast<G4UIQt*> (UI->GetG4UIWindow());
78 fUiQt->AddTabWidget((QWidget*)vtkWidget,name);
79}
80
82{
84 // force a widget repaint as there should already
85 // be a rendered buffer when visualiser starts up
86 // paintGL();
87 // repaint();
88}
G4bool AddTabWidget(QWidget *, QString)
Definition: G4UIQt.cc:1860
G4UIsession * GetG4UIWindow() const
Definition: G4UImanager.hh:188
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
const G4String & GetName() const
G4ViewParameters fVP
Definition: G4VViewer.hh:220
virtual ~G4VtkQtViewer()
virtual void CreateMainWindow(QVTKOpenGLNativeWidget *, const QString &)
G4VtkQtViewer(G4VSceneHandler &, const G4String &name)
vtkNew< vtkGeant4Callback > geant4Callback
Definition: G4VtkViewer.hh:183
vtkRenderWindowInteractor * renderWindowInteractor
Definition: G4VtkViewer.hh:188
vtkNew< vtkRenderer > renderer
Definition: G4VtkViewer.hh:186
void FinishView()
Definition: G4VtkViewer.cc:321
vtkRenderWindow * _renderWindow
Definition: G4VtkViewer.hh:187