mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-04 18:06:22 +03:00
0023701: Add Cocoa support to Qt samples
Adapted Qt samples for using Cocoa on Mac OS X
This commit is contained in:
parent
6aac585ac8
commit
5f9575b332
@ -18,9 +18,11 @@
|
||||
#include <Graphic3d_ExportFormat.hxx>
|
||||
#include <QWindowsStyle>
|
||||
|
||||
#ifdef WNT
|
||||
#if defined(_WIN32) || defined(__WIN32__)
|
||||
#include <WNT_Window.hxx>
|
||||
#include <Graphic3d_WNTGraphicDevice.hxx>
|
||||
#elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
|
||||
#include <Cocoa_Window.hxx>
|
||||
#else
|
||||
#include <QX11Info>
|
||||
#include <GL/glx.h>
|
||||
@ -53,7 +55,7 @@ View::View( Handle(AIS_InteractiveContext) theContext, QWidget* parent )
|
||||
: QWidget( parent ),
|
||||
myViewActions( 0 )
|
||||
{
|
||||
#ifndef WNT
|
||||
#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
|
||||
//XSynchronize( x11Display(),true ); // it is possible to use QApplication::syncX();
|
||||
XSynchronize( x11Info().display(),true ); // it is possible to use QApplication::syncX();
|
||||
#endif
|
||||
@ -70,7 +72,7 @@ myViewActions( 0 )
|
||||
setAttribute(Qt::WA_PaintOnScreen);
|
||||
setAttribute(Qt::WA_NoSystemBackground);
|
||||
|
||||
#if !defined WNT
|
||||
#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
|
||||
XVisualInfo* pVisualInfo;
|
||||
if ( x11Info().display() )
|
||||
{
|
||||
@ -161,22 +163,28 @@ View::~View()
|
||||
|
||||
void View::init()
|
||||
{
|
||||
if(myView.IsNull())
|
||||
myView = myContext->CurrentViewer()->CreateView();
|
||||
int windowHandle = (int) winId();
|
||||
short hi, lo;
|
||||
lo = (short) windowHandle;
|
||||
hi = (short) (windowHandle >> 16);
|
||||
#ifdef WNT
|
||||
Handle(WNT_Window) hWnd = new WNT_Window(Handle(Graphic3d_WNTGraphicDevice)::DownCast(myContext->CurrentViewer()->Device()),(int) hi,(int) lo);
|
||||
if (myView.IsNull())
|
||||
myView = myContext->CurrentViewer()->CreateView();
|
||||
#if defined(_WIN32) || defined(__WIN32__)
|
||||
Aspect_Handle aWindowHandle = (Aspect_Handle )winId();
|
||||
Handle(WNT_Window) hWnd = new WNT_Window (Handle(Graphic3d_WNTGraphicDevice)::DownCast (myContext->CurrentViewer()->Device()),
|
||||
aWindowHandle);
|
||||
#elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
|
||||
NSView* aViewHandle = (NSView* )winId();
|
||||
Handle(Cocoa_Window) hWnd = new Cocoa_Window (aViewHandle);
|
||||
#else
|
||||
Handle(Xw_Window) hWnd = new Xw_Window(Handle(Graphic3d_GraphicDevice)::DownCast(myContext->CurrentViewer()->Device()),(int) hi,(int) lo,Xw_WQ_SAMEQUALITY);
|
||||
Aspect_Handle aWindowHandle = (Aspect_Handle )winId();
|
||||
Handle(Xw_Window) hWnd = new Xw_Window (Handle(Graphic3d_GraphicDevice)::DownCast (myContext->CurrentViewer()->Device()),
|
||||
aWindowHandle,
|
||||
Xw_WQ_SAMEQUALITY);
|
||||
#endif // WNT
|
||||
myView->SetWindow( hWnd );
|
||||
if ( !hWnd->IsMapped() )
|
||||
hWnd->Map();
|
||||
myView->SetBackgroundColor(Quantity_NOC_BLACK);
|
||||
myView->MustBeResized();
|
||||
myView->SetWindow (hWnd);
|
||||
if (!hWnd->IsMapped())
|
||||
{
|
||||
hWnd->Map();
|
||||
}
|
||||
myView->SetBackgroundColor (Quantity_NOC_BLACK);
|
||||
myView->MustBeResized();
|
||||
}
|
||||
|
||||
void View::paintEvent( QPaintEvent * e )
|
||||
|
@ -30,9 +30,13 @@ unix {
|
||||
OBJECTS_DIR = ./$$UNAME/obj
|
||||
MOC_DIR = ./$$UNAME/src
|
||||
}
|
||||
INCLUDEPATH += $$QMAKE_INCDIR_X11 $$QMAKE_INCDIR_OPENGL $$QMAKE_INCDIR_THREAD
|
||||
DEFINES += LIN LININTEL OCC_CONVERT_SIGNALS HAVE_CONFIG_H HAVE_WOK_CONFIG_H QT_NO_STL
|
||||
LIBS += -L$$QMAKE_LIBDIR_X11 $$QMAKE_LIBS_X11 -L$$QMAKE_LIBDIR_OPENGL $$QMAKE_LIBS_OPENGL $$QMAKE_LIBS_THREAD
|
||||
|
||||
MACOSX_USE_GLX = $$(MACOSX_USE_GLX)
|
||||
|
||||
!macx | equals(MACOSX_USE_GLX, true): INCLUDEPATH += $$QMAKE_INCDIR_X11 $$QMAKE_INCDIR_OPENGL $$QMAKE_INCDIR_THREAD
|
||||
!macx | equals(MACOSX_USE_GLX, true): DEFINES += LIN LININTEL
|
||||
DEFINES += OCC_CONVERT_SIGNALS HAVE_CONFIG_H HAVE_WOK_CONFIG_H QT_NO_STL
|
||||
!macx | equals(MACOSX_USE_GLX, true): LIBS += -L$$QMAKE_LIBDIR_X11 $$QMAKE_LIBS_X11 -L$$QMAKE_LIBDIR_OPENGL $$QMAKE_LIBS_OPENGL $$QMAKE_LIBS_THREAD
|
||||
LIBS += -lfreeimageplus
|
||||
LIBS += -ltbb -ltbbmalloc
|
||||
}
|
||||
|
4
samples/qt/IESample/make.sh
Normal file → Executable file
4
samples/qt/IESample/make.sh
Normal file → Executable file
@ -4,4 +4,6 @@ export aSamplePath="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
if [ -e "${aSamplePath}/env.sh" ]; then source "${aSamplePath}/env.sh"; fi
|
||||
cd $aSamplePath
|
||||
qmake IESample.pro
|
||||
make
|
||||
if test `uname -s` != "Darwin"; then
|
||||
make
|
||||
fi
|
||||
|
@ -8,7 +8,17 @@ host=`uname -s`
|
||||
STATION=$host
|
||||
|
||||
RES_DIR="${aSamplePath}/res"
|
||||
BIN_DIR="${aSamplePath}/${STATION}/bin"
|
||||
|
||||
aSystem=`uname -s`
|
||||
if [ "$aSystem" == "Darwin" ]; then
|
||||
if [ "${CASDEB}" == "d" ]; then
|
||||
BIN_DIR="${aSamplePath}/build/Debug/IESample.app/Contents/MacOS"
|
||||
else
|
||||
BIN_DIR="${aSamplePath}/build/Release/IESample.app/Contents/MacOS"
|
||||
fi
|
||||
else
|
||||
BIN_DIR="${aSamplePath}/${STATION}/bin${CASDEB}"
|
||||
fi
|
||||
|
||||
CSF_ResourcesDefaults="${RES_DIR}"
|
||||
CSF_IEResourcesDefaults="${RES_DIR}"
|
||||
@ -19,9 +29,13 @@ export CSF_IEResourcesDefaults CSF_ResourcesDefaults
|
||||
export PATH
|
||||
|
||||
if test ! -r "${BIN_DIR}/IESample"; then
|
||||
echo "Executable \"${BIN_DIR}/IESample\" not found."
|
||||
echo "Probably you don't compile the application. Execute \"make\"."
|
||||
exit 1
|
||||
echo "Executable \"${BIN_DIR}/IESample\" not found."
|
||||
if [ "$aSystem" == "Darwin" ]; then
|
||||
echo "Probably you don't compile the application. Build it with Xcode."
|
||||
else
|
||||
echo "Probably you don't compile the application. Execute \"make\"."
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
${BIN_DIR}/IESample
|
||||
|
@ -32,11 +32,15 @@ unix {
|
||||
OBJECTS_DIR = ./$$UNAME/obj
|
||||
MOC_DIR = ./$$UNAME/src
|
||||
}
|
||||
INCLUDEPATH += $$QMAKE_INCDIR_X11 $$QMAKE_INCDIR_OPENGL $$QMAKE_INCDIR_THREAD
|
||||
DEFINES += LIN LININTEL OCC_CONVERT_SIGNALS HAVE_CONFIG_H HAVE_WOK_CONFIG_H
|
||||
LIBS += -L$$QMAKE_LIBDIR_X11 $$QMAKE_LIBS_X11 -L$$QMAKE_LIBDIR_OPENGL $$QMAKE_LIBS_OPENGL $$QMAKE_LIBS_THREAD
|
||||
LIBS += -lfreeimageplus
|
||||
LIBS += -ltbb -ltbbmalloc
|
||||
|
||||
MACOSX_USE_GLX = $$(MACOSX_USE_GLX)
|
||||
|
||||
!macx | equals(MACOSX_USE_GLX, true): INCLUDEPATH += $$QMAKE_INCDIR_X11 $$QMAKE_INCDIR_OPENGL $$QMAKE_INCDIR_THREAD
|
||||
!macx | equals(MACOSX_USE_GLX, true): DEFINES += LIN LININTEL
|
||||
DEFINES += OCC_CONVERT_SIGNALS HAVE_CONFIG_H HAVE_WOK_CONFIG_H QT_NO_STL
|
||||
!macx | equals(MACOSX_USE_GLX, true): LIBS += -L$$QMAKE_LIBDIR_X11 $$QMAKE_LIBS_X11 -L$$QMAKE_LIBDIR_OPENGL $$QMAKE_LIBS_OPENGL $$QMAKE_LIBS_THREAD
|
||||
LIBS += -lfreeimageplus
|
||||
LIBS += -ltbb -ltbbmalloc
|
||||
}
|
||||
|
||||
win32 {
|
||||
|
@ -4,4 +4,6 @@ export aSamplePath="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
if [ -e "${aSamplePath}/env.sh" ]; then source "${aSamplePath}/env.sh"; fi
|
||||
cd $aSamplePath
|
||||
qmake Tutorial.pro
|
||||
make
|
||||
if test `uname -s` != "Darwin"; then
|
||||
make
|
||||
fi
|
||||
|
@ -8,7 +8,17 @@ host=`uname -s`
|
||||
STATION=$host
|
||||
|
||||
RES_DIR="${aSamplePath}/res"
|
||||
BIN_DIR="${aSamplePath}/${STATION}/bin"
|
||||
|
||||
aSystem=`uname -s`
|
||||
if [ "$aSystem" == "Darwin" ]; then
|
||||
if [ "${CASDEB}" == "d" ]; then
|
||||
BIN_DIR="${aSamplePath}/build/Debug/Tutorial.app/Contents/MacOS"
|
||||
else
|
||||
BIN_DIR="${aSamplePath}/build/Release/Tutorial.app/Contents/MacOS"
|
||||
fi
|
||||
else
|
||||
BIN_DIR="${aSamplePath}/${STATION}/bin${CASDEB}"
|
||||
fi
|
||||
|
||||
CSF_ResourcesDefaults="${RES_DIR}"
|
||||
CSF_TutorialResourcesDefaults="${RES_DIR}"
|
||||
@ -19,9 +29,13 @@ export CSF_TutorialResourcesDefaults CSF_ResourcesDefaults
|
||||
export PATH
|
||||
|
||||
if test ! -r "${BIN_DIR}/Tutorial"; then
|
||||
echo "Executable \"${BIN_DIR}/Tutorial\" not found."
|
||||
echo "Probably you don't compile the application. Execute \"make\"."
|
||||
exit 1
|
||||
echo "Executable \"${BIN_DIR}/Tutorial\" not found."
|
||||
if [ "$aSystem" == "Darwin" ]; then
|
||||
echo "Probably you don't compile the application. Build it with Xcode."
|
||||
else
|
||||
echo "Probably you don't compile the application. Execute \"make\"."
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
${BIN_DIR}/Tutorial
|
||||
|
Loading…
x
Reference in New Issue
Block a user