QT4.3 and OpenCascade 6.2 possible?

Hello everybody,

I'm new in programming in OpenCascade.

I would like to be able to do cross platform applications.
I noticed that there are examples of Opencascade + QT.
I recently downloaded QT 4.3 and tried to do some basic programs. After few problems this works well. I noticed that all examples are for VC++.
Does opencascade work only with older versions of QT?
The new version (non-commercial) doesn't support Microsoft compiler form vc++ any more. It works with mingw.

Is there any way to use qt4 with opencascade and compile in mingw?
And use Dev-C++ to write code??

Thank you for answer in advance.

P Dolbey's picture

As far as I know, OCC 6.2 has not been compiled with MinGW, although it may be theoretically possible.

You can head over to

http://sourceforge.net/projects/qtwin/

and pick up the latest patches to enable Qt4 4.3 opensource to compile under vs2005 from the kde community. However there are reported problems compiling this with versions earlier than vs2005. Qt 4.2.3 still works fine. There's plenty of reference and guides on how to use these pathes.

Pete

P Dolbey's picture

Actually the "readme" for the qtwin patch1 explaing how to fix these issues.

http://sourceforge.net/project/shownotes.php?release_id=428110&group_id=...

Pete

Pawel Dobrowolski's picture

Thank you for reply,

So I will try to do like this:
I will download VC++ 2005 Express from Microsoft web page and try to follow your suggestions.

Does VC++ 2005 Express have any limitations that can make working with QT and OpenCascade impossible?

The problem is that I don't have much experience in programming.
When you read about QT and Open Cascade you think - OK all classes are done so only use it. There is big documentation so there will not be any problem.
But when you start testing you must fight with many problems that are complicated for fresh programmer.

I will be trying but I think I will write here many times.
Sorry for basic questions which I will ask in advance ;-).

Once more thanks for support and I hope I will succeed thanks answers from this forum.

P Dolbey's picture

If you use express, you'll also need to get the Platform SDK - a big download! Apart from that, its a common platform for Qt4 / qtwin development. Its always worth looking at the Qt forums, http://www.qtcentre.org/forum and http://www.qtforum.org for advice.

Pete

Pawel Dobrowolski's picture

Thank you I will follow your suggestions.

If I have any more questions I will ask.

Regards,

Pawel

Pawel Dobrowolski's picture

Hello again,

I have VC++ 2005 configured for QT4.
Examples from qt compile correctly.

I have downloaded example from:
http://myweb.tiscali.co.uk/dolbey/QtOpenCascade/index.htm#downloadables

When I added opencascade path to environment it compiled successfully
but I have "Run Time error" When I launch exe file

below log from compilation

could somebody help?

---------------------------------------

Build Log

Rebuild started: Project: QtOpenCascade, Configuration: Release|Win32

Command Lines

