[vtkusers] integrate a vtkOrientationMarkerWidget into a QVtkWidget

Nicolas Sarrasin nsarrasin at phenix-systems.com
Fri Sep 17 10:14:24 EDT 2010


  hi all,

I encounter difficulties in integrating a vtkOrientationMarkerWidget 
into a QVtkWidget, when I launch Iterator->start() my app doesn't appear 
and if I uncomment it then i get an exception when I move my mouse above 
the QVtkWidget.

Here is the sample code I try to launch :

test3daxesVtkQt::test3daxesVtkQt(QWidget *parent, Qt::WFlags flags) : 
QMainWindow(parent, flags)
{
     this->ui = new Ui_test3daxesVtkQtClass;
     ui->setupUi(this);

     ui->qvtkWidgetMain = new QVTKWidget(ui->centralwidget);
     ui->qvtkWidgetMain->setObjectName(QString::fromUtf8("qvtkWidgetMain"));
     ui->qvtkWidgetMain->setGeometry(QRect(10, 20, 511, 541));

   // sphere
   vtkSmartPointer<vtkSphereSource> sphereSource =
       vtkSmartPointer<vtkSphereSource>::New();
   sphereSource->Update();
   vtkSmartPointer<vtkPolyDataMapper> sphereMapper =
       vtkSmartPointer<vtkPolyDataMapper>::New();
   sphereMapper->SetInputConnection(sphereSource->GetOutputPort());
   vtkSmartPointer<vtkActor> sphereActor =
       vtkSmartPointer<vtkActor>::New();
   sphereActor->SetMapper(sphereMapper);

   // VTK Renderer
   vtkSmartPointer<vtkRenderer> Renderer =
       vtkSmartPointer<vtkRenderer>::New();
   Renderer->AddActor(sphereActor);

   // VTK/Qt wedded
   this->ui->qvtkWidgetMain->GetRenderWindow()->AddRenderer(Renderer);

   //integration d'un 3daxis
   // An interactor
   vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
     vtkSmartPointer<vtkRenderWindowInteractor>::New();
   
renderWindowInteractor->SetRenderWindow(this->ui->qvtkWidgetMain->GetRenderWindow());

   vtkSmartPointer<vtkAxesActor> axes =
     vtkSmartPointer<vtkAxesActor>::New();

   vtkSmartPointer<vtkOrientationMarkerWidget> widget =
     vtkSmartPointer<vtkOrientationMarkerWidget>::New();
   widget->SetOutlineColor( 0.9300, 0.5700, 0.1300 );
   widget->SetOrientationMarker( axes );
   widget->SetInteractor( renderWindowInteractor );
   widget->SetViewport( 0.0, 0.0, 0.4, 0.4 );
   widget->SetEnabled( 1 );
   widget->InteractiveOn();

   Renderer->ResetCamera();
   this->ui->qvtkWidgetMain->GetRenderWindow()->Render();

   // Begin mouse interaction
   //renderWindowInteractor->Start(); => no window appears
renderWindowInteractor->Start(); //=> exception at 
vtkOrientationMarkerWidget::ProcessEvents : "if(!self->GetInteractive())...

}

Please help me to understand what is the problem here and how to solve it.
Thanks by avdance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100917/d8e7d0fc/attachment.htm>


More information about the vtkusers mailing list