[vtkusers] Problem with checkerWidget in VTK+QT

Jothy jothybasu at gmail.com
Tue Aug 10 10:16:20 EDT 2010


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100810/8e41afcf/attachment.htm>


More information about the vtkusers mailing list