From: apn Date: Wed, 1 Nov 2017 09:53:29 +0000 (+0300) Subject: 0029187: VIS - TKIVtkDraw should support Cocoa on macOS X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2FCR29187;p=occt-copy.git 0029187: VIS - TKIVtkDraw should support Cocoa on macOS Adding support of Cocoa on macOS --- diff --git a/src/IVtkDraw/IVtkDraw.cxx b/src/IVtkDraw/IVtkDraw.cxx index 18ccdb92d8..dc09131f0a 100644 --- a/src/IVtkDraw/IVtkDraw.cxx +++ b/src/IVtkDraw/IVtkDraw.cxx @@ -54,6 +54,10 @@ #include #include #include +#elif defined(__APPLE__) && !defined(MACOSX_USE_GLX) +#include +#else +#include #endif #include @@ -117,7 +121,6 @@ #include #include #include -#include #include #include #include @@ -212,21 +215,23 @@ static Handle(PipelinePtr) PipelineByActorName (const TCollection_AsciiString& t } #ifdef _WIN32 - static Handle(WNT_Window)& GetWindow() { - static Handle(WNT_Window) aWindow; + static Handle(WNT_Window) WNTWin; + return WNTWin; +} +#elif defined(__APPLE__) && !defined(MACOSX_USE_GLX) +static Handle(Cocoa_Window)& GetWindow() +{ + static Handle(Cocoa_Window) aWindow; return aWindow; } - #else - static Handle(Xw_Window)& GetWindow() { static Handle(Xw_Window) aXWWin; return aXWWin; } - #endif static vtkSmartPointer& GetInteractor() @@ -313,8 +318,15 @@ void IVtkDraw::ViewerInit (Standard_Integer thePxLeft, Quantity_NOC_BLACK); GetWindow()->SetVirtual (Draw_VirtualWindows); } +#elif defined(__APPLE__) && !defined(MACOSX_USE_GLX) + if (GetWindow().IsNull()) + { + GetWindow() = new Cocoa_Window ("IVtkTest", + aPxLeft, aPxTop, + aPxWidth, aPxHeight); + GetWindow()->SetVirtual (Draw_VirtualWindows); + } #else - if (GetWindow().IsNull()) { GetWindow() = new Xw_Window (GetDisplayConnection(), @@ -332,9 +344,7 @@ void IVtkDraw::ViewerInit (Standard_Integer thePxLeft, GetRenderer()->GetActiveCamera()->ParallelProjectionOn(); aRenWin->SetSize (aPxWidth, aPxHeight); -#ifdef _WIN32 - aRenWin->SetWindowId((void*)GetWindow()->HWindow()); -#else +#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) Window aWindowId = GetWindow()->XWindow(); aRenWin->SetWindowId ((void*)aWindowId); Display *aDisplayId = GetDisplayConnection()->GetDisplay(); @@ -360,7 +370,11 @@ void IVtkDraw::ViewerInit (Standard_Integer thePxLeft, ); XSynchronize (aDisplayId, 0); - +#elif defined(__APPLE__) && !defined(MACOSX_USE_GLX) + // __APPLE__ +#else + // _WIN32 + aRenWin->SetWindowId((void*)GetWindow()->HWindow()); #endif // Init interactor