[vtkusers] Problem with checkerWidget in VTK+QT
Eric E. Monson
emonson at cs.duke.edu
Tue Aug 10 10:56:48 EDT 2010
Hey Jothy,
I think you just don't need the last call to Interactor->Start(). Try it without and see if the interactor still behaves properly. I don't understand it completely, but the QVTKWidget seem to want to control the initial render window rendering and interactor start without you calling them explicitly.
Talk to you later,
-Eric
------------------------------------------------------
Eric E Monson
Duke Visualization Technology Group
On Aug 10, 2010, at 10:16 AM, Jothy wrote:
> Hi all,
>
> I am getting "ERROR: In C:\vtk-5.6.0\GUISupport\Qt\QVTKWidget.cxx, line 968
> QVTKInteractor (0x3626430): QVTKInteractor cannot control the event loop." error when I try to render the images with a checkerwidget.
>
> Here is the code, I use QtCreator for this
>
>
>
> vtkSmartPointer<vtkJPEGReader> jPEGReader1 =
> vtkSmartPointer<vtkJPEGReader>::New();
> vtkStdString fname1="C:\\BlueHills.jpg";
> jPEGReader1->SetFileName(fname1);
> vtkSmartPointer<vtkJPEGReader> jPEGReader2 =
> vtkSmartPointer<vtkJPEGReader>::New();
> vtkStdString fname2="C:\\Sunset.jpg" ;
> jPEGReader2->SetFileName (fname2);
> vtkSmartPointer<vtkImageCheckerboard> checkerboardFilter =
> vtkSmartPointer<vtkImageCheckerboard>::New();
> checkerboardFilter->SetInput(0, jPEGReader1->GetOutput());
> checkerboardFilter->SetInput(1, jPEGReader2->GetOutput());
> checkerboardFilter->SetNumberOfDivisions(3,3,1);
>
>
> // Create the RenderWindow, Renderer and both Actors
> //
> vtkSmartPointer<vtkRenderer> ren1 =
> vtkSmartPointer<vtkRenderer>::New();
> vtkSmartPointer<vtkRenderWindow> renWin =
> ui->qvtkWidget->GetRenderWindow();
> renWin->AddRenderer(ren1);
> vtkSmartPointer<vtkImageActor> checkerActor =
> vtkSmartPointer<vtkImageActor>::New();
> checkerActor->SetInput(checkerboardFilter->GetOutput());
>
>
> // VTK widgets consist of two parts: the widget part that handles
> // event processing; and the widget representation that defines how
> // the widget appears in the scene
> // (i.e., matters pertaining to geometry).
> vtkSmartPointer<vtkCheckerboardWidget> checkerWidget =
> vtkSmartPointer<vtkCheckerboardWidget>::New();
> checkerWidget->SetInteractor(ui->qvtkWidget->GetInteractor());
> vtkCheckerboardRepresentation *checkerWidgetRep=
> static_cast<vtkCheckerboardRepresentation *>
> (checkerWidget->GetRepresentation());
> checkerWidgetRep->SetImageActor(checkerActor);
> checkerWidgetRep->SetCheckerboard(checkerboardFilter);
>
>
> // Add the actors to the renderer, set the background and size
> //
> ren1->AddActor(checkerActor);
> ren1->SetBackground(0.1, 0.2, 0.4);
> renWin->SetSize(300, 300);
> renWin->SetInteractor(ui->qvtkWidget->GetInteractor());
>
>
> // render the image
> //
> ui->qvtkWidget->GetInteractor()->Initialize();
> ui->qvtkWidget->show();//or Render();
> checkerWidget->On();
> ui->qvtkWidget->GetInteractor()->Start();
>
>
>
> Thank you,
>
> Jothy
>
> _______________________________________________
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100810/fe88385d/attachment.htm>
More information about the vtkusers
mailing list