[vtkusers] Problem QVTKWidget using vtkCarbonRenderWindow instead of vtkCocoaRenderWindow

clinton at elemtech.com clinton at elemtech.com
Fri Sep 26 11:42:51 EDT 2008


Run patch in the GUISupport/Qt directory, because that's where I made the 
patch this time.

cd VTK/GUISupport/Qt
patch < /path/to/QVTKWidget.diff

Clint

On Friday 26 September 2008 9:32:26 am Elvis Dowson wrote:
> Hi,
>           Could you tell me how I should apply the patch? I've saved
> the contents to QVTKWidget.diff
>
> Should I use the command
>
> patch -p0 <QVTKWidget.diff
>
> from my top level source directory? My sources are located in /Users/
> elvis/Tool/vtk-5.x/src
>
> Inside that you have the VTK directory.
>
> Where should I put the patch and execute the patch command?
>
> Best regards,
>
> Elvis Dowson
>
> On Sep 26, 2008, at 5:37 PM, Clinton Stimpson wrote:
> > That's the right flag, QT_MAC_USE_COCOA.  It is initially set in
> > qconfig.h, which is generated by the configure script, and only
> > forced on in qglobal.h if building 64 bit.
> > I've attached a patch for you.  How far does that get you?
> >
> > Clint
> >
> > Elvis Dowson wrote:
> >> Hi,
> >>        In the file qglobal.h, I found a definition called
> >> QT_MAC_USE_COCOA that could be used  to switch to a vtkCocoa
> >> implementation for QVTKWidget.
> >>
> >> However, upon closer investigation, I find that it is only enable
> >> in Qt-4.5.x if 64-bit support is turned on.
> >>
> >> #ifdef AUTODETECT_COCOA
> >> #  ifdef Q_OS_MAC64
> >> #    define QT_MAC_USE_COCOA 1
> >> #  endif
> >> #endif
> >>
> >> I couldn't find any explicit definitions for Carbon, see code
> >> snippet from qglobal.h below
> >>
> >> #elif defined(Q_OS_UNIX)
> >> #  if defined(Q_OS_MAC) && !defined(__USE_WS_X11__) && !
> >> defined(Q_WS_QWS)
> >> #    define Q_WS_MAC
> >> #    define Q_WS_MACX
> >> #    if defined(Q_OS_MAC64)
> >> #      define Q_WS_MAC64
> >> #    elif defined(Q_OS_MAC32)
> >> #      define Q_WS_MAC32
> >> #    endif
> >> #  elif !defined(Q_WS_QWS)
> >> #    define Q_WS_X11
> >> #  endif
> >> #endif
> >>
> >> So, I guess this implies that the quickest way to try to fix this
> >> issue is to add support for Cocoa bindings for QVTKWidget for 64-
> >> bits.
> >>
> >> Best regards,
> >>
> >> Elvis
> >>
> >> On Sep 26, 2008, at 11:41 AM, Elvis Dowson wrote:
> >>> Any ideas on which pre-processor symbol I can use to help switch
> >>> between Carbon and Cocoa. At the moment, there is only one symbol
> >>> Q_WS_MAC.
> >
> > Index: QVTKWidget.cxx
> > ===================================================================
> > RCS file: /cvsroot/VTK/VTK/GUISupport/Qt/QVTKWidget.cxx,v
> > retrieving revision 1.36
> > diff -u -r1.36 QVTKWidget.cxx
> > --- QVTKWidget.cxx	19 Jun 2007 15:09:05 -0000	1.36
> > +++ QVTKWidget.cxx	26 Sep 2008 13:28:19 -0000
> > @@ -42,9 +42,12 @@
> > #include "vtkstd/map"
> > #include "vtkInteractorStyleTrackballCamera.h"
> > #include "vtkRenderWindow.h"
> > -#if defined(Q_WS_MAC)
> > +#if defined(QVTK_USE_CARBON)
> > #  include "vtkCarbonRenderWindow.h"
> > #endif
> > +#if defined(QVTK_USE_COCOA)
> > +#  include "vtkCocoaRenderWindow.h"
> > +#endif
> > #include "vtkCommand.h"
> > #include "vtkOStrStreamWrapper.h"
> > #include "vtkObjectFactory.h"
> > @@ -131,7 +134,7 @@
> >   this->mCachedImage->SetOrigin(0,0,0);
> >   this->mCachedImage->SetSpacing(1,1,1);
> >
> > -#if defined(Q_WS_MAC)
> > +#if defined(QVTK_USE_CARBON)
> >   this->DirtyRegionHandler = 0;
> >   this->DirtyRegionHandlerUPP = 0;
> > #endif
> > @@ -223,7 +226,7 @@
> >     this->mRenWin->SetWindowId( reinterpret_cast<void*>(this-
> >
> > >winId()));
> >
> >     // mac compatibility issues
> > -#if defined(Q_WS_MAC) && (QT_VERSION < 0x040000)
> > +#if defined(QVTK_USE_CARBON) && (QT_VERSION < 0x040000)
> >     this->mRenWin->SetWindowId( NULL );
> >     static_cast<vtkCarbonRenderWindow*>(this->mRenWin)->SetRootWindow(
> >       reinterpret_cast<WindowPtr>(this->handle()));
> > @@ -238,7 +241,7 @@
> >     if(isVisible())
> >       {
> >       this->mRenWin->Start();
> > -#if defined (Q_WS_MAC) && (QT_VERSION < 0x040000)
> > +#if defined (QVTK_USE_CARBON) && (QT_VERSION < 0x040000)
> >       macFixRect();
> > #endif
> >       }
> > @@ -272,7 +275,7 @@
> >     cbc->Delete();
> >     }
> >
> > -#if defined(Q_WS_MAC) && QT_VERSION >= 0x040000
> > +#if defined(QVTK_USE_CARBON) && QT_VERSION >= 0x040000
> >   if(mRenWin && !this->DirtyRegionHandlerUPP)
> >     {
> >     this->DirtyRegionHandlerUPP =
> > NewEventHandlerUPP(QVTKWidget::DirtyRegionProcessor);
> > @@ -439,7 +442,7 @@
> >     }
> >   this->markCachedImageAsDirty();
> >
> > -#if defined (Q_WS_MAC) && (QT_VERSION < 0x040000)
> > +#if defined (QVTK_USE_CARBON) && (QT_VERSION < 0x040000)
> >   macFixRect();
> > #endif
> > }
> > @@ -456,7 +459,7 @@
> >   // give the size to the interactor and vtk window
> >   this->mRenWin->vtkRenderWindow::SetPosition(this->x(), this->y());
> >
> > -#if defined (Q_WS_MAC) && (QT_VERSION < 0x040000)
> > +#if defined (QVTK_USE_CARBON) && (QT_VERSION < 0x040000)
> >   macFixRect();
> > #endif
> > }
> > @@ -973,7 +976,7 @@
> >     x11_setup_window();
> >
> >     // connect to new window
> > -#if defined(Q_WS_MAC)
> > +#if defined(QVTK_USE_CARBON)
> >     static_cast<vtkCarbonRenderWindow*>(this->mRenWin)->SetRootWindow(
> >       reinterpret_cast<WindowPtr>(this->handle()));
> >
> > @@ -1415,7 +1418,7 @@
> > #endif
> > }
> >
> > -#if defined (Q_WS_MAC) && QT_VERSION >= 0x040000
> > +#if defined (QVTK_USE_CARBON) && QT_VERSION >= 0x040000
> > OSStatus QVTKWidget::DirtyRegionProcessor(EventHandlerCallRef,
> > EventRef event, void* wid)
> > {
> >   QVTKWidget* widget = reinterpret_cast<QVTKWidget*>(wid);
> > @@ -1430,7 +1433,7 @@
> >
> > #endif
> >
> > -#if defined (Q_WS_MAC) && QT_VERSION < 0x040000
> > +#if defined (QVTK_USE_CARBON) && QT_VERSION < 0x040000
> >
> > // gotta do some special stuff on the MAC to make it work right
> > // this stuff will need changing when using Qt4 with HIViews
> > @@ -1510,7 +1513,7 @@
> > // slot to update the draw region and draw the scene
> > void QVTKWidget::internalMacFixRect()
> > {
> > -#if defined(Q_WS_MAC) && QT_VERSION < 0x040000
> > +#if defined(QVTK_USE_CARBON) && QT_VERSION < 0x040000
> >   this->macFixRect();
> >   this->update();
> > #endif
> > Index: QVTKWidget.h.in
> > ===================================================================
> > RCS file: /cvsroot/VTK/VTK/GUISupport/Qt/QVTKWidget.h.in,v
> > retrieving revision 1.1
> > diff -u -r1.1 QVTKWidget.h.in
> > --- QVTKWidget.h.in	1 Apr 2008 16:43:24 -0000	1.1
> > +++ QVTKWidget.h.in	26 Sep 2008 13:28:19 -0000
> > @@ -41,7 +41,14 @@
> > #include <vtkConfigure.h>
> > class vtkImageData;
> >
> > -#if defined(Q_WS_MAC) && QT_VERSION >= 0x040000
> > +#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
> > +# define QVTK_USE_COCOA
> > +#elif defined(Q_WS_MAC)
> > +# define QVTK_USE_CARBON
> > +#endif
> > +
> > +
> > +#if defined(QVTK_USE_CARBON) && QT_VERSION >= 0x040000
> > #include <Carbon/Carbon.h>    // Event handling for dirty region
> > #endif
> >
> > @@ -209,13 +216,13 @@
> >   // that VTK chooses
> >   void x11_setup_window();
> >
> > -#if defined(Q_WS_MAC) && QT_VERSION < 0x040000
> > +#if defined(QVTK_USE_CARBON) && QT_VERSION < 0x040000
> >   void macFixRect();
> >   virtual void setRegionDirty(bool);
> >   virtual void macWidgetChangedWindow();
> > #endif
> >
> > -#if defined(Q_WS_MAC) && QT_VERSION >= 0x040000
> > +#if defined(QVTK_USE_CARBON) && QT_VERSION >= 0x040000
> >   EventHandlerUPP DirtyRegionHandlerUPP;
> >   EventHandlerRef DirtyRegionHandler;
> >   static OSStatus DirtyRegionProcessor(EventHandlerCallRef er,
> > EventRef event, void*);





More information about the vtkusers mailing list