[vtkusers] problem in having two Widgets with the same interactor

satyanarayana reddy satyajanga at gmail.com
Mon Mar 8 02:14:17 EST 2010


Hi David,
          Thanks for the reply. It is working fine for me. But this time I
am facing a new problem. If I add any actor to the to the renderer then 1st
widget is moving only at the first time after that I am not able to move it.
2nd widget is moving without any problem.
Plz see the pipeline I have followed.

   // Input is a polydata file like brainImageSmooth.vtk in VTKData/Data

vtkPolyDataReader *reader = vtkPolyDataReader::New();

reader->SetFileName(argv[1]);

reader->Update();

 vtkPolyData *polyData = reader->GetOutput();

vtkPolyDataMapper* surfaceMapper = vtkPolyDataMapper::New();

surfaceMapper->SetInput(polyData);

 vtkActor* surfaceActor = vtkActor::New();

surfaceActor->SetMapper(surfaceMapper);

 // a renderer and render window

vtkRenderer *renderer =

vtkRenderer::New();

vtkRenderWindow *renderWindow =

vtkRenderWindow::New();

renderWindow->AddRenderer(renderer);

renderer->AddActor(surfaceActor);

// an interactor

vtkRenderWindowInteractor *renderWindowInteractor =

vtkRenderWindowInteractor::New();

renderWindowInteractor->SetRenderWindow(renderWindow);

 vtkSphereWidget *sphereWidget1 =

vtkSphereWidget::New();

sphereWidget1->SetInteractor(renderWindowInteractor);

sphereWidget1->SetRepresentationToSurface();

sphereWidget1->SetCenter(-10.0, 0.0, 0.0);

sphereWidget1->SetRadius(4);

sphereWidget1->On();

vtkSphereWidget *sphereWidget2 =

vtkSphereWidget::New();

sphereWidget2->SetInteractor(renderWindowInteractor);

sphereWidget2->SetRepresentationToSurface();

sphereWidget2->SetCenter(10.0, 0.0, 0.0);

sphereWidget2->SetRadius(4);

 sphereWidget2->On();

renderWindow->Render();

renderWindowInteractor->Initialize();

renderWindowInteractor->Start();


Thanks and Regards,
Satya.

> The following works fine for me - can you explain the problem in more
> detail?
>
> #include <vtkPolyDataMapper.h>
> #include <vtkActor.h>
> #include <vtkRenderWindow.h>
> #include <vtkRenderer.h>
> #include <vtkRenderWindowInteractor.h>
> #include <vtkPolyData.h>
> #include <vtkSmartPointer.h>
> #include <vtkSphereSource.h>
> #include <vtkSphereWidget.h>
> #include <vtkSphereRepresentation.h>
> #include <vtkBoxWidget2.h>
> #include <vtkCommand.h>
>
> int main(int argc, char *argv[])
> {
>   // a renderer and render window
>   vtkSmartPointer<vtkRenderer> renderer =
>       vtkSmartPointer<vtkRenderer>::New();
>   vtkSmartPointer<vtkRenderWindow> renderWindow =
>       vtkSmartPointer<vtkRenderWindow>::New();
>   renderWindow->AddRenderer(renderer);
>
>   // an interactor
>   vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
>       vtkSmartPointer<vtkRenderWindowInteractor>::New();
>   renderWindowInteractor->SetRenderWindow(renderWindow);
>
>   vtkSmartPointer<vtkSphereWidget> sphereWidget1 =
>       vtkSmartPointer<vtkSphereWidget>::New();
>   sphereWidget1->SetInteractor(renderWindowInteractor);
>   sphereWidget1->SetRepresentationToSurface();
>
>    vtkSmartPointer<vtkSphereWidget> sphereWidget2 =
>       vtkSmartPointer<vtkSphereWidget>::New();
>   sphereWidget2->SetInteractor(renderWindowInteractor);
>   sphereWidget2->SetRepresentationToSurface();
>   sphereWidget2->SetCenter(2.0, 0.0, 0.0);
>
>   sphereWidget1->On();
>   sphereWidget2->On();
>   renderWindow->Render();
>   renderWindowInteractor->Start();
>
>   return EXIT_SUCCESS;
> }
>
> Thanks,
>
> David
>
> _______________________________________________
> 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/20100308/0827c5c2/attachment.htm>


More information about the vtkusers mailing list