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
# 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()
// Qt includes
#include <QColor>
-
-#ifndef WIN32
+#if !defined(WIN32) && !defined(__APPLE__)
#include <GL/glx.h>
#endif
#include <Quantity_NameOfColor.hxx>
#include <Quantity_Color.hxx>
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
class GLViewer_Viewer2d;
#include <QPainter>
#include <QFile>
-#ifndef WIN32
+#if defined(__APPLE__)
+#include <OpenGL/CGLCurrent.h>
+#elif !defined(WIN32)
#include <GL/glx.h>
#endif
aFindFont.myIsUndl = theFont->underline();
aFindFont.myPointSize = theFont->pointSize();
-#ifdef WIN32
+#if defined(WIN32)
HGLRC ctx = ::wglGetCurrentContext();
if ( !ctx )
return aList;
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<GLViewer_TexFindId, GLuint>::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 )
class QFile;
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
#include "GLViewer.h"
#include "GLViewer_Defs.h"
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
{
#include "GLViewer.h"
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#include <OpenGL/glu.h>
+#else
#include <GL/gl.h>
#include <GL/glu.h>
+#endif
#ifdef WIN32
#pragma warning( disable:4251 )
#include "GLViewer.h"
#include "GLViewer_Geom.h"
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
#include <QString>
#include "GLViewer.h"
#include "GLViewer_Defs.h"
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
#include <QFont>
#include <QString>
//
#include "GLViewer_Tools.h"
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
#include <iostream>
#include <string.h>
#include <stdlib.h>
-#if !defined WIN32
+#if !defined WIN32 && !defined __APPLE__
#include <QX11Info>
#include <GL/glx.h>
#include <X11/Xlib.h>
*/
void GLViewer_ViewPort::selectVisualId( ViewType type )
{
-#if !defined WIN32
+#if !defined WIN32 && !defined __APPLE__
XVisualInfo* pVisualInfo;
if ( QX11Info::display() )
{
#include <windows.h>
#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#include <OpenGL/glu.h>
+#else
#include <GL/gl.h>
#include <GL/glu.h>
+#endif
#include "GLViewer_ViewPort.h"
#include "GLViewer_Widget.h"
#include <TColStd_SequenceOfInteger.hxx>
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
class GLViewer_Object;
class GLViewer_ViewFrame;
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
#include <windows.h>
#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
#include "OCCViewer_Trihedron.h"
#include <PrsMgr_PresentationManager3d.hxx>
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
# include <GL/glx.h>
#endif
bool ok = false;
GLuint aList = glGenLists( 256 );
-#ifdef WIN32
+#if defined(WIN32)
HGLRC hglrc = wglGetCurrentContext();
if( hglrc )
{
SelectObject( hdc, oldFont );
DeleteObject( font );
}
-#else // X Window
+#elif !defined(__APPLE__) // X Window
Display* dpy = glXGetCurrentDisplay();
if( dpy )
{
#endif
#include <Aspect_DisplayConnection.hxx>
-#ifdef WIN32
+#if defined(WIN32)
#include <WNT_Window.hxx>
+#elif defined(__APPLE__)
+#include <Cocoa_Window.hxx>
#else
#include <Xw_Window.hxx>
#endif
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 );
if (aGraphicDriver.IsNull())
{
Handle(Aspect_DisplayConnection) aDisplayConnection;
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
aDisplayConnection = new Aspect_DisplayConnection( displayName );
#else
aDisplayConnection = new Aspect_DisplayConnection();
#include <stdlib.h>
-#if !defined WIN32
+#if !defined WIN32 && !defined __APPLE__
#include <QX11Info>
#include <GL/glx.h>
#include <X11/Xlib.h>
*/
void OCCViewer_ViewPort::selectVisualId()
{
-#if !defined WIN32
+#if !defined WIN32 && !defined __APPLE__
XVisualInfo* pVisualInfo;
if ( QX11Info::display() )
{
//# include <QWindowsStyle>
//#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
// To avoid conflict between KeyPress from the X.h (define KeyPress 2)
// and QEvent::KeyPress (qevent.h)
# ifndef GLX_GLXEXT_LEGACY
# define GLX_GLXEXT_LEGACY
# endif
+#ifdef __APPLE__
+#import <mach-o/dyld.h>
+#import <stdlib.h>
+#import <string.h>
+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 <GL/glx.h>
+#endif
# include <dlfcn.h>
#else
# include <wingdi.h>
#include <windows.h>
#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
class OPENGLUTILS_EXPORT OpenGLUtils_FrameBuffer
{
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( "." );
return font;
}
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
#include <X11/Xlib.h>
#include <GL/glx.h>
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;
}
}
# --- 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})
*/
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() ),
// 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 <xcb/xcb.h>
#endif
myRenderWindow->Delete();
myRenderWindow->DoubleBufferOn();
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
myRenderWindow->SetDisplayId((void*)QX11Info::display());
#endif
myRenderWindow->SetWindowId((void*)winId());
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() )
{
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();
{
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();
// 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)
return QWidget::winEvent( msg, result);
}
-#else
-
+#elif !defined(__APPLE__)
/*!
To handle native X11 events (from such devices as SpaceMouse)
*/
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<xcb_generic_event_t *>(message);
//! 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
#include <QtGlobal>
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
#include <X11/X.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
SVTK_SpaceMouseX::SVTK_SpaceMouseX()
: SVTK_SpaceMouse()
{
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
win = InputFocus;
#endif
}
return myInstance;
}
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
static int errorCallback( Display *display, XErrorEvent *Error )
{
SVTK_SpaceMouseXCB::SVTK_SpaceMouseXCB()
: SVTK_SpaceMouse()
{
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
win = InputFocus;
#endif
}
/*!
Initialization
*/
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
int SVTK_SpaceMouseXCB::initialize( xcb_connection_t *connection, xcb_window_t window )
{
// make request
#include <QtGlobal>
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
extern "C"
{
#include <X11/X.h>
#include <xcb/xcb.h>
#endif
}
-
#endif
class SVTK_SpaceMouse
// 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 );
static SVTK_SpaceMouseX* myInstance;
};
+
#else
+
class SVTK_SpaceMouseXCB: public SVTK_SpaceMouse
{
// 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 );
static SVTK_SpaceMouseXCB* myInstance;
};
+
#endif
#endif
#include <OpenGLUtils_FrameBuffer.h>
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
namespace SVTK
{
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() ),
# ifndef GLX_GLXEXT_LEGACY
# define GLX_GLXEXT_LEGACY
# endif
+#ifdef __APPLE__
+#import <mach-o/dyld.h>
+#import <stdlib.h>
+#import <string.h>
+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 <GL/glx.h>
+#endif
# include <dlfcn.h>
#else
# include <wingdi.h>
#include <map>
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
#include <vtkSmartPointer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRendererCollection.h>
#include <vtkCamera.h>
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
#include <QX11Info>
#include <vtkXOpenGLRenderWindow.h>
#endif
setAttribute( Qt::WA_DeleteOnClose );
myRW = vtkRenderWindow::New();
-#ifndef WIN32
+#if !defined WIN32 && !defined __APPLE__
myRW->SetDisplayId((void*)(QX11Info::display()));
#endif
myRW->SetWindowId((void*)winId());