Creating temporary file "D:\Temp\BAT00000136682492.bat" with contents
[
@echo off

h:\lib\Qt\4.3.0\bin\moc.exe -DNDEBUG -D_WINDOWS -DUNICODE -DQT_LARGEFILE_SUPPORT -DWIN32 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DCSFDB -D_DEBUG -DWNT -DQTOPENCASCADE_NO_DLL -DQT_DLL -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I "h:\lib\Qt\4.3.0\include\QtCore" -I "h:\lib\Qt\4.3.0\include\QtCore" -I "h:\lib\Qt\4.3.0\include\QtGui" -I "h:\lib\Qt\4.3.0\include\QtGui" -I "h:\lib\Qt\4.3.0\include\QtOpenGL" -I "h:\lib\Qt\4.3.0\include\QtOpenGL" -I "h:\lib\Qt\4.3.0\include" -I "." -I "F:\Programowanie\OpenCascade_6.2\ros\inc" -I "h:\lib\Qt\4.3.0\include\ActiveQt" -I "release" -I "." -I"h:\lib\Qt\4.3.0\mkspecs\win32-msvc2005" mainwindow.h -o release\moc_mainwindow.cpp

if errorlevel 1 goto VCReportError

goto VCEnd

:VCReportError

echo Project : error PRJ0019: A tool returned an error code from "MOC mainwindow.h"

exit 1

:VCEnd
]
Creating command line "D:\Temp\BAT00000136682492.bat"
Creating temporary file "D:\Temp\BAT00000236682492.bat" with contents
[
@echo off

h:\lib\Qt\4.3.0\bin\moc.exe -DNDEBUG -D_WINDOWS -DUNICODE -DQT_LARGEFILE_SUPPORT -DWIN32 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DCSFDB -D_DEBUG -DWNT -DQTOPENCASCADE_NO_DLL -DQT_DLL -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I "h:\lib\Qt\4.3.0\include\QtCore" -I "h:\lib\Qt\4.3.0\include\QtCore" -I "h:\lib\Qt\4.3.0\include\QtGui" -I "h:\lib\Qt\4.3.0\include\QtGui" -I "h:\lib\Qt\4.3.0\include\QtOpenGL" -I "h:\lib\Qt\4.3.0\include\QtOpenGL" -I "h:\lib\Qt\4.3.0\include" -I "." -I "F:\Programowanie\OpenCascade_6.2\ros\inc" -I "h:\lib\Qt\4.3.0\include\ActiveQt" -I "release" -I "." -I"h:\lib\Qt\4.3.0\mkspecs\win32-msvc2005" QtOCCViewerContext.h -o release\moc_QtOCCViewerContext.cpp

if errorlevel 1 goto VCReportError

goto VCEnd

:VCReportError

echo Project : error PRJ0019: A tool returned an error code from "MOC QtOCCViewerContext.h"

exit 1

:VCEnd
]
Creating command line "D:\Temp\BAT00000236682492.bat"
Creating temporary file "D:\Temp\BAT00000336682492.bat" with contents
[
@echo off

h:\lib\Qt\4.3.0\bin\moc.exe -DNDEBUG -D_WINDOWS -DUNICODE -DQT_LARGEFILE_SUPPORT -DWIN32 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DCSFDB -D_DEBUG -DWNT -DQTOPENCASCADE_NO_DLL -DQT_DLL -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I "h:\lib\Qt\4.3.0\include\QtCore" -I "h:\lib\Qt\4.3.0\include\QtCore" -I "h:\lib\Qt\4.3.0\include\QtGui" -I "h:\lib\Qt\4.3.0\include\QtGui" -I "h:\lib\Qt\4.3.0\include\QtOpenGL" -I "h:\lib\Qt\4.3.0\include\QtOpenGL" -I "h:\lib\Qt\4.3.0\include" -I "." -I "F:\Programowanie\OpenCascade_6.2\ros\inc" -I "h:\lib\Qt\4.3.0\include\ActiveQt" -I "release" -I "." -I"h:\lib\Qt\4.3.0\mkspecs\win32-msvc2005" QtOCCViewWidget.h -o release\moc_QtOCCViewWidget.cpp

if errorlevel 1 goto VCReportError

goto VCEnd

:VCReportError

echo Project : error PRJ0019: A tool returned an error code from "MOC QtOCCViewWidget.h"

exit 1

:VCEnd
]
Creating command line "D:\Temp\BAT00000336682492.bat"
Creating temporary file "D:\Temp\BAT00000436682492.bat" with contents
[
@echo off

h:\lib\Qt\4.3.0\bin\moc.exe -DNDEBUG -D_WINDOWS -DUNICODE -DQT_LARGEFILE_SUPPORT -DWIN32 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DCSFDB -D_DEBUG -DWNT -DQTOPENCASCADE_NO_DLL -DQT_DLL -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I "h:\lib\Qt\4.3.0\include\QtCore" -I "h:\lib\Qt\4.3.0\include\QtCore" -I "h:\lib\Qt\4.3.0\include\QtGui" -I "h:\lib\Qt\4.3.0\include\QtGui" -I "h:\lib\Qt\4.3.0\include\QtOpenGL" -I "h:\lib\Qt\4.3.0\include\QtOpenGL" -I "h:\lib\Qt\4.3.0\include" -I "." -I "F:\Programowanie\OpenCascade_6.2\ros\inc" -I "h:\lib\Qt\4.3.0\include\ActiveQt" -I "release" -I "." -I"h:\lib\Qt\4.3.0\mkspecs\win32-msvc2005" QtOCCInputOutput.h -o release\moc_QtOCCInputOutput.cpp

if errorlevel 1 goto VCReportError

goto VCEnd

:VCReportError

echo Project : error PRJ0019: A tool returned an error code from "MOC QtOCCInputOutput.h"

exit 1

:VCEnd
]
Creating command line "D:\Temp\BAT00000436682492.bat"
Creating temporary file "D:\Temp\RSP00000536682492.rsp" with contents
[
/O2 /I "h:\lib\Qt\4.3.0\include\QtCore" /I "h:\lib\Qt\4.3.0\include\QtGui" /I "h:\lib\Qt\4.3.0\include\QtOpenGL" /I "h:\lib\Qt\4.3.0\include" /I "." /I "f:\Programowanie\OpenCascade_6.2\ros\inc" /I "h:\lib\Qt\4.3.0\include\ActiveQt" /I "release" /I "h:\lib\Qt\4.3.0\mkspecs\win32-msvc2005" /D "NDEBUG" /D "_WINDOWS" /D "UNICODE" /D "QT_LARGEFILE_SUPPORT" /D "WIN32" /D "_CRT_SECURE_NO_DEPRECATE" /D "_CRT_NONSTDC_NO_DEPRECATE" /D "CSFDB" /D "_DEBUG" /D "WNT" /D "QTOPENCASCADE_NO_DLL" /D "QT_DLL" /D "QT_NO_DEBUG" /D "QT_OPENGL_LIB" /D "QT_GUI_LIB" /D "QT_CORE_LIB" /D "QT_THREAD_SUPPORT" /FD /EHsc /MD /Yu"QtOpenCascade.h" /Fp"release\\QtOpenCascade.pch" /Fo"release\\" /Fd".\\" /W3 /c /TP /FI "QtOpenCascade.h" -Zm200 -EHsc

".\release\moc_mainwindow.cpp"

".\release\moc_QtOCCViewerContext.cpp"

".\release\moc_QtOCCViewWidget.cpp"

".\release\moc_QtOCCInputOutput.cpp"

".\mainwindow.cpp"

".\main.cpp"

".\QtOCCViewerContext.cpp"

".\QtOCCViewWidget.cpp"

".\QtOCCInputOutput.cpp"

".\MakeBottle.cpp"
]
Creating command line "cl.exe @D:\Temp\RSP00000536682492.rsp /nologo /errorReport:prompt"
Creating temporary file "D:\Temp\RSP00000636682492.rsp" with contents
[
/O2 /I "h:\lib\Qt\4.3.0\include\QtCore" /I "h:\lib\Qt\4.3.0\include\QtGui" /I "h:\lib\Qt\4.3.0\include\QtOpenGL" /I "h:\lib\Qt\4.3.0\include" /I "." /I "f:\Programowanie\OpenCascade_6.2\ros\inc" /I "h:\lib\Qt\4.3.0\include\ActiveQt" /I "release" /I "h:\lib\Qt\4.3.0\mkspecs\win32-msvc2005" /D "NDEBUG" /D "_WINDOWS" /D "UNICODE" /D "QT_LARGEFILE_SUPPORT" /D "WIN32" /D "_CRT_SECURE_NO_DEPRECATE" /D "_CRT_NONSTDC_NO_DEPRECATE" /D "CSFDB" /D "_DEBUG" /D "WNT" /D "QTOPENCASCADE_NO_DLL" /D "QT_DLL" /D "QT_NO_DEBUG" /D "QT_OPENGL_LIB" /D "QT_GUI_LIB" /D "QT_CORE_LIB" /D "QT_THREAD_SUPPORT" /FD /EHsc /MD /Yc /Fp"release\\QtOpenCascade.pch" /Fo"release\\" /Fd".\\" /W3 /c /TP -Zm200 -EHsc

".\QtOpenCascade.h"
]
Creating command line "cl.exe @D:\Temp\RSP00000636682492.rsp /nologo /errorReport:prompt"
Creating command line "rc.exe /d "NDEBUG" /fo"release\/QtOpenCascade.res" ".\QtOpenCascade.rc""
Creating temporary file "D:\Temp\RSP00000736682492.rsp" with contents
[
/OUT:"release\QtOpenCascade.exe" /LIBPATH:"h:\lib\Qt\4.3.0\lib" /MANIFEST /MANIFESTFILE:"release\\QtOpenCascade.exe.intermediate.manifest" /SUBSYSTEM:WINDOWS h:\lib\Qt\4.3.0\lib\qtmain.lib opengl32.lib glu32.lib gdi32.lib user32.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\BinLPlugin.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\BinPlugin.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\BinXCAFPlugin.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\FWOSPlugin.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\mscmd.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\PTKernel.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\StdLPlugin.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\StdPlugin.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKAdvTools.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKBin.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKBinL.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKBinXCAF.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKBO.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKBool.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKBRep.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKCAF.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKCDF.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKCDLFront.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKCPPClient.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKCPPExt.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKCPPIntExt.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKCPPJini.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKCSFDBSchema.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKDCAF.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKDraw.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKernel.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKFeat.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKFillet.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKG2d.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKG3d.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKGeomAlgo.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKGeomBase.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKHLR.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKIDLFront.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKIGES.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKjcas.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKLCAF.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKMath.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKMesh.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKMeshVS.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKOffset.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKOpenGl.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKPCAF.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKPLCAF.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKPrim.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKPShape.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKService.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKShapeSchema.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKShHealing.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKStdLSchema.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKStdSchema.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKSTEP.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKSTEP209.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKSTEPAttr.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKSTEPBase.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKSTL.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKTCPPExt.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKTopAlgo.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKTopTest.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKV2d.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKV3d.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKViewerTest.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKVRML.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKXCAF.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKXCAFSchema.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKXDEDRAW.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKXDEIGES.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKXDESTEP.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKXml.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKXmlL.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKXmlXCAF.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKXSBase.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\TKXSDRAW.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\XCAFPlugin.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\XmlLPlugin.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\XmlPlugin.lib F:\Programowanie\OpenCascade_6.2\ros\win32\lib\XmlXCAFPlugin.lib h:\lib\Qt\4.3.0\lib\QtOpenGL4.lib h:\lib\Qt\4.3.0\lib\QtGui4.lib h:\lib\Qt\4.3.0\lib\QtCore4.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib

".\release\MakeBottle.obj"

".\release\QtOCCInputOutput.obj"

".\release\QtOCCViewWidget.obj"

".\release\QtOCCViewerContext.obj"

".\release\main.obj"

".\release\mainwindow.obj"

".\release\QtOpenCascade.obj"

".\release\moc_QtOCCInputOutput.obj"

".\release\moc_QtOCCViewWidget.obj"

".\release\moc_QtOCCViewerContext.obj"

".\release\moc_mainwindow.obj"

".\release\QtOpenCascade.res"
]
Creating command line "link.exe @D:\Temp\RSP00000736682492.rsp /NOLOGO /ERRORREPORT:PROMPT"
Creating temporary file "D:\Temp\RSP00000836682492.rsp" with contents
[
/outputresource:".\release\QtOpenCascade.exe;#1" /manifest

".\release\QtOpenCascade.exe.intermediate.manifest"
]
Creating command line "mt.exe @D:\Temp\RSP00000836682492.rsp /nologo"
Creating temporary file "D:\Temp\BAT00000936682492.bat" with contents
[
@echo Manifest resource last updated at %TIME% on %DATE% > ".\release\mt.dep"
]
Creating command line "D:\Temp\BAT00000936682492.bat"

