1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

Compare commits

...

1 Commits

Author SHA1 Message Date
apn
18bf6aa82f 0029187: VIS - TKIVtkDraw should support Cocoa on macOS
Adding support of Cocoa on macOS
2017-11-01 12:53:29 +03:00

View File

@@ -54,6 +54,10 @@
#include <windows.h> #include <windows.h>
#include <WNT_WClass.hxx> #include <WNT_WClass.hxx>
#include <WNT_Window.hxx> #include <WNT_Window.hxx>
#elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
#include <Cocoa_Window.hxx>
#else
#include <Xw_Window.hxx>
#endif #endif
#include <Draw.hxx> #include <Draw.hxx>
@@ -117,7 +121,6 @@
#include <X11/Shell.h> #include <X11/Shell.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <GL/glx.h> #include <GL/glx.h>
#include <Xw_Window.hxx>
#include <vtkXRenderWindowInteractor.h> #include <vtkXRenderWindowInteractor.h>
#include <vtkXOpenGLRenderWindow.h> #include <vtkXOpenGLRenderWindow.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
@@ -212,21 +215,23 @@ static Handle(PipelinePtr) PipelineByActorName (const TCollection_AsciiString& t
} }
#ifdef _WIN32 #ifdef _WIN32
static Handle(WNT_Window)& GetWindow() 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; return aWindow;
} }
#else #else
static Handle(Xw_Window)& GetWindow() static Handle(Xw_Window)& GetWindow()
{ {
static Handle(Xw_Window) aXWWin; static Handle(Xw_Window) aXWWin;
return aXWWin; return aXWWin;
} }
#endif #endif
static vtkSmartPointer<IVtkDraw_Interactor>& GetInteractor() static vtkSmartPointer<IVtkDraw_Interactor>& GetInteractor()
@@ -313,8 +318,15 @@ void IVtkDraw::ViewerInit (Standard_Integer thePxLeft,
Quantity_NOC_BLACK); Quantity_NOC_BLACK);
GetWindow()->SetVirtual (Draw_VirtualWindows); 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 #else
if (GetWindow().IsNull()) if (GetWindow().IsNull())
{ {
GetWindow() = new Xw_Window (GetDisplayConnection(), GetWindow() = new Xw_Window (GetDisplayConnection(),
@@ -332,9 +344,7 @@ void IVtkDraw::ViewerInit (Standard_Integer thePxLeft,
GetRenderer()->GetActiveCamera()->ParallelProjectionOn(); GetRenderer()->GetActiveCamera()->ParallelProjectionOn();
aRenWin->SetSize (aPxWidth, aPxHeight); aRenWin->SetSize (aPxWidth, aPxHeight);
#ifdef _WIN32 #if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
aRenWin->SetWindowId((void*)GetWindow()->HWindow());
#else
Window aWindowId = GetWindow()->XWindow(); Window aWindowId = GetWindow()->XWindow();
aRenWin->SetWindowId ((void*)aWindowId); aRenWin->SetWindowId ((void*)aWindowId);
Display *aDisplayId = GetDisplayConnection()->GetDisplay(); Display *aDisplayId = GetDisplayConnection()->GetDisplay();
@@ -360,7 +370,11 @@ void IVtkDraw::ViewerInit (Standard_Integer thePxLeft,
); );
XSynchronize (aDisplayId, 0); XSynchronize (aDisplayId, 0);
#elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
// __APPLE__
#else
// _WIN32
aRenWin->SetWindowId((void*)GetWindow()->HWindow());
#endif #endif
// Init interactor // Init interactor