[vtkusers] QVTKWidget with vtkImageViewer2 glitch

J.S.Wijnhout at lumc.nl J.S.Wijnhout at lumc.nl
Wed Mar 4 04:26:25 EST 2009


 
>Or perhaps the weird resize problems is because you're potentially interfering with Qt's work of managing the resizes.  I can't 
>remember which, but on some windowing systems, it leads to undesirable/unecessary recursive behavior.
>Please remove your calls to SetSize and SetPosition.

Actually I added those to get rid of the problems. It seemed to help the initialization problem, however the resizing problem did not change at all.

>And when you submit bug reports, please give a complete and simple example.  There's no way to reproduce it otherwise, as it 
>works fine for me in several other apps in compiz.

Done, I've attached a test case to the bug report.
http://public.kitware.com/Bug/view.php?id=8648

>As said before, vtkImageViewer2 assumes no GUI on the first render.

The resizing problem is not related to the image viewer, but rather the QVTKWidget.

Best,
Jeroen

J.S.Wijnhout at lumc.nl wrote:
> Hi,
>
> A short update: The weird resize problems were caused by the 
> interaction of the QVTKWidget with a composite window manager (compiz 
> on Ubuntu 8.10). On a regular (or should I say, old fashioned) window 
> manager the QVTKWidget works all right.
>
> I have reported this as an issue:
> http://public.kitware.com/Bug/view.php?id=8648
>
> best,
> Jeroen
>
> ----------------------------------------------------------------------
> --
> *From:* vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] *On 
> Behalf Of * J.S.Wijnhout at lumc.nl
> *Sent:* Friday, February 27, 2009 1:42 PM
> *To:* vtkusers at vtk.org
> *Subject:* Re: [vtkusers] QVTKWidget with vtkImageViewer2 glitch
>
> Thank for the pointer. Since setting the size of the image viewer is 
> apparently the problem I created a custom QVTKWidget that embeds an 
> vtkImageViewer2. The implementation is basically:
>
> ImageViewerWidget::ImageViewerWidget(QWidget *_parent) : 
> QVTKWidget(_parent)
> {
>     m_imageViewer = vtkImageViewer2::New (); }
>
> void ImageViewerWidget::SetInput ( vtkImageData *_image ) {
>     m_imageViewer->SetInput ( _image );
>     m_imageViewer->SetupInteractor(GetInteractor());   
>     m_imageViewer->SetRenderWindow(GetRenderWindow());
>     m_imageViewer->UpdateDisplayExtent (); }
>
> void ImageViewerWidget::resizeEvent ( QResizeEvent * event ) {
>     QVTKWidget::resizeEvent(event);
>     m_imageViewer->SetSize(width(),height());
>     m_imageViewer->SetPosition(x(),y());
>     m_imageViewer->UpdateDisplayExtent ();   
> }
>
> void ImageViewerWidget::showEvent ( QShowEvent * event ) {
>     QVTKWidget::showEvent(event);
>     m_imageViewer->SetSize(width(),height());
>     m_imageViewer->SetPosition(x(),y());
>     m_imageViewer->UpdateDisplayExtent (); }
>
> This gets rid of the problems I mentioned, because the size is set 
> explicitly on a show and resize event.
>
> However, there is a new problem that occurs only when there are 
> multiple QVTKWidgets around. Upon starting the application (I have 
> four QVTKWidgets in a grid layout), a random number of widgets 
> actually show up (sometimes all four, but usually only two or three).
> After, seemingly, an arbitrary number of resize actions one or more 
> QVTKWidgets become defunctional (it stops resizing and does not 
> respond to input any more). When you click on a defunctional 
> QVTKWidget, the whole desktop screen flickers once. It almost seems as 
> if there can be only on QVTKWidget because the first QVTKWidget that 
> is initialized always remains working.
>
> best,
> Jeroen
>
> --
> Leiden University Medical Center
> Image Processing Division
>
>
>
> -----Original Message-----
> From: Clinton Stimpson [mailto:clinton at elemtech.com]
> Sent: Wed 2/25/2009 7:06 PM
> To: Wijnhout, J.S. (LKEB)
> Cc: vtkusers at vtk.org
> Subject: Re: [vtkusers] QVTKWidget with vtkImageViewer2 glitch
>
>
> Here's what I understand is happening.
>
> vtkImageViewer2::Render assumes it can change the size of the window 
> and places the image accordingly.
> When embedded in a GUI, the size of the window can't always be 
> changed, so the image shows up in the wrong place based on what it 
> thought the window size was.
> Your workaround give vtkImageViewer2 a chance to successfully resize a 
> window and initialize the camera properly based on that, then you 
> replaced the window and kept the correctly initialized camera.
>
> There are probably other workarounds, such as fixing the camera 
> yourself.  I'd file a bug against vtkImageViewer2.
>
> Clint
>
>
> J.S.Wijnhout at lumc.nl wrote:
> > 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 ();
> > }
> >
> >
> > 
> > --------------------------------------------------------------------
> > ----
> >
> > _______________________________________________
> > Powered by www.kitware.com
> >
> > Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> >
> > Please keep messages on-topic and check the VTK FAQ at: 
> http://www.vtk.org/Wiki/VTK_FAQ
> >
> > Follow this link to subscribe/unsubscribe:
> > http://www.vtk.org/mailman/listinfo/vtkusers
> >  
>
>
>
>
>
> ----------------------------------------------------------------------
> --
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at 
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: 
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>   





More information about the vtkusers mailing list