Output Window

MOC mainwindow.h
MOC QtOCCViewerContext.h
MOC QtOCCViewWidget.h
MOC QtOCCInputOutput.h
Compiling...
QtOpenCascade.h
Compiling...
moc_mainwindow.cpp
moc_QtOCCViewerContext.cpp
moc_QtOCCViewWidget.cpp
moc_QtOCCInputOutput.cpp
mainwindow.cpp
main.cpp
QtOCCViewerContext.cpp
QtOCCViewWidget.cpp
QtOCCInputOutput.cpp
MakeBottle.cpp
Generating Code...
Compiling resources...
Linking...
Creating library release\QtOpenCascade.lib and object release\QtOpenCascade.exp
Embedding manifest...

Results

Build log was saved at "file://f:\Programowanie\projekty\qt_Visual_2005\QtOCC-0.6\release\BuildLog.htm"
QtOpenCascade - 0 error(s), 0 warning(s)

P Dolbey's picture

There was a problem that was discovered with the original code that you have downloaded (there are other versions hidden on my site with various fixes). But first I need to see if you have the same error. It was basically that the winId() (i.e. the win32 HWND) property of the QGLWidget hadn't been initialised before the initialize() method was called BUT I believe this only affected some graphics. I never had this problem on ATI Radeon.

