Open Inventor consists of a portable core component and various window system-specific components:
Qt is a cross-platform C++ GUI application framework from Trolltech AS. See www.trolltech.com for more information.
Open Inventor was designed to be portable and window system independent. Like OpenGL it uses a large core of system-independent classes and a small set of window system-specific classes. The SoXt classes are specific to the X Windows/ Xt/ Motif environment (Unix/Linux). The SoWin classes are specific to the Microsoft Windows environment. The SoQt classes are specific to the Qt environment, but Qt is itself window system independent. So the combination of the Open Inventor core, SoQt classes, and Qt allows a single application source code to build and run on many different platforms, including both Unix/Linux and Microsoft Windows.
There is a close correspondence between the SoXt, the SoWin, and the SoQt classes. Thus, it is very easy to port an SoXt or an SoWin Inventor program to a portable SoQt program.
As usual, it is easier to begin with a simple example. Here is a simple Open Inventor program from Hello Cone Using the Examiner Viewer. This program has been translated into Qt by simply replacing the SoXt calls with SoQt calls.
This program works essentially the same as it would with SoXt and SoWin. Calling SoQt::init with a string creates a QApplication and its main window, and returns its window handle. The viewer’s window is created as a child of the main window. The “ show ” call makes the various windows visible and the SoQt::mainLoop provides the Qt event loop.
Example : Hello Cone using SoQt classes
C++ :
The SoQt class initializes Inventor for use with all supported systems. All of its methods are static convenience functions. Every SoQt class includes all the methods of its corresponding SoWin and SoXt class. Generally these methods have the same or similar behavior. In a few cases the data types have been changed for the Qt environment. In particular:
SoWin | SoXt | SoQt |
---|---|---|
HWND | Window and Widget | QWidget * |
MSG | XEvent | QEvent |
SoQtComponent is the abstract base class for all Open Inventor components. Some of the functions were already defined in the QWidget class but are still defined for compatibility reasons, like show(), hide(), isVisible(), setFullScreen(), or setTitle(). Others are typical Open Inventor component functions like getWidget(), getWidgetName(), getClassName(), etc. The getDisplay() method is for use on Unix only.
Help files are handled differently on Windows and Unix/Linux. On Windows,SoQt opens a CHM help file (VC++ 6.0) or a Help 2.0 file
(VC++ 7.1 and newer). On Unix/Linux, it opens the HTML help documentation.
SoQtGLWidget is the generic component for OpenGL rendering. SoQtGLWidget uses QGLWidget from Qt.
Windows | Unix | Qt |
---|---|---|
HGLRC | GLXContext | QGLContext |
PIXELFORMATDESCRIPTOR | XVisualInfo | QGLFormat |
This part describes how to implement a Qt application using SoQt classes. Good examples to look at to understand this part are the QtLargeModelViewer or the QtTreeView examples (located in $OIVHOME/src/Inventor/examples/Qt).
C++ :
+ Both functions will call **SoDB::init()**, **SoNodeKit::init()**, and **SoInteraction::init()**. + The first method assumes you’ve created the **QApplication** and the **mainWidget** and receives a handle to this **mainWidget** as an argument. + The second method receives the name of the application which will be used to set the title of the **mainWindow** as the first argument and the name of the class as the second argument. It creates the **QApplication** and the **mainWidget** and returns a handle to this **mainWidget**. The **QApplication** object is accessible through the global pointer qApp.
Open Inventor for Qt has been adapted to the Qt user interface guidelines, but at the same time preserves the system-independent “look and feel” of the viewer and editor components. Notice that the distinctive Open Inventor thumb wheel is preserved and the viewer toolbar uses the same button bitmaps as on SoWin and SoXt.
,_material_editor,_material_palette,_and_color_editor
Open Inventor provides a plugin for Qt Designer. This plugin extends the set of available widgets in Qt Designer so that an Open Inventor 3D viewer can easily be integrated into the application’s user interface.
The directory $OIVHOME/OpenInventor/OIV/src/Inventor/examples/Qt/Plugin contains the files necessary to build Qt Designer plugin library, including project and source files:
On Unix or Linux, you must build the plugin library yourself, using the supplied makefile. The makefile will copy the library into the designer plugin directory (for example, /plugins/designer).
When the Qt Designer program starts, it loads all the plugin libraries in the Qt plugin directory (e.g., $QTDIR/plugins/designer).
The SoQtWidgetPlugin library will add a new group (Open Inventor) in the toolbox bar and a new item in this group: SoQtWrapper (it must have the same name as the class of the object created).
The tooltip text will be: “Open Inventor Viewer Widget”. And the “What’s this” text will be: “A widget to visualize 3D graphics with Open Inventor”. See Qt Designer Plugin (tooltip and “What’s this” text) below.
This plugin will create a Qt form widget that contains, by default, an SoQtExaminerViewer object. These objects will be saved in a “.ui” XML Qt Designer file.
You can replace the Examiner Viewer with a render area or another Inventor viewer in the .cpp file that is generated by the project that loads this “.ui” file. See the Reference Manual for more information on SoQtWrapper.