Commit 0fbcab87 authored by Sankhesh Jhaveri's avatar Sankhesh Jhaveri 💬 Committed by Kitware Robot
Browse files

Merge topic 'update_qt_test'

d9627592 Port the TestQtSwapWindows test to use modern QVTKOpenGLWidget
03168839

 Create a default render window for the QVTKOpenGLWidget
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !3643
parents 4810b281 d9627592
......@@ -226,6 +226,13 @@ void QVTKOpenGLWidget::startEventCallback()
//-----------------------------------------------------------------------------
vtkRenderWindow* QVTKOpenGLWidget::GetRenderWindow()
{
if (!this->RenderWindow)
{
// create a default
vtkGenericOpenGLRenderWindow* win = vtkGenericOpenGLRenderWindow::New();
this->SetRenderWindow(win);
win->Delete();
}
return this->RenderWindow;
}
......
......@@ -131,6 +131,8 @@ public:
//@{
/**
* Get/Set the currently used vtkGenericOpenGLRenderWindow.
* GetRenderWindow() creates and returns a new vtkGenericOpenGLRenderWindow
* if it is not already provided.
*/
void SetRenderWindow(vtkGenericOpenGLRenderWindow* win);
void SetRenderWindow(vtkRenderWindow* win);
......
......@@ -17,6 +17,7 @@ if(VTK_QT_VERSION VERSION_GREATER "4" AND
vtk_add_test_cxx(${vtk-module}CxxTests tests
NO_VALID
TestQVTKOpenGLWidgetPicking.cxx
TestQtSwapWindows.cxx
)
endif()
......@@ -27,9 +28,6 @@ if(NOT VTK_LEGACY_REMOVE)
NO_VALID
TestWin32QVTKWidget.cxx)
endif()
vtk_add_test_cxx(${vtk-module}CxxTests tests
NO_VALID
TestQtSwapWindows.cxx)
endif()
if(VTK_QT_VERSION VERSION_GREATER "4")
......
#include <QVTKWidget.h>
#include <QApplication>
#include <QWidget>
#include <QBoxLayout>
#include <QVTKOpenGLWidget.h>
#include <QWidget>
#include <vtkNew.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkSmartPointer.h>
#include <vtkNew.h>
int TestQtSwapWindows(int argc, char* argv[])
{
QSurfaceFormat::setDefaultFormat(QVTKOpenGLWidget::defaultFormat());
QApplication app(argc, argv);
// Set up frame with two horizontally stacked panels,
// Each containg a QVTKWidget
// Each containg a QVTKOpenGLWidget
QWidget frame;
QHBoxLayout *layout = new QHBoxLayout(&frame);
QWidget *leftPanel = new QWidget(&frame);
QVBoxLayout *leftLayout = new QVBoxLayout(leftPanel);
QVTKWidget *leftVTKWidget = new QVTKWidget(leftPanel);
QVTKOpenGLWidget *leftVTKWidget = new QVTKOpenGLWidget(leftPanel);
vtkSmartPointer<vtkRenderer> leftRenderer = vtkSmartPointer<vtkRenderer>::New();
leftRenderer->SetBackground(1, 0, 0);
leftVTKWidget->GetRenderWindow()->AddRenderer(leftRenderer);
......@@ -26,7 +27,7 @@ int TestQtSwapWindows(int argc, char* argv[])
QWidget *rightPanel = new QWidget(&frame);
QVBoxLayout *rightLayout = new QVBoxLayout(rightPanel);
QVTKWidget *rightVTKWidget = new QVTKWidget(rightPanel);
QVTKOpenGLWidget *rightVTKWidget = new QVTKOpenGLWidget(rightPanel);
vtkSmartPointer<vtkRenderer> rightRenderer = vtkSmartPointer<vtkRenderer>::New();
rightRenderer->SetBackground(0, 1, 0);
rightVTKWidget->GetRenderWindow()->AddRenderer(rightRenderer);
......
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