The original fix for this was to inherit the QtOCCViewWidget directly from QWidget (not QGLWidget) - however this solution failed on Linux testing by Marc Britten.

However I now believe that by following the model for some of the standard Qt opengl code (which works on all cards pretty reliable), i.e. by correctly re-implementing the QGLWidget methods initializeGL() and paintGL() that a reliable solution is found. (I have an implementation in my latest viewer, but I need to build a mini-harnes for that).

So first, lets see if you problem is the same. I guess your using the nmake files to build your application. We need to debug this code, and the simplest way is to create a vcproj files. From a command prompt in you QtOCC project folder create a vcproj by typing

qmake -tp vc -spec win32-msvc2005 (the last parameter needed if you don't have a QMAKESPEC defined). This should create a QtOpenCascade.vcproj that you can load in VS2005 and compile (you'll get the option to create an sln file when you first compile).

If you stick a breakpoint on the line

int windowHandle = (int) winId();

in the QtOCCViewWidget::initialize(..) method and the windowHandle is set to zero when you step over this line then you have the problem. If that happens then post back here and let me.

You can then try an old win32 only compatible version with only QWidget inheritance from
http://myweb.tiscali.co.uk/dolbey/QtOpenCascade/QtOCC-0.3.zip

Then keep watching this thread, cos I'll put up a new version of the viewwer based on my current code (now renamed QoccViewWidget but I'll put that back for this demo). This uses the standard QGLWidget model for intialising (and adds my gradient background mentioned elsewhere). I hope this will fix your (and others) problem properly.

