Commit 4a674320 authored by Krupcale, Matthew's avatar Krupcale, Matthew
Browse files

radixwidgets: add support for VTK 9

Add support for building with VTK 9. QVTKOpenGLWidget is deprecated since VTK 9
and is now only a wrapper for QVTKOpenGLStereoWidget [1]. Thus, use the preferred
and versatile QVTKOpenGLNativeWidget [2] instead for VTK_MAJOR_VERSION >= 8.

 * radixwidgets/vtkchartwidget.hh: include appropriate
   QVTKOpenGL{,Native}Widget.h header and create typedef QVTKWidget_t based on
   VTK version
 * radixwidgets/examples/radixvtkchartwidget.cc: likewise.
 * radixwidgets/examples/radixvtkerrorbars.cc: use QVTKWidget_t
 * radixwidgets/vtkchartwidget.cc: likewise.

[1] https://vtk.org/doc/nightly/html/classQVTKOpenGLWidget.html
[2] https://vtk.org/doc/nightly/html/classQVTKOpenGLNativeWidget.html
parent 28729700
Pipeline #160573 passed with stages
in 19 minutes and 11 seconds
......@@ -9,7 +9,14 @@ VTK_MODULE_INIT(vtkRenderingOpenGL2)
VTK_MODULE_INIT(vtkInteractionStyle)
VTK_MODULE_INIT(vtkRenderingFreeType)
#include "vtkVersionMacros.h"
#if VTK_MAJOR_VERSION < 9
#include "QVTKOpenGLWidget.h"
typedef QVTKOpenGLWidget QVTKWidget_t;
#else
#include "QVTKOpenGLNativeWidget.h"
typedef QVTKOpenGLNativeWidget QVTKWidget_t;
#endif
#include "vtkChartXY.h"
#include "vtkContextScene.h"
#include "vtkContextView.h"
......@@ -44,9 +51,9 @@ MainWindow::MainWindow(QWidget *parent)
{
setGeometry(400, 250, 542, 390);
// needed to ensure appropriate OpenGL context is created for VTK rendering.
QSurfaceFormat::setDefaultFormat(QVTKOpenGLWidget::defaultFormat());
QSurfaceFormat::setDefaultFormat(QVTKWidget_t::defaultFormat());
QVTKOpenGLWidget *qvtkWidget = new QVTKOpenGLWidget(this);
QVTKWidget_t *qvtkWidget = new QVTKWidget_t(this);
vtkNew<vtkGenericOpenGLRenderWindow> renderWindow;
qvtkWidget->SetRenderWindow(renderWindow);
......
......@@ -24,7 +24,7 @@ vtkChartMainWindow::vtkChartMainWindow(QWidget* parent)
{
setGeometry(400, 250, 542, 390);
// needed to ensure appropriate OpenGL context is created for VTK rendering.
QSurfaceFormat::setDefaultFormat(QVTKOpenGLWidget::defaultFormat());
QSurfaceFormat::setDefaultFormat(QVTKWidget_t::defaultFormat());
// Test widget
QWidget* widget = new QWidget(this);
......
......@@ -15,7 +15,7 @@ namespace radix
double VTKChartWidget::mDefaultBackground[3] = {1.0, 1.0, 1.0};
VTKChartWidget::VTKChartWidget(QWidget *parent)
: QVTKOpenGLWidget(parent)
: QVTKWidget_t(parent)
{
mChartXY = vtkSmartPointer<vtkChartXY>::New();
mContextView = vtkSmartPointer<vtkContextView>::New();
......
#ifndef RADIX_RADIXWIDGETS_VTKCHARTWIDGET_HH_
#define RADIX_RADIXWIDGETS_VTKCHARTWIDGET_HH_
#include <vtkVersionMacros.h>
#if VTK_MAJOR_VERSION < 9
#include <QVTKOpenGLWidget.h>
#include <QVTKWidget.h>
typedef QVTKOpenGLWidget QVTKWidget_t;
#else
#include <QVTKOpenGLNativeWidget.h>
typedef QVTKOpenGLNativeWidget QVTKWidget_t;
#endif
#include <vtkChartXY.h>
#include <vtkContextScene.h>
#include <vtkContextView.h>
......@@ -16,7 +23,7 @@
namespace radix
{
class RADIX_PUBLIC VTKChartWidget : public QVTKOpenGLWidget
class RADIX_PUBLIC VTKChartWidget : public QVTKWidget_t
{
Q_OBJECT
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment