[vtkusers] Re: Best vtk / QT package?

Steffen Oeltze Steffen.Oeltze at Student.Uni-Magdeburg.DE
Mon Sep 9 10:43:02 EDT 2002


thank you very much. I'm going to be careful.

Steffen

Jerome, Ron wrote:

> Hi Steffen,
>
>  
>
> Attached you will find the .cpp and .h files.  Please note that this 
> is very much a work in progress, so there are no guaranties as to the 
> quality, stability or robustness of this code (use at your own risk).
>
>  
>
> That being said, I hope it is of use to you.
>
>  
>
> Ron Jerome
>
> Institute for Chemical Process and
>
> Environmental Technology
>
> National Research Council Canada
>
> 613-993-5346
>
>  
>
>     -----Original Message-----
>     From: Steffen Oeltze [mailto:Steffen.Oeltze at Student.Uni-Magdeburg.DE]
>     Sent: Monday, September 09, 2002 2:55 AM
>     To: Jerome, Ron
>     Subject: Re: [vtkusers] Re: Best vtk / QT package?
>
>     Hi Ron,
>
>     I'm very interested in your vtkRenderWidget-class. Could you
>     please send me
>     the *.cpp and *.h files.
>
>     Thank's a lot,
>     Steffen Oeltze
>
>     Jerome, Ron wrote:
>
>>     Be aware that some of these solutions (including VTK_QT solution
>>     by Carsten Kübler <http://wwwipr.ira.uka.de/%7Ekuebler> ) have
>>     issues with  (will not display) 2D actors such as scalar bars and
>>     2D text.
>>
>>      
>>
>>     I created a render widget by subclassing QWidget, then in the
>>     constructor doing something like what is shown below.  This has
>>     no problem with 2D stuff. 
>>
>>      
>>
>>     vtkRenderWidget::vtkRenderWidget( QWidget * parent, const char *
>>     name,WFlags f  )
>>     : QWidget(parent, name,f) {
>>      this->setFocusPolicy(QWidget::StrongFocus);
>>      this->setMouseTracking(TRUE);
>>      this->setUpdatesEnabled( FALSE );
>>      this->setMinimumSize(QSize(300,300));
>>      this->InitRenderWindow();
>>     }
>>
>>      
>>
>>     void vtkRenderWidget::InitRenderWindow() {
>>
>>      this->renderWindow = vtkRenderWindow::New();
>>
>>      this->interactor = vtkRenderWindowInteractor::New();
>>      this->interactor->SetRenderWindow(this->renderWindow);
>>
>>     }
>>
>>      
>>
>>     void vtkRenderWidget::resizeEvent(QResizeEvent *event) {
>>      
>>      if (!this->initNeeded)
>>       this->renderWindow->Render();
>>      
>>     }
>>
>>      
>>
>>     void vtkRenderWidget::paintEvent(QPaintEvent *event )
>>     {
>>      // Get the native window ID and pass it
>>      // to the VTK render window
>>      // before we render for the first time...
>>      if (this->initNeeded) {
>>       WId nId = winId();
>>       this->renderWindow->SetWindowId( (void*) nId );
>>       this->interactor->Initialize();
>>       this->initNeeded = false;
>>       this->renderWindow->Render();
>>       
>>      }
>>      else {
>>       this->renderWindow->Render();
>>      }
>>     }
>>     void vtkRenderWidget::TimerFunc() {
>>      if( ! this->interactor->GetEnabled() ) {
>>       return ;
>>      }
>>      
>>      if (this->vtkVersionNumber->GetVTKMajorVersion() >= 4 &&
>>       this->vtkVersionNumber->GetVTKMinorVersion() >= 1)
>>      {
>>       this->interactor->InvokeEvent(vtkCommand::TimerEvent,NULL);
>>      }
>>      else
>>      {
>>       this->interactor->GetInteractorStyle()->OnTimer() ;
>>      }
>>      
>>      
>>     }
>>
>>      
>>
>>      
>>
>>      
>>
>>     void vtkRenderWidget::mouseMoveEvent( QMouseEvent *event ) {
>>      
>>      // mTimer->start(10, TRUE) ;
>>      mX = event->x() ;
>>      mY = event->y() ;
>>      if (this->vtkVersionNumber->GetVTKMajorVersion() >= 4 &&
>>       this->vtkVersionNumber->GetVTKMinorVersion() >= 1)
>>      {
>>     #if VTK_MAJOR_VERSION >= 4
>>     #if VTK_MINOR_VERSION >= 1
>>       this->interactor->SetEventInformationFlipY(
>>        event->x(),
>>        event->y(),
>>        (event->state() & ControlButton),
>>        (event->state() & ShiftButton));
>>     #endif
>>     #endif
>>       if (!this->mouseInWindow &&
>>        (event->x() >= 0 && event->x() < this->geometry().width() &&
>>        event->y() >= 0 && event->y() < this->geometry().height()))
>>       {
>>        this->interactor->InvokeEvent(vtkCommand::EnterEvent, NULL);
>>        this->mouseInWindow = 1;
>>       }
>>       
>>       if (this->mouseInWindow &&
>>        (event->x() < 0 || event->x() >= this->geometry().width() ||
>>        event->y() < 0 || event->y() >= this->geometry().height()))
>>       {
>>        this->interactor->InvokeEvent(vtkCommand::LeaveEvent, NULL);
>>        this->mouseInWindow = 0;
>>       }
>>       
>>       this->interactor->InvokeEvent(vtkCommand::MouseMoveEvent, NULL);
>>       
>>      }
>>      else
>>      {
>>       if (!this->mouseInWindow &&
>>        (mX >= 0 && mX < this->geometry().width() &&
>>        mY >= 0 && mY < this->geometry().height()))
>>       {
>>        this->interactor->GetInteractorStyle()->OnEnter(0, 0,
>>         mX, this->geometry().height() - mY - 1);
>>        
>>        this->mouseInWindow = 1;
>>       }
>>       
>>       if (this->mouseInWindow &&
>>        (mX < 0 || mX >= this->geometry().width() ||
>>        mY < 0 || mY >= this->geometry().height()))
>>       {
>>        this->interactor->GetInteractorStyle()->OnLeave(0, 0,
>>         mX, this->geometry().height() - mY - 1);
>>        
>>        this->mouseInWindow = 0;
>>       }
>>       this->interactor->GetInteractorStyle()->OnMouseMove(0, 0,
>>        mX, this->geometry().height() - mY - 1) ;
>>       
>>      }
>>      
>>      
>>     }
>>
>>      
>>
>>
>>     void vtkRenderWidget::mousePressEvent( QMouseEvent *event ) {
>>      
>>      //   mTimer->start(10, TRUE) ;
>>      mX = event->x() ;
>>      mY = event->y() ;
>>      
>>     #if VTK_MAJOR_VERSION >= 4
>>     #if VTK_MINOR_VERSION >= 1
>>      if (this->vtkVersionNumber->GetVTKMajorVersion() >= 4 &&
>>       this->vtkVersionNumber->GetVTKMinorVersion() >= 1)
>>      {
>>       this->interactor->SetEventInformationFlipY(event->x(),
>>        event->y(),
>>        (event->state() & ControlButton),
>>        (event->state() & ShiftButton));
>>      }
>>     #endif
>>     #endif  
>>      switch(event->button()) {
>>      case LeftButton:
>>       if (this->vtkVersionNumber->GetVTKMajorVersion() >= 4 &&
>>        this->vtkVersionNumber->GetVTKMinorVersion() >= 1)
>>       {
>>        this->interactor->InvokeEvent(vtkCommand::LeftButtonPressEvent,NULL);
>>       }
>>       else
>>       {
>>        this->interactor->GetInteractorStyle()->OnLeftButtonDown(
>>     (event->state() & ControlButton),
>>         (event->state() & ShiftButton),
>>         mX, this->geometry().height() - mY - 1 ) ;
>>       }
>>       break ;
>>      case MidButton:
>>       if (this->vtkVersionNumber->GetVTKMajorVersion() >= 4 &&
>>        this->vtkVersionNumber->GetVTKMinorVersion() >= 1)
>>       {
>>        this->interactor->InvokeEvent(vtkCommand::MiddleButtonPressEvent,NULL);
>>       }
>>       else
>>       {
>>        this->interactor->GetInteractorStyle()->OnMiddleButtonDown(
>>     (event->state() & ControlButton),
>>         (event->state() & ShiftButton),
>>         mX,   this->geometry().height() - mY - 1 ) ;
>>       }
>>       break ;
>>      case RightButton:
>>       if (this->vtkVersionNumber->GetVTKMajorVersion() >= 4 &&
>>        this->vtkVersionNumber->GetVTKMinorVersion() >= 1)
>>       {
>>        this->interactor->InvokeEvent(vtkCommand::RightButtonPressEvent,NULL);
>>       }
>>       else
>>       {
>>        this->interactor->GetInteractorStyle()->OnRightButtonDown(
>>     (event->state() & ControlButton),
>>         (event->state() & ShiftButton),
>>         mX, this->geometry().height() - mY - 1 ) ;
>>       }
>>       break;
>>      default:
>>       break ;
>>      }
>>      return ;
>>     }
>>
>>      
>>
>>
>>     void vtkRenderWidget::mouseReleaseEvent( QMouseEvent *event ) {
>>      // mTimer->stop() ; 
>>      
>>     #if VTK_MAJOR_VERSION >= 4
>>     #if VTK_MINOR_VERSION >= 1
>>      if (this->vtkVersionNumber->GetVTKMajorVersion() >= 4 &&
>>       this->vtkVersionNumber->GetVTKMinorVersion() >= 1)
>>      {
>>       this->interactor->SetEventInformationFlipY(event->x(),
>>        event->y(),
>>        (event->state() & ControlButton),
>>        (event->state() & ShiftButton));
>>      }
>>     #endif
>>     #endif  
>>      switch(event->button())
>>      {
>>       
>>      case LeftButton:
>>       if (this->vtkVersionNumber->GetVTKMajorVersion() >= 4 &&
>>        this->vtkVersionNumber->GetVTKMinorVersion() >= 1)
>>       {
>>        this->interactor->InvokeEvent(vtkCommand::LeftButtonReleaseEvent,NULL); 
>>       }
>>       else
>>       {
>>        this->interactor->GetInteractorStyle()->OnLeftButtonUp(
>>     (event->state() & ControlButton),
>>         (event->state() & ShiftButton),
>>         mX,   this->geometry().height() - mY - 1 ) ;
>>       }
>>       break ;
>>      case MidButton:
>>       if (this->vtkVersionNumber->GetVTKMajorVersion() >= 4 &&
>>        this->vtkVersionNumber->GetVTKMinorVersion() >= 1)
>>       {
>>        this->interactor->InvokeEvent(vtkCommand::MiddleButtonReleaseEvent,NULL); 
>>       }
>>       else
>>       {
>>        this->interactor->GetInteractorStyle()->OnMiddleButtonUp(
>>     (event->state() & ControlButton),
>>         (event->state() & ShiftButton),
>>         mX,  this->geometry().height() - mY - 1 ) ;
>>       }
>>       
>>       break ;
>>      case RightButton:
>>       if (this->vtkVersionNumber->GetVTKMajorVersion() >= 4 &&
>>        this->vtkVersionNumber->GetVTKMinorVersion() >= 1)
>>       {
>>        this->interactor->InvokeEvent(vtkCommand::RightButtonReleaseEvent,NULL); 
>>       }
>>       else
>>       {
>>        this->interactor->GetInteractorStyle()->OnRightButtonUp(
>>     (event->state() & ControlButton),
>>         (event->state() & ShiftButton),
>>         mX,   this->geometry().height() - mY - 1 ) ;
>>       }
>>       
>>       break;
>>      default:
>>       break ;
>>      }
>>      return ;
>>     }
>>
>>      
>>
>>
>>     void vtkRenderWidget::keyPressEvent (QKeyEvent * event) {
>>      if (this->vtkVersionNumber->GetVTKMajorVersion() >= 4 &&
>>       this->vtkVersionNumber->GetVTKMinorVersion() >= 1)
>>      {
>>     #if VTK_MAJOR_VERSION >= 4
>>     #if VTK_MINOR_VERSION >= 1
>>       this->interactor->SetKeyEventInformation(event->state() &
>>     ControlButton,
>>        event->state() & ShiftButton,
>>        *key,
>>        event->count(),
>>        "None");
>>       this->interactor->InvokeEvent(vtkCommand::KeyPressEvent, NULL);
>>     #endif
>>     #endif
>>      }
>>      else
>>      {  
>>       this->interactor->GetInteractorStyle()->OnChar( event->state()
>>     & ControlButton,
>>        event->state() & ShiftButton,
>>        event->key(),
>>        1 ) ;
>>      }
>>      
>>     }
>>
>>      
>>
>>
>>     void vtkRenderWidget::keyReleaseEvent (QKeyEvent * event) {
>>      
>>      if (this->vtkVersionNumber->GetVTKMajorVersion() >= 4 &&
>>       this->vtkVersionNumber->GetVTKMinorVersion() >= 1)
>>      {
>>     #if VTK_MAJOR_VERSION >= 4
>>     #if VTK_MINOR_VERSION >= 1
>>       this->interactor->SetKeyEventInformation(event->state() &
>>     ControlButton,
>>        event->state() & ShiftButton,
>>        event->ascii(),
>>        event->count(),
>>        "None");
>>       this->interactor->InvokeEvent(vtkCommand::KeyReleaseEvent, NULL);
>>     #endif
>>     #endif
>>      }
>>      else
>>      {
>>       this->interactor->GetInteractorStyle()->OnKeyUp( event->state()
>>     & ControlButton,
>>        event->state() & ShiftButton,
>>        event->key(), 1 ) ;
>>      }
>>     }
>>
>>     Ron Jerome
>>
>>     Institute for Chemical Process and
>>
>>     Environmental Technology
>>
>>     National Research Council Canada
>>
>>     613-993-5346
>>
>>      
>>
>>         -----Original Message-----
>>         From: Stefan Bruckner [ mailto:stefan.bruckner at chello.at ]
>>         Sent: Friday, September 06, 2002 10:48 AM
>>         To: vtkusers at public.kitware.com
>>         <mailto:vtkusers at public.kitware.com>
>>         Subject: Re: [vtkusers] Re: Best vtk / QT package?
>>
>>         That should work. I actually just saw the GetDataPointer()
>>         Method after I sent the last message.
>>
>>          
>>
>>         I have not tried stereo rendering yet ... you're having
>>         troubles with it, ríght?
>>
>>          
>>
>>         --
>>
>>         Stefan Bruckner
>>
>>          
>>
>>             -----Ursprüngliche Nachricht-----
>>             Von: Steffen Oeltze [
>>             mailto:Steffen.Oeltze at Student.Uni-Magdeburg.DE ]
>>             Gesendet: Freitag, 06. September 2002 16:20
>>             An: Stefan Bruckner
>>             Cc: vtkusers at public.kitware.com
>>             <mailto:vtkusers at public.kitware.com>
>>             Betreff: Re: [vtkusers] Re: Best vtk / QT package?
>>
>>             I have found a convenient way in the meanwhile. When the
>>             user changes the rgb-values (the scalar value keeps the
>>             same) of a point I simply use the function
>>             addRGBValue(...). VTK internally replaces the old point
>>             by the new one. When the user changes the scalar value I
>>             use the getDataPointer()-function which returns a pointer
>>             to the transfer function and then, I manipulate the
>>             function directly by replacing the scalar value each time
>>             the user moves a slider. This is actually what I'm
>>             planing to do. I haven't implemented it yet.
>>             I expect to be at most 10 points in my functions.
>>
>>             Have you tried to enable a vtkQtRenderWindow for stereo
>>             rendering yet ?
>>
>>             Steffen
>>
>>
>>
>>
>>             Stefan Bruckner wrote:
>>
>>>             What I did in the Java-Program is to simple store the
>>>             function currently displayed in the edior in an array.
>>>             When the vtk window has to be redrawn and the transfer
>>>             function has been modified, I just create a new
>>>             vtkColorTransferFunction from the array. Although this
>>>             is of course not optimal, the overhead introduced is
>>>             negligible, if node counts don't get to high. How many
>>>             nodes do you expect to be in your functions?
>>>
>>>              
>>>
>>>              
>>>
>>>              -----Ursprüngliche Nachricht-----
>>>             Von: Steffen Oeltze [
>>>             mailto:Steffen.Oeltze at Student.Uni-Magdeburg.DE ]
>>>             Gesendet: Freitag, 06. September 2002 09:45
>>>             An: Stefan Bruckner; VTK users
>>>             Betreff: Re: [vtkusers] Re: Best vtk / QT package?
>>>
>>>                 I have got a question concerning the package you
>>>                 have mentioned. I'm using vtkqt by Matthias Koenig
>>>                 which works fine except for the fact that I'm not
>>>                 able to render stereo in his vtkQtRenderWindow.
>>>                 Calling the method "StereoCapableOn()" results in an
>>>                 error. Could you please test for me if this method
>>>                 works with the package you are using ?
>>>
>>>                 A week ago I downloaded your java-program to
>>>                 graphically edit a transfer function. I'm trying to
>>>                 implement something similar using Qt. Unfortunately,
>>>                 I encountered a problem concerning the
>>>                 editing of a vtkColorTransferFunction. You  can add
>>>                 a point to this function and you can remove
>>>                 one but I couldn't find a method to modify an
>>>                 already existing point. However, this is necessary
>>>                 for my application because I want to enable the user
>>>                 to change the transfer function interactively.
>>>                 The problem is that I don't want a new point to be
>>>                 added each time the user changes the color
>>>                 but I want to modify the recently added point. How
>>>                 did you manage this ?
>>>
>>>                 Regards,
>>>                 Steffen
>>>
>>>                 Stefan Bruckner wrote:
>>>
>>>>I've examined nearly all of the packages out there, most of them are
>>>>pretty outdated. The best and probably most current (VTK 4, QT 3) is
>>>>VTK_QT by Carsten Kuebler. 
>>>>
>>>>Source is provided in an MS Visual Studio project, but I've managed to
>>>>compile it under Linux within minutes without problems.
>>>>
>>>>Download: http://wwwipr.ira.uka.de/~kuebler/vtkqt/index.html <http://wwwipr.ira.uka.de/%7Ekuebler/vtkqt/index.html>
>>>>
>>>>--
>>>>Stefan Bruckner
>>>>
>>>>
>>>>>I am trying to get vtk and qt working properly.
>>>>>
>>>>>Which is the best vtk/qt package available?
>>>>>Which has the best chance of being supported in the future?
>>>>>Which should I avoid altogether? (maybe too old to work with newer
>>>>>versions?)
>>>>>
>>>>>I appreciate all help and opinions!
>>>>>
>>>>>Thanks,
>>>>>Alex Lear
>>>>>
>>>>>_______________________________________________
>>>>>This is the private VTK discussion list. 
>>>>>Please keep messages on-topic. Check the FAQ at:
>>>>>
>>>><http://public.kitware.com/cgi-bin/vtkfaq>
>>>>
>>>>>Follow this link to subscribe/unsubscribe:
>>>>>http://public.kitware.com/mailman/listinfo/vtkusers
>>>>>
>>>>
>>>>
>>>>
>>>>
>>>>_______________________________________________
>>>>This is the private VTK discussion list. 
>>>>Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
>>>>Follow this link to subscribe/unsubscribe:
>>>>http://public.kitware.com/mailman/listinfo/vtkusers
>>>>
>>>
>>
>
> vtkrenderwidget.cpp
>
> Content-Type:
>
> application/octet-stream
> Content-Encoding:
>
> quoted-printable
>
>
> ------------------------------------------------------------------------
> vtkrenderwidget.h
>
> Content-Type:
>
> application/octet-stream
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20020909/2e012d74/attachment.htm>


More information about the vtkusers mailing list