Pete

P Dolbey's picture

..and here is a first candidate. Its only been tested on my XP platform, and although I've started making a number of edits to core OpenCascade libraries, this code should still run OK without. Give it a try and let me know if there's any gotcha's.

Pete

Nearly forgot - here's the link http://myweb.tiscali.co.uk/dolbey/QtOpenCascade/QtOCC-0.7.zip

Pawel Dobrowolski's picture

Finally I managed to run your example.

The strange thing is that only version which works on my computer is QtOCC-0.3.
Other two give "Run Time error".

Thank you very much for help. Now I can start learning.

PS. I can't debug because I don't have path libd in OCC folder. I think I should recompile OCC on VC++ 2005 express to have debug libraries. I don't want do it now, because I don't want damage good configuration which I have now.

Is there any FAQ how can I run binaries of QtOCC programs on another Win XP machine?

I really appreciate your help.

Regards,
Pawel

Stefan Boeykens's picture

I have attempted to compile it, but get runtime errors.
------------
First-chance exception at 0x7c812a5b in QtOpenCascade.exe: Microsoft C++ exception: Aspect_GraphicDeviceDefinitionError at memory location 0x0012fbe4..
------------

I suspect that my OCC libraries might be a problem. I spent about a day compiling OCC 6.2 on VC2005, in debug mode. Haven't attempted the release libraries at the moment. I'm not linking against the precompiled libraries, since they are made for VC 2003.

I have had to remove the "all.vcproj" from all solutions and I didn't succeed in compiling "TKjcas.lib". I commented it out in the QtOCC example, suspecting that it wouldn't be needed.

It compiles and links, but I get the above runtime error.

---> Is there a guide somewhere helping to recompile OCC 6.2 with VC2005, so that I am at least sure that the problem is not with the OCC libraries?

---> I have installed Qt 4.2.2 and use it in other projects without problems. I have used qmake to generate a Visual Studio Project file which is working just fine.

----

FWIW, I never succeeded in running any of the previous QtOCC examples.

Stefan Boeykens's picture

The actual error occurs on:
--------
static Handle( Graphic3d_WNTGraphicDevice ) defaultdevice;
if( defaultdevice.IsNull() )
{
defaultdevice = new Graphic3d_WNTGraphicDevice();
}
--------
in QtOCCViewerContex.cpp (lines 77-81)

I never reach the place where int windowHandle = (int) winId(); is called.

P Dolbey's picture

Sorry to hear that your having problems with the code.

For a long time I've advocated re-compiling OpenCascade to be compatible with your compiler of choice, other wise you end up with a mish mash of run-time dependencies. OCC 6.2 compiles pretty cleanly with VS2005 using the instructions in the documentation - I did have a trick I used for OCC 6.1 issues described here http://www.opencascade.org/org/forum/thread_10904/. I also tend to ignore recompiling drawexe.exe as it removes the dependency on tcl/tk, although I have had it working with the ActiveState versions.

Assuming your interested in getting the code running on your platforms, there are a number of things we can do. But first I'd like to know some core things.

1) Do the standard MFC applications work (in debug mode).
2) Does the standard qt demo work.

The next important things relate to your environment variables - can you list them please.

There was a simple trick I used for VS2003 when I wanted to debug code. Basically I copied all the files from the bin to bind, and lib to libd. This avoided recompiling OCC or changing the sample project files. But for VS2005 I'd always recommend recompiling.

Pete

P Dolbey's picture

