This is an example of a shape viewer application wholly based on Qt4 (4.3.1) that provides a simple rendering environment for OpenCASCADE's built-in rendering contexts. At present it provides a basic viewer for BREP, STEP and IGES files, but it is hoped to extend into an application that builds or edits geometries.

Thanks to help from Marc Britten, the Qt4 project will compile and run on both Windows (Visual Studio 2005, XP) and Linux (Ubuntu 6.10 Edgy) platforms.

Qt4 Design

I've only starting playing with Trolltech's Qt GUI builder very recently, exploiting its open source Windows edition and the Qt/Win project's patches to run under Microsoft Visual Studio 2005. But this means I have jumped straight in onto version Qt4, and all the OCC examples are written for Qt3.

I'm starting to get into the slots and signals methods of Qt4, and they provide the potential for a much better rendering/GUI framework that those presented with OCC. Basically it should be possible to just let the rendering engine raise events to be consumed by slots connected to other objects in the application level objects, and not try to handle everything itself.

Also Qt4 provides a "command pattern" model via the QUndoCommand class - many of the current OCC examples seem very weak in their command handling architecture and application class designs.

QtOpenCascade Demo

The current viewer is basically a joining of the Qt4 menu's example with a updated OCC renderer that doesn't require any Qt3 support classes. Its been deliberately developed as an Single Document Interface model. It doesn't use any fancy ui files, toolbars or anything else - these will be added in a later version. Their are 4 menus, but functionality is only contained in the File and View menus. You can load files, clear the model (with File->New) perform all the usual scales, pans, and rotations by holding down the Ctlr key and selecting L,M,R mouses button. Window zooms etc., are available from the View->Actions menu, Display characteristic from the View->Display and some grid behaviours can be changed from the View->Grid menu. The "load bottle" is still available in this version.

From a developer's point of view, the aim is to provide a readable set of classes that ease, rather than hinder, development of application specific code - but this is yet to be proven.

Windows Version Linux Version


The source code is available as a Qt4 project here. This version has my code for gradient backgrounds, and an improved intialisation process. I'm not going to tell you how to set up your environment paths etc. - I assume you have already working systems for Qt4 and OCC. The project uses the CASROOT and QTDIR environment variables to locate include files and libraries on your system - these are assumed to be in default relative locations e.g. include files in $(CASROOT)\lib. To build the apps in debug and release just cd into the folder from a cmd prompt, set up your compiler and Qt environment variables then type: -

make / nmake ( for Linux / Windows)

and it should build! On Windows, you can also spool out .vcproj files using "qmake -tp vc" using Qt/Win - these should adapt to your own environment, but with Visual Studio 2003, you may find that the IDE corrupts the linker command line. You can fix this by replacing $(CASROOT) references in QtOpenCascadeWin32.pri file with your actual OCC installation directory. This is not needed for Visual Studio 2005.

The Doxygen documentation can be viewed on-line here


These are some of the useful links I have been referencing.


Marc Britten for the Linux porting - again many thanks for your help.

This could not have been developed without the fantastic work carried out by both OpenCASCADE SA and TrollTech ASA in their support of the Open Source Initiative.

(c) Peter Dolbey 2007 This page last edited 18 September 2007