[vtkusers] [vtk-developers] Instructions to implement 3D Space Navigator support with VTK
Goodwin Lawlor
goodwin.lawlor at ucd.ie
Fri Mar 28 19:28:52 EDT 2008
Hi Wagner,
Try putting your code into the vtkXRenderWindowInteractorCallback method
in the vtkXRenderWindowInteractor class. There's a ClientMessage case at
the bottom of the switch.
hth
Goodwin
Wagner Sales wrote:
> Hi all,
>
> I need to implement 3DConnexion Space Navigator support in my VTK
> application. To know a little bit more, this device are used to
> control 3D navigation in a scheme, like rotation, zooming, move and
> others.
> I read an old post in the list, but no answers are returned. I was
> read the VTK interactor and relative classes (interactorStyle,
> vtkXRenderWindowInteractor ) to try to understand how to implement
> this, but without success.
> Since I'm using X11, this device will send to me a ClientMessage
> XEvent type, with the data about move position or button click. I'm
> current handling this in Qt, without problems ( the code are at the
> end to illustrate better what's I need to do). Now, I need to do in
> VTK, but I'm a little bit confused about wich class(es) I need to re
> implement or inherits to give this support. vtkRenderWindowInteractor?
> vtkInteractorStyle? Or something completely new?
> I know this classes are changing from VTK 5.0 to 5.2, and I'm using
> VTK 5.0.4.
>
> Can someone helps and put me in the correct way?
>
> Thks in advance!
>
>
> Wagner Sales
>
>
> The Qt code to handle the event:
> bool QtSpaceNavigatorWidget:
> :x11Event(XEvent *event)
> {
> MagellanFloatEvent MagellanEvent;
> double MagellanSensitivity = 1.0;
> Display *display = QX11Info::display();
> {
> if(!display)
> {
> qDebug() << "Cannot open display!" << endl;
> }
> }
> if ( !MagellanInit( display, winId() ) )
> {
> qDebug() << "No Space Navigator driver exists";
> return false;
> };
>
> switch (event->type)
> {
> case ClientMessage:
> switch( MagellanTranslateEvent( display, event,
> &MagellanEvent, 1.0, 1.0 ) )
> {
> case MagellanInputMotionEvent :
> MagellanRemoveMotionEvents( display );
> // now we will be set the values from Space Navigator on
> the text labels
>
> xvalue->setText(QString::number(MagellanEvent.MagellanData[ MagellanX ]));
>
> yvalue->setText(QString::number(MagellanEvent.MagellanData[ MagellanY ]));
>
> zvalue->setText(QString::number(MagellanEvent.MagellanData[ MagellanZ ]));
>
> avalue->setText(QString::number(MagellanEvent.MagellanData[ MagellanA ]));
>
> bvalue->setText(QString::number(MagellanEvent.MagellanData[ MagellanB ]));
>
> cvalue->setText(QString::number(MagellanEvent.MagellanData[ MagellanC ]));
> return false;
>
> break;
>
> case MagellanInputButtonPressEvent :
> qDebug() << "MagellanInputButtonPressEvent called" <<
> endl;
>
> switch ( MagellanEvent.MagellanButton )
> {
> case 5: MagellanApplicationSensitivity(
> display, MagellanSensitivity / 2.0 ); break;
> case 6: MagellanApplicationSensitivity(
> display, MagellanSensitivity * 2.0 ); break;
> case 7: MagellanApplicationSensitivity(
> display, 1.0 ); break;
> };
>
> switch( MagellanEvent.MagellanButton )
> {
> case 5: MagellanSensitivity =
> MagellanSensitivity <= 1.0/32.0 ? 1.0/32.0 : MagellanSensitivity/2.0;
> break;
> case 6: MagellanSensitivity =
> MagellanSensitivity >= 32.0 ? 32.0 : MagellanSensitivity*2.0; break;
> case 7: MagellanSensitivity = 1.0; break;
> };
> switch( MagellanEvent.MagellanButton )
> {
> case 5:
> case 6:
> case 7:
> printf("Application Sensitivity = %lf \n",
> MagellanSensitivity );
> break;
> };
> return false;
> break;
>
> case MagellanInputButtonReleaseEvent :
> qDebug() << "MagellanInputButtonPressEvent called" <<
> endl;
> return false;
> break;
> }
> default:
> return false;
> break;
> }
> return false;
>
> }
> ------------------------------------------------------------------------
>
> _______________________________________________
> vtk-developers mailing list
> vtk-developers at vtk.org
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
More information about the vtkusers
mailing list