[vtkusers] Basic instructions to implement a 3DConexxion support in VTK

Wagner Sales wsales at gmail.com
Thu Mar 27 10:44:15 EDT 2008


Hi all,

I need to implement 3DConexxion 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.
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). 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?

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;

}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080327/165c14d5/attachment-0002.htm>


More information about the vtkusers mailing list