[vtkusers] QVTKWidget with vtkImageViewer2 glitch
J.S.Wijnhout at lumc.nl
J.S.Wijnhout at lumc.nl
Wed Feb 25 05:19:13 EST 2009
Hi,
For starters, I have read the thread on this issue:
http://www.vtk.org/pipermail/vtkusers/2008-November/098242.html
However I managed to get vtkImageViewer2 working inside a QVTKWidget, with one glitch however. The sample code is printed at the bottom of the screen.
The way I got this to work relies on the order in which calls to Render and SetRenderWindow are made. First I render the image viewer by calling vtkImageViewer2::Render, after that I attach the image viewer render window to the QVTKWidget. This works, but because I call render first a separate render window is created and then (after the call to QVTKWidget::SetRenderWindow) reparented to the QVTKWidget. This happens really fast, so I guess I could live with it. But it keeps me wondering what I should do to have it functioning properly. Any advice on how to circumvent or fix vtkImageViewer2 would be welcome.
best,
Jeroen
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkImageViewer2.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkPNGReader.h>
#include <QVTKWidget.h>
#include <QApplication>
#include <QMainWindow>
#include <QStatusBar>
int main ( int argc, char **argv )
{
QApplication app(argc,argv);
const char* fileName = argv[1];
QMainWindow w;
w.statusBar()->showMessage(fileName);
QVTKWidget vtkWidget;
vtkWidget.setAutomaticImageCacheEnabled(false);
w.setCentralWidget(&vtkWidget);
vtkPNGReader *reader1 = vtkPNGReader::New ();
reader1->SetFileName(fileName);
reader1->Update ();
vtkImageViewer2 *viewer1 = vtkImageViewer2::New ();
viewer1->SetInput(reader1->GetOutput());
viewer1->SetupInteractor(vtkWidget.GetInteractor());
viewer1->Render ();
viewer1->SetRenderWindow(vtkWidget.GetRenderWindow());
w.show ();
app.exec ();
viewer1->Delete ();
reader1->Delete ();
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090225/f931870f/attachment.htm>
More information about the vtkusers
mailing list