1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-FileCopyrightText: Copyright 2004 Sandia Corporation
// SPDX-License-Identifier: LicenseRef-BSD-3-Clause-Sandia-USGov
/*========================================================================
For general information about using VTK and Qt, see:
http://www.trolltech.com/products/3rdparty/vtksupport.html
=========================================================================*/
/*========================================================================
!!! WARNING for those who want to contribute code to this file.
!!! If you use a commercial edition of Qt, you can modify this code.
!!! If you use an open source version of Qt, you are free to modify
!!! and use this code within the guidelines of the GPL license.
!!! Unfortunately, you cannot contribute the changes back into this
!!! file. Doing so creates a conflict between the GPL and BSD-like VTK
!!! license.
=========================================================================*/
#include <QtGui/QSurfaceFormat>
#include <QtWidgets/QApplication>
#include "vtkGenericOpenGLRenderWindow.h"
#include "vtkImageViewer.h"
#include "vtkPNGReader.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkTestUtilities.h"
#include "QVTKRenderWidget.h"
int main(int argc, char** argv)
{
// set surface format before application initialization
QSurfaceFormat::setDefaultFormat(QVTKRenderWidget::defaultFormat());
QApplication app(argc, argv);
QVTKRenderWidget widget;
widget.resize(256, 256);
vtkNew<vtkGenericOpenGLRenderWindow> renWin;
widget.setRenderWindow(renWin);
vtkNew<vtkPNGReader> reader;
char* fname = vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/vtk.png");
reader->SetFileName(fname);
delete[] fname;
vtkNew<vtkImageViewer> image_view;
// use our render window with image_view
image_view->SetRenderWindow(renWin);
image_view->SetInputConnection(reader->GetOutputPort());
image_view->SetupInteractor(renWin->GetInteractor());
image_view->SetColorLevel(138.5);
image_view->SetColorWindow(233);
widget.show();
app.exec();
return 0;
}
|