From 6d95e8aac480cc46df35de17c533dbe7bdb7a3d1 Mon Sep 17 00:00:00 2001 From: vsr Date: Fri, 20 Jan 2017 15:43:08 +0300 Subject: [PATCH] Patch for MacOS (from SALOME forum) --- src/CAM/CAM_Application.cxx | 4 ++- src/GLViewer/CMakeLists.txt | 2 +- src/GLViewer/GLViewer_BaseDrawers.cxx | 3 +- src/GLViewer/GLViewer_Context.h | 4 +++ src/GLViewer/GLViewer_Drawer.cxx | 33 +++++++++++++++++++-- src/GLViewer/GLViewer_Drawer.h | 8 +++-- src/GLViewer/GLViewer_Grid.h | 5 ++++ src/GLViewer/GLViewer_Object.h | 4 +++ src/GLViewer/GLViewer_Text.h | 4 +++ src/GLViewer/GLViewer_Tools.cxx | 4 +++ src/GLViewer/GLViewer_ViewPort.cxx | 4 +-- src/GLViewer/GLViewer_ViewPort2d.h | 5 ++++ src/GLViewer/GLViewer_Viewer2d.h | 4 +++ src/LightApp/LightApp_Application.cxx | 4 ++- src/OCCViewer/OCCViewer_Trihedron.cxx | 10 +++++-- src/OCCViewer/OCCViewer_VService.cxx | 10 +++++-- src/OCCViewer/OCCViewer_ViewPort.cxx | 4 +-- src/OCCViewer/OCCViewer_ViewWindow.cxx | 4 +++ src/OpenGLUtils/OpenGLUtils_FrameBuffer.cxx | 20 +++++++++++++ src/OpenGLUtils/OpenGLUtils_FrameBuffer.h | 4 +++ src/Qtx/Qtx.cxx | 8 +++-- src/SALOME_PY/SalomePy.cxx | 2 +- src/SALOME_PYQT/SalomePyQt/CMakeLists.txt | 2 +- src/SUITApp/SUITApp_Application.cxx | 2 +- src/SVTK/SVTK_RenderWindowInteractor.cxx | 19 ++++++------ src/SVTK/SVTK_RenderWindowInteractor.h | 4 +-- src/SVTK/SVTK_SpaceMouse.cxx | 10 +++---- src/SVTK/SVTK_SpaceMouse.h | 10 ++++--- src/SVTK/SVTK_ViewWindow.cxx | 4 +++ src/Session/SALOME_Session_Server.cxx | 2 +- src/VTKViewer/VTKViewer_PolyDataMapper.cxx | 20 +++++++++++++ src/VTKViewer/VTKViewer_PolyDataMapper.h | 4 +++ src/VTKViewer/VTKViewer_RenderWindow.cxx | 4 +-- 33 files changed, 182 insertions(+), 49 deletions(-) diff --git a/src/CAM/CAM_Application.cxx b/src/CAM/CAM_Application.cxx index a8603ec1f..59a7f7ed8 100755 --- a/src/CAM/CAM_Application.cxx +++ b/src/CAM/CAM_Application.cxx @@ -771,8 +771,10 @@ void CAM_Application::readModuleList() if ( !modLibrary.isEmpty() ) { modLibrary = SUIT_Tools::file( modLibrary.trimmed() ); -#ifdef WIN32 +#if defined(WIN32) QString libExt = QString( "dll" ); +#elif defined(__APPLE__) + QString libExt = QString( "dylib" ); #else QString libExt = QString( "so" ); #endif diff --git a/src/GLViewer/CMakeLists.txt b/src/GLViewer/CMakeLists.txt index 2198d7eb4..9d0e36c57 100755 --- a/src/GLViewer/CMakeLists.txt +++ b/src/GLViewer/CMakeLists.txt @@ -33,7 +33,7 @@ ADD_DEFINITIONS(${CAS_DEFINITIONS} ${QT_DEFINITIONS}) # libraries to link to SET(_link_LIBRARIES ${QT_LIBRARIES} ${CAS_KERNEL} ${OPENGL_LIBRARIES} qtx suit) -IF(NOT WIN32) +IF(NOT (WIN32 OR APPLE)) LIST(APPEND _link_LIBRARIES Xmu) ENDIF() diff --git a/src/GLViewer/GLViewer_BaseDrawers.cxx b/src/GLViewer/GLViewer_BaseDrawers.cxx index cd27c7f04..f675e769e 100644 --- a/src/GLViewer/GLViewer_BaseDrawers.cxx +++ b/src/GLViewer/GLViewer_BaseDrawers.cxx @@ -34,8 +34,7 @@ // Qt includes #include - -#ifndef WIN32 +#if !defined(WIN32) && !defined(__APPLE__) #include #endif diff --git a/src/GLViewer/GLViewer_Context.h b/src/GLViewer/GLViewer_Context.h index 498ef3f22..aa31fd709 100644 --- a/src/GLViewer/GLViewer_Context.h +++ b/src/GLViewer/GLViewer_Context.h @@ -39,7 +39,11 @@ class QRect; #include #include +#ifdef __APPLE__ +#include +#else #include +#endif class GLViewer_Viewer2d; diff --git a/src/GLViewer/GLViewer_Drawer.cxx b/src/GLViewer/GLViewer_Drawer.cxx index 089d8a810..13d5e8acb 100644 --- a/src/GLViewer/GLViewer_Drawer.cxx +++ b/src/GLViewer/GLViewer_Drawer.cxx @@ -36,7 +36,9 @@ #include #include -#ifndef WIN32 +#if defined(__APPLE__) +#include +#elif !defined(WIN32) #include #endif @@ -377,7 +379,7 @@ static GLuint displayListBase( QFont* theFont ) aFindFont.myIsUndl = theFont->underline(); aFindFont.myPointSize = theFont->pointSize(); -#ifdef WIN32 +#if defined(WIN32) HGLRC ctx = ::wglGetCurrentContext(); if ( !ctx ) return aList; @@ -406,6 +408,33 @@ static GLuint displayListBase( QFont* theFont ) aList = listBase; GLViewer_TexFont::BitmapFontCache[aFindFont] = aList; } +#elif defined(__APPLE__) + CGLContextObj ctx = ::CGLGetCurrentContext(); + if ( !ctx ) + return aList; + + aFindFont.myViewPortId = (long)ctx; + + if ( GLViewer_TexFont::BitmapFontCache.contains( aFindFont ) ) + aList = GLViewer_TexFont::BitmapFontCache[aFindFont]; + else + { + GLuint listBase = 0; + QMap::iterator it = GLViewer_TexFont::BitmapFontCache.begin(); + for ( ; it != GLViewer_TexFont::BitmapFontCache.end(); ++it ) + { + if ( it.key().myViewPortId == (long)ctx && it.value() > listBase ) + listBase = it.value(); + } + listBase += 256; + + //HDC glHdc = ::wglGetCurrentDC(); + //::SelectObject( glHdc, theFont->handle() ); + //if ( !::wglUseFontBitmaps( glHdc, 0, 256, listBase ) ) + // listBase = 0; + aList = listBase; + GLViewer_TexFont::BitmapFontCache[aFindFont] = aList; + } #else //X Window Display* aDisp = glXGetCurrentDisplay(); if( !aDisp ) diff --git a/src/GLViewer/GLViewer_Drawer.h b/src/GLViewer/GLViewer_Drawer.h index e454081a5..f936da990 100644 --- a/src/GLViewer/GLViewer_Drawer.h +++ b/src/GLViewer/GLViewer_Drawer.h @@ -36,7 +36,11 @@ class QFile; +#ifdef __APPLE__ +#include +#else #include +#endif #include "GLViewer.h" #include "GLViewer_Defs.h" @@ -79,8 +83,8 @@ struct GLVIEWER_API GLViewer_TexFindId bool myIsUndl; //! Font Size int myPointSize; - //! View POrt ID - int myViewPortId; + //! View Port ID + long myViewPortId; //! Overloaded operator for using struct as MAP key bool operator < (const GLViewer_TexFindId theStruct) const { diff --git a/src/GLViewer/GLViewer_Grid.h b/src/GLViewer/GLViewer_Grid.h index 1a867b2e4..f487a0e7e 100644 --- a/src/GLViewer/GLViewer_Grid.h +++ b/src/GLViewer/GLViewer_Grid.h @@ -33,8 +33,13 @@ #include "GLViewer.h" +#ifdef __APPLE__ +#include +#include +#else #include #include +#endif #ifdef WIN32 #pragma warning( disable:4251 ) diff --git a/src/GLViewer/GLViewer_Object.h b/src/GLViewer/GLViewer_Object.h index 10b181ab1..bbf4df0e1 100644 --- a/src/GLViewer/GLViewer_Object.h +++ b/src/GLViewer/GLViewer_Object.h @@ -34,7 +34,11 @@ #include "GLViewer.h" #include "GLViewer_Geom.h" +#ifdef __APPLE__ +#include +#else #include +#endif #include diff --git a/src/GLViewer/GLViewer_Text.h b/src/GLViewer/GLViewer_Text.h index cc15d8907..01adfd250 100644 --- a/src/GLViewer/GLViewer_Text.h +++ b/src/GLViewer/GLViewer_Text.h @@ -34,7 +34,11 @@ #include "GLViewer.h" #include "GLViewer_Defs.h" +#ifdef __APPLE__ +#include +#else #include +#endif #include #include diff --git a/src/GLViewer/GLViewer_Tools.cxx b/src/GLViewer/GLViewer_Tools.cxx index 7079142f8..e1df5e0ea 100644 --- a/src/GLViewer/GLViewer_Tools.cxx +++ b/src/GLViewer/GLViewer_Tools.cxx @@ -26,7 +26,11 @@ // #include "GLViewer_Tools.h" +#ifdef __APPLE__ +#include +#else #include +#endif #include #include diff --git a/src/GLViewer/GLViewer_ViewPort.cxx b/src/GLViewer/GLViewer_ViewPort.cxx index 733b1a392..75187e971 100644 --- a/src/GLViewer/GLViewer_ViewPort.cxx +++ b/src/GLViewer/GLViewer_ViewPort.cxx @@ -42,7 +42,7 @@ #include -#if !defined WIN32 +#if !defined WIN32 && !defined __APPLE__ #include #include #include @@ -353,7 +353,7 @@ void GLViewer_ViewPort::cleanup() */ void GLViewer_ViewPort::selectVisualId( ViewType type ) { -#if !defined WIN32 +#if !defined WIN32 && !defined __APPLE__ XVisualInfo* pVisualInfo; if ( QX11Info::display() ) { diff --git a/src/GLViewer/GLViewer_ViewPort2d.h b/src/GLViewer/GLViewer_ViewPort2d.h index c673b169b..465c2f8d7 100644 --- a/src/GLViewer/GLViewer_ViewPort2d.h +++ b/src/GLViewer/GLViewer_ViewPort2d.h @@ -31,8 +31,13 @@ #include #endif +#ifdef __APPLE__ +#include +#include +#else #include #include +#endif #include "GLViewer_ViewPort.h" #include "GLViewer_Widget.h" diff --git a/src/GLViewer/GLViewer_Viewer2d.h b/src/GLViewer/GLViewer_Viewer2d.h index 875baa0b8..9cafb3bdc 100644 --- a/src/GLViewer/GLViewer_Viewer2d.h +++ b/src/GLViewer/GLViewer_Viewer2d.h @@ -38,7 +38,11 @@ class QFile; #include +#ifdef __APPLE__ +#include +#else #include +#endif class GLViewer_Object; class GLViewer_ViewFrame; diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 37ca6fd0f..4b336bd65 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -4458,8 +4458,10 @@ bool LightApp_Application::isLibExists( const QString& moduleTitle ) const bool isPythonLightModule = lib.contains("SalomePyQtGUILight"); QStringList paths; -#ifdef WIN32 +#if defined(WIN32) paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts ); +#elif defined(__APPLE__) + paths = QString(::getenv( "DYLD_LIBRARY_PATH" )).split( ":", QString::SkipEmptyParts ); #else paths = QString(::getenv( "LD_LIBRARY_PATH" )).split( ":", QString::SkipEmptyParts ); #endif diff --git a/src/OCCViewer/OCCViewer_Trihedron.cxx b/src/OCCViewer/OCCViewer_Trihedron.cxx index 4682ce950..d13af530e 100644 --- a/src/OCCViewer/OCCViewer_Trihedron.cxx +++ b/src/OCCViewer/OCCViewer_Trihedron.cxx @@ -21,7 +21,11 @@ #include #endif +#ifdef __APPLE__ +#include +#else #include +#endif #include "OCCViewer_Trihedron.h" @@ -37,7 +41,7 @@ #include -#ifndef WIN32 +#if !defined WIN32 && !defined __APPLE__ # include #endif @@ -122,7 +126,7 @@ GLuint generateTextList() bool ok = false; GLuint aList = glGenLists( 256 ); -#ifdef WIN32 +#if defined(WIN32) HGLRC hglrc = wglGetCurrentContext(); if( hglrc ) { @@ -142,7 +146,7 @@ GLuint generateTextList() SelectObject( hdc, oldFont ); DeleteObject( font ); } -#else // X Window +#elif !defined(__APPLE__) // X Window Display* dpy = glXGetCurrentDisplay(); if( dpy ) { diff --git a/src/OCCViewer/OCCViewer_VService.cxx b/src/OCCViewer/OCCViewer_VService.cxx index ec09bc0a9..e5fce614a 100644 --- a/src/OCCViewer/OCCViewer_VService.cxx +++ b/src/OCCViewer/OCCViewer_VService.cxx @@ -34,8 +34,10 @@ #endif #include -#ifdef WIN32 +#if defined(WIN32) #include +#elif defined(__APPLE__) +#include #else #include #endif @@ -47,8 +49,10 @@ Handle(Aspect_Window) OCCViewer_VService::CreateWindow( const Handle(V3d_View)& WId winId ) { Aspect_Handle aWindowHandle = (Aspect_Handle)winId; -#ifdef WIN32 +#if defined(WIN32) Handle(WNT_Window) viewWindow = new WNT_Window( aWindowHandle ); +#elif defined(__APPLE__) + Handle(Cocoa_Window) viewWindow = new Cocoa_Window( (NSView*)winId ); #else Handle(Aspect_DisplayConnection) aDispConnection = view->Viewer()->Driver()->GetDisplayConnection(); Handle(Xw_Window) viewWindow = new Xw_Window( aDispConnection, aWindowHandle ); @@ -75,7 +79,7 @@ Handle(V3d_Viewer) OCCViewer_VService::CreateViewer( const Standard_ExtString na if (aGraphicDriver.IsNull()) { Handle(Aspect_DisplayConnection) aDisplayConnection; -#ifndef WIN32 +#if !defined WIN32 && !defined __APPLE__ aDisplayConnection = new Aspect_DisplayConnection( displayName ); #else aDisplayConnection = new Aspect_DisplayConnection(); diff --git a/src/OCCViewer/OCCViewer_ViewPort.cxx b/src/OCCViewer/OCCViewer_ViewPort.cxx index d6cca3173..d0d2ce19d 100755 --- a/src/OCCViewer/OCCViewer_ViewPort.cxx +++ b/src/OCCViewer/OCCViewer_ViewPort.cxx @@ -40,7 +40,7 @@ #include -#if !defined WIN32 +#if !defined WIN32 && !defined __APPLE__ #include #include #include @@ -236,7 +236,7 @@ void OCCViewer_ViewPort::cleanup() */ void OCCViewer_ViewPort::selectVisualId() { -#if !defined WIN32 +#if !defined WIN32 && !defined __APPLE__ XVisualInfo* pVisualInfo; if ( QX11Info::display() ) { diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index 8959f5961..678a6de3c 100644 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -115,7 +115,11 @@ static QEvent* l_mbPressEvent = 0; //# include //#endif +#ifdef __APPLE__ +#include +#else #include +#endif // To avoid conflict between KeyPress from the X.h (define KeyPress 2) // and QEvent::KeyPress (qevent.h) diff --git a/src/OpenGLUtils/OpenGLUtils_FrameBuffer.cxx b/src/OpenGLUtils/OpenGLUtils_FrameBuffer.cxx index d0f822174..891ae6511 100755 --- a/src/OpenGLUtils/OpenGLUtils_FrameBuffer.cxx +++ b/src/OpenGLUtils/OpenGLUtils_FrameBuffer.cxx @@ -34,7 +34,27 @@ # ifndef GLX_GLXEXT_LEGACY # define GLX_GLXEXT_LEGACY # endif +#ifdef __APPLE__ +#import +#import +#import +void * glXGetProcAddressARB (const GLubyte *name) + +{ + NSSymbol symbol; + char *symbolName; + symbolName = (char *)malloc (strlen ((const char *)name) + 2); // 1 + strcpy(symbolName + 1, (const char *)name); // 2 + symbolName[0] = '_'; // 3 + symbol = NULL; + if (NSIsSymbolNameDefined (symbolName)) // 4 + symbol = NSLookupAndBindSymbol (symbolName); + free (symbolName); // 5 + return symbol ? NSAddressOfSymbol (symbol) : NULL; // 6 +} +#else # include +#endif # include #else # include diff --git a/src/OpenGLUtils/OpenGLUtils_FrameBuffer.h b/src/OpenGLUtils/OpenGLUtils_FrameBuffer.h index 8e7efeb57..feb10037f 100755 --- a/src/OpenGLUtils/OpenGLUtils_FrameBuffer.h +++ b/src/OpenGLUtils/OpenGLUtils_FrameBuffer.h @@ -29,7 +29,11 @@ #include #endif +#ifdef __APPLE__ +#include +#else #include +#endif class OPENGLUTILS_EXPORT OpenGLUtils_FrameBuffer { diff --git a/src/Qtx/Qtx.cxx b/src/Qtx/Qtx.cxx index 0bacef045..d596874ce 100755 --- a/src/Qtx/Qtx.cxx +++ b/src/Qtx/Qtx.cxx @@ -429,13 +429,15 @@ QString Qtx::library( const QString& str ) name = QString( "lib" ) + name; #endif -#ifdef WIN32 +#if defined(WIN32) QString libExt( "dll" ); +#elif defined(__APPLE__) + QString libExt( "dylib" ); #else QString libExt( "so" ); #endif - if ( ext.toLower() != QString( "so" ) && ext.toLower() != QString( "dll" ) ) + if ( ext.toLower() != QString( "so" ) && ext.toLower() != QString( "dll" ) && ext.toLower() != QString( "dylib" ) ) { if ( !name.isEmpty() && !ext.isEmpty() ) name += QString( "." ); @@ -2104,7 +2106,7 @@ QFont Qtx::stringToFont( const QString& fontDescription ) return font; } -#ifndef WIN32 +#if !defined WIN32 && !defined __APPLE__ #include #include diff --git a/src/SALOME_PY/SalomePy.cxx b/src/SALOME_PY/SalomePy.cxx index 65cf4ffe8..d099217b9 100755 --- a/src/SALOME_PY/SalomePy.cxx +++ b/src/SALOME_PY/SalomePy.cxx @@ -449,7 +449,7 @@ extern "C" SALOMEPY_EXPORT PyObject* libSalomePy_setView( PyObject* self, PyObje case ViewLeft: aVTKViewWindow->onLeftView(); break; default: - PyErr_Format(PyExc_ValueError,"setView%: wrong parameter value; must be between %d and %d", ViewFront, ViewLeft ); + PyErr_Format(PyExc_ValueError,"setView: wrong parameter value; must be between %d and %d", ViewFront, ViewLeft ); break; } } diff --git a/src/SALOME_PYQT/SalomePyQt/CMakeLists.txt b/src/SALOME_PYQT/SalomePyQt/CMakeLists.txt index 9760dd47a..e5c68a0f6 100755 --- a/src/SALOME_PYQT/SalomePyQt/CMakeLists.txt +++ b/src/SALOME_PYQT/SalomePyQt/CMakeLists.txt @@ -118,7 +118,7 @@ SET(SalomePyQt_SOURCES ${_other_SOURCES} ${_moc_SOURCES} ${_sip_SOURCES}) # --- rules --- -ADD_LIBRARY(SalomePyQt ${SalomePyQt_SOURCES}) +ADD_LIBRARY(SalomePyQt MODULE ${SalomePyQt_SOURCES}) TARGET_LINK_LIBRARIES(SalomePyQt ${_link_LIBRARIES}) INSTALL(TARGETS SalomePyQt DESTINATION ${SALOME_INSTALL_LIBS}) diff --git a/src/SUITApp/SUITApp_Application.cxx b/src/SUITApp/SUITApp_Application.cxx index ad1fcf01c..f15906995 100644 --- a/src/SUITApp/SUITApp_Application.cxx +++ b/src/SUITApp/SUITApp_Application.cxx @@ -41,7 +41,7 @@ */ SUITApp_Application::SUITApp_Application( int& argc, char** argv, SUIT_ExceptionHandler* hand ) // TODO (QT5 PORTING) Below is a temporary solution, to allow compiling with Qt 5 -#if !defined(WIN32) && (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) +#if !defined(WIN32) && !defined(__APPLE__) && (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) // san: Opening an X display and choosing a visual most suitable for 3D visualization // in order to make SALOME viewers work with non-native X servers : QApplication( (Display*)Qtx::getDisplay(), argc, argv, Qtx::getVisual() ), diff --git a/src/SVTK/SVTK_RenderWindowInteractor.cxx b/src/SVTK/SVTK_RenderWindowInteractor.cxx index c82c25156..c6278f7c2 100644 --- a/src/SVTK/SVTK_RenderWindowInteractor.cxx +++ b/src/SVTK/SVTK_RenderWindowInteractor.cxx @@ -34,7 +34,7 @@ // QT Includes // Put Qt includes before the X11 includes which #define the symbol None // (see SVTK_SpaceMouse.h) to avoid the compilation error. -#ifndef WIN32 +#if !defined(WIN32) && !defined(__APPLE__) #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #include #endif @@ -84,7 +84,7 @@ QVTK_RenderWindowInteractor myRenderWindow->Delete(); myRenderWindow->DoubleBufferOn(); -#ifndef WIN32 +#if !defined WIN32 && !defined __APPLE__ myRenderWindow->SetDisplayId((void*)QX11Info::display()); #endif myRenderWindow->SetWindowId((void*)winId()); @@ -112,7 +112,7 @@ QVTK_RenderWindowInteractor QVTK_RenderWindowInteractor ::~QVTK_RenderWindowInteractor() { -#ifndef WIN32 +#if !defined WIN32 && !defined __APPLE__ #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) SVTK_SpaceMouseX* aSpaceMouse = SVTK_SpaceMouseX::getInstance(); if ( aSpaceMouse && aSpaceMouse->isSpaceMouseOn() ) @@ -415,7 +415,7 @@ QVTK_RenderWindowInteractor { QWidget::focusInEvent( event ); -#ifndef WIN32 +#if !defined WIN32 && !defined __APPLE__ // register set space mouse events receiver #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) SVTK_SpaceMouseX* aSpaceMouse = SVTK_SpaceMouseX::getInstance(); @@ -451,7 +451,7 @@ QVTK_RenderWindowInteractor { QWidget::focusOutEvent( event ); -#ifndef WIN32 +#if !defined WIN32 && !defined __APPLE__ #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) // unregister set space mouse events receiver SVTK_SpaceMouseX* aSpaceMouse = SVTK_SpaceMouseX::getInstance(); @@ -467,7 +467,7 @@ QVTK_RenderWindowInteractor // TODO (QT5 PORTING) Below is a temporary solution, to allow compiling with Qt 5 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) -#ifdef WIN32 +#if defined(WIN32) /*! To handle native Win32 events (from such devices as SpaceMouse) @@ -478,8 +478,7 @@ bool QVTK_RenderWindowInteractor::winEvent( MSG* msg, long* result ) return QWidget::winEvent( msg, result); } -#else - +#elif !defined(__APPLE__) /*! To handle native X11 events (from such devices as SpaceMouse) */ @@ -519,9 +518,9 @@ QVTK_RenderWindowInteractor bool QVTK_RenderWindowInteractor ::nativeEvent(const QByteArray& eventType, void* message, long* result) { -#ifdef WIN32 +#if defined(WIN32) // TODO: WIN32-related implementation -#else +#elif !defined(__APPLE__) if ( eventType == "xcb_generic_event_t" ) { xcb_generic_event_t* ev = static_cast(message); diff --git a/src/SVTK/SVTK_RenderWindowInteractor.h b/src/SVTK/SVTK_RenderWindowInteractor.h index 521794f67..e04a2edbf 100644 --- a/src/SVTK/SVTK_RenderWindowInteractor.h +++ b/src/SVTK/SVTK_RenderWindowInteractor.h @@ -124,9 +124,9 @@ class SVTK_EXPORT QVTK_RenderWindowInteractor: public QWidget //! To handle native events (from such devices as SpaceMouse) // TODO (QT5 PORTING) Below is a temporary solution, to allow compiling with Qt 5 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) -#ifdef WIN32 +#if defined(WIN32) virtual bool winEvent( MSG*, long* ); -#else +#elif !defined(__APPLE__) virtual bool x11Event( XEvent *e ); #endif #else diff --git a/src/SVTK/SVTK_SpaceMouse.cxx b/src/SVTK/SVTK_SpaceMouse.cxx index 5db6b427d..7e8e6abf8 100644 --- a/src/SVTK/SVTK_SpaceMouse.cxx +++ b/src/SVTK/SVTK_SpaceMouse.cxx @@ -30,7 +30,7 @@ #include -#ifndef WIN32 +#if !defined WIN32 && !defined __APPLE__ #include #include #include @@ -64,7 +64,7 @@ SVTK_SpaceMouse::SVTK_SpaceMouse() SVTK_SpaceMouseX::SVTK_SpaceMouseX() : SVTK_SpaceMouse() { -#ifndef WIN32 +#if !defined WIN32 && !defined __APPLE__ win = InputFocus; #endif } @@ -79,7 +79,7 @@ SVTK_SpaceMouseX* SVTK_SpaceMouseX::getInstance() return myInstance; } -#ifndef WIN32 +#if !defined WIN32 && !defined __APPLE__ static int errorCallback( Display *display, XErrorEvent *Error ) { @@ -232,7 +232,7 @@ int SVTK_SpaceMouseX::translateEvent( Display* display, XEvent* xEvent, MoveEven SVTK_SpaceMouseXCB::SVTK_SpaceMouseXCB() : SVTK_SpaceMouse() { -#ifndef WIN32 +#if !defined WIN32 && !defined __APPLE__ win = InputFocus; #endif } @@ -249,7 +249,7 @@ SVTK_SpaceMouseXCB* SVTK_SpaceMouseXCB::getInstance() /*! Initialization */ -#ifndef WIN32 +#if !defined WIN32 && !defined __APPLE__ int SVTK_SpaceMouseXCB::initialize( xcb_connection_t *connection, xcb_window_t window ) { // make request diff --git a/src/SVTK/SVTK_SpaceMouse.h b/src/SVTK/SVTK_SpaceMouse.h index ab140cd0d..af04575a5 100644 --- a/src/SVTK/SVTK_SpaceMouse.h +++ b/src/SVTK/SVTK_SpaceMouse.h @@ -29,7 +29,7 @@ #include -#ifndef WIN32 +#if !defined WIN32 && !defined __APPLE__ extern "C" { #include @@ -39,7 +39,6 @@ extern "C" #include #endif } - #endif class SVTK_SpaceMouse @@ -76,7 +75,7 @@ public: // access to SpaceMouse utility class static SVTK_SpaceMouseX* getInstance(); -#ifndef WIN32 +#if !defined WIN32 && !defined __APPLE__ int initialize ( Display*, Window ); int setWindow ( Display*, Window ); int translateEvent ( Display*, XEvent*, MoveEvent*, double, double ); @@ -93,7 +92,9 @@ private: static SVTK_SpaceMouseX* myInstance; }; + #else + class SVTK_SpaceMouseXCB: public SVTK_SpaceMouse { @@ -103,7 +104,7 @@ public: // access to SpaceMouse utility class static SVTK_SpaceMouseXCB* getInstance(); -#ifndef WIN32 +#if !defined WIN32 && !defined __APPLE__ int initialize ( xcb_connection_t*, xcb_window_t ); int setWindow ( xcb_connection_t*, xcb_window_t ); int translateEvent ( xcb_connection_t*, xcb_client_message_event_t*, MoveEvent*, double, double ); @@ -119,5 +120,6 @@ private: static SVTK_SpaceMouseXCB* myInstance; }; + #endif #endif diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index 16578ddbf..d13911d46 100755 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -105,7 +105,11 @@ #include +#ifdef __APPLE__ +#include +#else #include +#endif namespace SVTK { diff --git a/src/Session/SALOME_Session_Server.cxx b/src/Session/SALOME_Session_Server.cxx index 021cc2643..a5389c9fc 100755 --- a/src/Session/SALOME_Session_Server.cxx +++ b/src/Session/SALOME_Session_Server.cxx @@ -248,7 +248,7 @@ class SALOME_QApplication : public QApplication public: SALOME_QApplication( int& argc, char** argv ) // TODO (QT5 PORTING) Below is a temporary solution, to allow compiling with Qt 5 -#if !defined WIN32 && QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +#if !defined(WIN32) && !defined(__APPLE__) && (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) // san: Opening an X display and choosing a visual most suitable for 3D visualization // in order to make SALOME viewers work with non-native X servers : QApplication( (Display*)Qtx::getDisplay(), argc, argv, Qtx::getVisual() ), diff --git a/src/VTKViewer/VTKViewer_PolyDataMapper.cxx b/src/VTKViewer/VTKViewer_PolyDataMapper.cxx index 7dca2f88d..807154003 100644 --- a/src/VTKViewer/VTKViewer_PolyDataMapper.cxx +++ b/src/VTKViewer/VTKViewer_PolyDataMapper.cxx @@ -46,7 +46,27 @@ # ifndef GLX_GLXEXT_LEGACY # define GLX_GLXEXT_LEGACY # endif +#ifdef __APPLE__ +#import +#import +#import +void * glXGetProcAddressARB (const GLubyte *name) + +{ + NSSymbol symbol; + char *symbolName; + symbolName = (char *)malloc (strlen ((const char *)name) + 2); // 1 + strcpy(symbolName + 1, (const char *)name); // 2 + symbolName[0] = '_'; // 3 + symbol = NULL; + if (NSIsSymbolNameDefined (symbolName)) // 4 + symbol = NSLookupAndBindSymbol (symbolName); + free (symbolName); // 5 + return symbol ? NSAddressOfSymbol (symbol) : NULL; // 6 +} +#else # include +#endif # include #else # include diff --git a/src/VTKViewer/VTKViewer_PolyDataMapper.h b/src/VTKViewer/VTKViewer_PolyDataMapper.h index 8fa5725b0..14418801a 100644 --- a/src/VTKViewer/VTKViewer_PolyDataMapper.h +++ b/src/VTKViewer/VTKViewer_PolyDataMapper.h @@ -29,7 +29,11 @@ #include +#ifdef __APPLE__ +#include +#else #include +#endif #include diff --git a/src/VTKViewer/VTKViewer_RenderWindow.cxx b/src/VTKViewer/VTKViewer_RenderWindow.cxx index 2395f8c96..16aafdbc3 100755 --- a/src/VTKViewer/VTKViewer_RenderWindow.cxx +++ b/src/VTKViewer/VTKViewer_RenderWindow.cxx @@ -31,7 +31,7 @@ #include #include #include -#ifndef WIN32 +#if !defined WIN32 && !defined __APPLE__ #include #include #endif @@ -47,7 +47,7 @@ QWidget(parent, Qt::FramelessWindowHint ) setAttribute( Qt::WA_DeleteOnClose ); myRW = vtkRenderWindow::New(); -#ifndef WIN32 +#if !defined WIN32 && !defined __APPLE__ myRW->SetDisplayId((void*)(QX11Info::display())); #endif myRW->SetWindowId((void*)winId()); -- 2.39.2