Just as a test I've downloaded the 0.7 onto my work machine, with Qt 4.2.1, OCC 6.1 and VS2003 and its worked fine. However this also has an ATI Radeon X300 just like my home machine. I've never been able to reproduce the problems other have had with this card. Can you tell me what cards your using?

A further test I'd be interested in hearing about relates to the standard Qt hellogl application on your platform. I'd love to know the value of the winId() (a.k.a.HWND) in the initializeGL() method of the QGLWidget.

Cheers, Pete

P Dolbey's picture

Another thing to try in the 0.7 version is patching out some of the window attribute calls in QtOCCViewWidget.cpp, i.e the lines that read

// Avoid Qt background clears to improve resizing speed,
// along with a couple of other attributes
//setAutoFillBackground( false );
//setAutoBufferSwap( false );
//setAttribute( Qt::WA_NoSystemBackground );
//setAttribute( Qt::WA_OpaquePaintEvent );
//setAttribute( Qt::WA_WState_Visible, false );
//setAttribute( Qt::WA_PaintOnScreen );

as rendering performance on my works machine seems fine with the following patches applied to OCC-

http://www.opencascade.org/org/forum/thread_11016/ (Jan's post of 2007-04-18)
http://www.opencascade.org/org/forum/thread_8291/

I've also discovered that whilst nmake work fine on VS2003, in order to get the linker to work in the IDE I had to change $(CASROOT) to the real directory in QtOpenCascadeWin32.pri. This environment variable works fine with VS2005.

Pete

P Dolbey's picture

I guess I'm getting kind of frustrated because I know there's a problem with the code, but I can't reproduce it or fix it. But I've been doing a lot with this viewer, and here's a screen shot of what should be possible.

http://myweb.tiscali.co.uk/dolbey/QtOpenCascade/images/QtOCC4.PNG

Now if someone could let me run a remote session on their machine...

Pete

Pawel Dobrowolski's picture

Pete,

I'm following your suggestions but there are many things to do.
You think that recompiling OCC on VS 2005 should be done.
So I'm preparing to do it but first I have to build TCL, TK, TIX and FLTK as mentioned in OCC manual.

I'm really green so any help will be appreciated in case of errors.

P Dolbey's picture

Unless you want the drawexe.exe, you don't need TCL, TK, TIX. I'd ignore these for now.
If you want grab the latest versions from www.activestate.com. A tip - if you want TIX (used in netgen as well) grab a copy of activepython 2.5 as well as activetcl, its the only place I've found a pre-cooked tix 8.4! In the case of FLTK (I assume Fast Light Tool Kit) I have never needed this to compile OCC.

If you're feeling courageous download this file.

http://myweb.tiscali.co.uk/dolbey/QtOpenCascade/OpenCASCADE.zip

