VTK  9.3.20240419
QVTKInteractorAdapter.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-FileCopyrightText: Copyright 2004 Sandia Corporation
3 // SPDX-License-Identifier: LicenseRef-BSD-3-Clause-Sandia-USGov
4 
5 /*========================================================================
6  For general information about using VTK and Qt, see:
7  http://www.trolltech.com/products/3rdparty/vtksupport.html
8 =========================================================================*/
9 
10 // .NAME QVTKInteractorAdapter - Handle Qt events.
11 // .SECTION Description
12 // QVTKInteractor handles relaying Qt events to VTK.
13 
14 #ifndef Q_VTK_INTERACTOR_ADAPTER_H
15 #define Q_VTK_INTERACTOR_ADAPTER_H
16 
17 #include "QVTKWin32Header.h"
18 #include "vtkGUISupportQtModule.h" // For export macro
19 #include <QtCore/QObject>
20 
21 class QEvent;
22 
23 VTK_ABI_NAMESPACE_BEGIN
25 
26 // .NAME QVTKInteractorAdapter - A QEvent translator.
27 // .SECTION Description
28 // QVTKInteractorAdapter translates QEvents and send them to a
29 // vtkRenderWindowInteractor.
30 class VTKGUISUPPORTQT_EXPORT QVTKInteractorAdapter : public QObject
31 {
32  Q_OBJECT
33 public:
34  // Description:
35  // Constructor: takes QObject parent
36  QVTKInteractorAdapter(QObject* parent = nullptr);
37 
38  // Description:
39  // Destructor
41 
42  // Description:
43  // Set the device pixel ratio, this defaults to 1.0, but in Qt 5 can be != 1.0.
44  void SetDevicePixelRatio(float ratio, vtkRenderWindowInteractor* iren = nullptr);
45  float GetDevicePixelRatio() { return this->DevicePixelRatio; }
46 
47  // Description:
48  // Process a QEvent and send it to the interactor
49  // returns whether the event was recognized and processed
50  bool ProcessEvent(QEvent* e, vtkRenderWindowInteractor* iren);
51 
52 protected:
55  static const double DevicePixelRatioTolerance;
56 };
57 
58 VTK_ABI_NAMESPACE_END
59 #endif
60 // VTK-HeaderTest-Exclude: QVTKInteractorAdapter.h
void SetDevicePixelRatio(float ratio, vtkRenderWindowInteractor *iren=nullptr)
static const double DevicePixelRatioTolerance
QVTKInteractorAdapter(QObject *parent=nullptr)
~QVTKInteractorAdapter() override
bool ProcessEvent(QEvent *e, vtkRenderWindowInteractor *iren)
platform-independent render window interaction including picking and frame rate control.