It contains a single OpenCASCADE solution file with most of the inter-dependencies between the various modules sorted out. Bung it in your ..\ros\adm\win32 folder, load it up and it should upgrade all the projects as well (you might want to backup this folder first). Use the batch build options to create debug and release versions (I normally leave out drawexe and wok). You may need to run it a couple of times (nobody's perfect) and if you leave it alone for all but a few moments Intellisense goes bananas - but its what I use to perform recompiles.

Pete

Pawel Dobrowolski's picture

Pete,

I did us you suggested and I have following results:

I looked in solution files and compiled vcprojects in your OPenCASACADE solution file in sequence written in OCC manual.

Foundation Classes (file FoundationClasses.*)
Modeling Data (file ModelingData.*)
Modeling Algorithms (file ModelingAlgorithms.*)
Visualization (file Visualization.*)
Application Framework (file ApplicationFramework.*)

compiled successfully. No errors, many warnings.

Data Exchange (file DataExchange.*)

compiled successfully except:
TKXDEIGES (don't see TKIGES.lib file)
TKIGES (don't see TKTopTest.lib file)
TKTopTest (don't see TKDraw.lib file)
TKDraw (don't see tcl.h file)

So it seems that I need to install tcl first.

You said that you omit compilation for draw.exe.
Does it mean that I shouldn't compile? :

Draw (file Draw.*)
WOK (file WOK.*)
Wrappers (file Wrappers.*)

When I manage to compile the rest in debug mode (so far I compile every library in debug mode), should I compile once again in release mode?
Maybe copying files from bind to bin and from libd to lib will be enough?
Is there any difference between libs compiled in debug mode and these compiled in release mode?

Regards,
Pawel

Pawel Dobrowolski's picture

Pete,

I did us you suggested and I have following results:

I looked in solution files and compiled vcprojects in your OPenCASACADE solution file in sequence written in OCC manual.

Foundation Classes (file FoundationClasses.*)
Modeling Data (file ModelingData.*)
Modeling Algorithms (file ModelingAlgorithms.*)
Visualization (file Visualization.*)
Application Framework (file ApplicationFramework.*)

compiled successfully. No errors, many warnings.

Data Exchange (file DataExchange.*)

compiled successfully except:
TKXDEIGES (don't see TKIGES.lib file)
TKIGES (don't see TKTopTest.lib file)
TKTopTest (don't see TKDraw.lib file)
TKDraw (don't see tcl.h file)

So it seems that I need to install tcl first.

You said that you omit compilation for draw.exe.
Does it mean that I shouldn't compile? :

Draw (file Draw.*)
WOK (file WOK.*)
Wrappers (file Wrappers.*)

When I manage to compile the rest in debug mode (so far I compile every library in debug mode), should I compile once again in release mode?
Maybe copying files from bind to bin and from libd to lib will be enough?
Is there any difference between libs compiled in debug mode and these compiled in release mode?

Regards,
Pawel

Stefan Boeykens's picture

It's getting difficult. I've succeeded in recompiling most of OpenCASCADE in debug mode, using the provided solution files (and ignoring tons of warnings).
I can even launch the drawexe application, albeit not totally stable.
Not everything compiles and Visual Studio is getting really unstable with so many projects underneath a single solution.

I have tried to compile the MFC examples (common and mfcsample displayed many errors: "for(int i...)" followed by "for(i;...)" gave problems, so I inserted the second "int".

When it finally compiles and I launch it (using the "$CASROOOT\win32\bind" folder for execution, to find all DLLs), it fails on "Aspect_GraphicDeviceDefinitionError". I think that is the same problem as I had with the QtOCC example. So that seems to be the real problem.

Stefan Boeykens's picture

FWIW, the 2D MFC samples seem to work. The Topology example fails on the same error.
I have an nVidia Quadro FX1400, using two screens. Single screen doesn't solve the problem.

Why is it so difficult to recompile OpenCASCADE in VC2005? Was it never tested on this platform?

Stefan Boeykens's picture

I suspect problems with mixing debug and release libraries... The DLL load mechanism seems to load the TKOpenGL.dll at runtime and finds it in the release folder, instead of the debug folder!

Copying all DLLs in the bin folder (from the bind folder) seems to get me at least a step further. Still no answer to the actual QtOCC library, I'm afraid...

Stefan Boeykens's picture

I can get a bit further. I receive a windowHandle in QtOCCViewWidget, but it crashes at:
"myView->SetWindow( myWindow, rc , paintCallBack, this );"

The actual problem is deeper: in "visual3d_view.cxx", in the ::SetWindow method, the MyCView is initialized with a nullpointer called ptrView. It raises an exception at line 443: "if (! MyGraphicDriver->View (MyCView))
Visual3d_ViewDefinitionError::Raise ("Association failed");"

P Dolbey's picture

Stefan

First try this

myView->SetWindow( myWindow, 0 , paintCallBack, this );

(thats a zero). This will force OpenCascade to create it own rendering context instead of using the QGLWidget's version.

If that's not looking good, replace with just the old-fashioned

myView->SetWindow( myWindow );

which will disable the gradient background callback.

For the the issue with the int i variables, the technique I adopted in http://www.opencascade.org/org/forum/thread_10904/ worked with OCC 6.1, but you will need to recover all your VC7.1 vcproj files after this change has been made. OCC 6.2 was supposed to be entirely VS2005 compliant, but I still have the conformance flag set so maybe I wouldn't have noticed if it wasn't.

Good luck and thanks for trying.

Pete

P Dolbey's picture

It would be great if you could single step through the call to MyGraphicDriver->View(MyCView). Hope you followed Jan's note re-environment variables.

Pete

Stefan Boeykens's picture

Dolbey wrote: "myView->SetWindow(...)"
None of the different calls makes a difference.

Dolbey wrote: "It would be great if you could single step through the call to MyGraphicDriver->View(MyCView)."

ACView contains: WsId=3, ViewId=3, ptrView=0x00000000 and further on mostly 0 (false, I assume). It returns "result == 0 --> Standard_False". And then the exception is raised.

P Dolbey's picture

Another thought. OpenCascade writes a lot of debug message to the ths console, which isn't there if you just run the app. If you add a "CONFIG += console" to the .pro file and remake with qmake, the application will also launch a cmd console. It might reveal some interesting OC debug printf's and cout's.

Pete

P Dolbey's picture

You said

"The actual problem is deeper: in "visual3d_view.cxx", in the ::SetWindow method, the MyCView is initialized with a nullpointer called ptrView."

Where exactly is this line.

Pete

Stefan Boeykens's picture

I said: "The actual problem is deeper: in visual3d_view.cxx, in the ::SetWindow method, the MyCView is initialized with a nullpointer called ptrView."
P Dolbey said: "Where exactly is this line."

lines 443: if (! MyGraphicDriver->View (MyCView))
Visual3d_ViewDefinitionError::Raise ("Association failed");

So step by step:

----------------------------------------------------
QtOCCViewWidget.cpp, line 132: QtOccViewWidget::initializeOCC(... aContext)
----------------------------------------------------
...
int windowHandle = (int) winId(); --> 0x0003085a
...
rc = wglGetCurrentContext(); --> 0x00010001
myWindow = new WNT_Window(...); --> this has an entity
sizes are known (0,21,1600,1095)
myHPixmap = 0x00000000
AspectWindow
MyGraphicDevice
WNT_GraphicDevice, MyGraphicDriver and MySharedLibrary
...
line 160: myView->SetWindow(myWindow); // I changed this as you suggested

----------------------------------------------------
v3d_view.cxx, line 479: V3d_View::SetWindow(...)
----------------------------------------------------
...
MyView->SetWindow(TheWindow);

----------------------------------------------------
visual3d_view.cxx, line 397: Visual3d_View::SetWindow(... AWindow)
----------------------------------------------------
...

MyCView is currently as follows (after UpdateView on line 442):
WsId = 3
ViewId = 3
ptrView = 0x00000000
Most settings are 0
Most pointers are 0x000000000 (ptrUnderlayer, GContext, GDisplayCB, GClientData)
Orientation and mapping seem OK.
DefWindow:
ext_data = 0x00000000
Title = 0x000000000
Icon = 0x00000000
Rest seems Ok (XWindow, XParentWindow, dx, dy... all not null)
...
if(! MyGraphicDriver->View(MyCView))
Visual3d_ViewDefinitionError::Raise ("Association failed");

--------------------------------------
opengl_graphicdriver_7.cxx line 391: OpenGl_GraphicDriver::View (...)
--------------------------------------
...
Result = call_togl_view(&MyCView);

--------------------------------------
opengl_togl_view.c line 44: int EXPORT call_togl_view(...)
--------------------------------------
...
call_subr_open_ws(aview) returns false and we return.

---------------------------------------
opengl_subrvis.c, line 203: int call_subr_open_ws()
---------------------------------------
...
line 234: aview->GContext --> 0,
win = TxglCreateWindow(...) --> win = 0x00000000

---------------------------------------
opengl_txgl.c line 169: Windo TxglCreateWindow(...)
----------------------------------------
... I receive a pixel format (7) on line 445
But line 483 is the problem:
SetPixelFormat(hte->hDC, iPixelFormat, &pfd) returns false.

And then I'm thrown out of the party...

P Dolbey's picture

Hi Stefan,

If you followed my previous tip about adding a "console" out, the line on 485

printf ("*OpenGL interface: SetPixelFormat failed. Error code %d\n",GetLastError ());

could be emitting the error code for GetLastError - this value might be significant. Have you tried changing your graphics settings, especially the color depth. I've found some sites that indicate that you need to ensure you've got 32 not 16 bit color. It might be worth drop screen resolutions to see if that helps.

Can you re-check that the standard Qt opengl samples run correctly. The reason I emphasise this is that if you use the original "myView->SetWindow( myWindow, rc , paintCallBack, this );", the SetPixelFormat line doesn't seem to be called in OCC, as the pixel format has been set by the QGLWidget. So if standard Qt opengl works, why OCC doesn't?

Your doing a great job here, thanks. It may be better to open a private mail channel instead of staring to create noise on the forum. I can be found at "peter at dolbey dot freeserve dot co dot uk" (with the usual replacements).

Pete

Jan Brüninghaus's picture

> The DLL load mechanism seems to load the TKOpenGL.dll at runtime and finds it in the
> release folder, instead of the debug folder!

That behavour is caused by the environment variable CSF_GraphicShr, wich holds a hard reference to the release TKOpenGl.dll after OCC installation by default.