|
http://www.sim.no http://www.coin3d.org |
#include <Inventor/Win/SoWin.h>
This is the "application-wide" class with solely static methods handling initialization and event processing tasks. You must use this class in any application built on top of the SoWin library.
Typical usage is as follows (complete application code):
#include <Inventor/Win/SoWin.h> #include <Inventor/Win/viewers/SoWinExaminerViewer.h> #include <Inventor/nodes/SoBaseColor.h> #include <Inventor/nodes/SoCone.h> #include <Inventor/nodes/SoSeparator.h> int main(int argc, char ** argv) { // Initialize SoWin and Inventor API libraries. This returns a main // window to use. HWND mainwin = SoWin::init(argc, argv, argv[0]); // Make a dead simple scene graph, only containing a single // yellow cone under the scenegraph root. SoSeparator * root = new SoSeparator; root->ref(); SoBaseColor * col = new SoBaseColor; col->rgb = SbColor(1, 1, 0); root->addChild(col); root->addChild(new SoCone); // Use one of the convenient viewer classes. SoWinExaminerViewer * eviewer = new SoWinExaminerViewer(mainwin); eviewer->setSceneGraph(root); eviewer->show(); // Pop up the main window. SoWin::show(mainwin); // Loop until exit. SoWin::mainLoop(); // Clean up resources. delete eviewer; root->unref(); return 0; }
And voila:
Public Types | |
| typedef void | FatalErrorCB (const SbString errmsg, SoWin::FatalErrors errcode, void *userdata) |
| UNSPECIFIED_ERROR = 0 | |
| NO_OPENGL_CANVAS | |
| INTERNAL_ASSERT | |
| DLL | |
| LIB | |
| UNKNOWN | |
| enum | FatalErrors { UNSPECIFIED_ERROR = 0, NO_OPENGL_CANVAS, INTERNAL_ASSERT } |
| enum | ABIType { DLL, LIB, UNKNOWN } |
Static Public Member Functions | |
| static HWND | init (const char *appname, const char *classname="SoWin") |
| static HWND | init (int &argc, char **argv, const char *appname, const char *classname="SoWin") |
| static void | init (HWND toplevelwidget) |
| static void | mainLoop (void) |
| static void | exitMainLoop (void) |
| static void | done (void) |
| static HWND | getTopLevelWidget (void) |
| static HWND | getShellWidget (const HWND w) |
| static void | show (HWND const widget) |
| static void | hide (HWND const widget) |
| static void | setWidgetSize (HWND const widget, const SbVec2s size) |
| static SbVec2s | getWidgetSize (const HWND widget) |
| static void | createSimpleErrorDialog (HWND widget, const char *title, const char *string1, const char *string2=NULL) |
| static void | getVersionInfo (int *major=NULL, int *minor=NULL, int *micro=NULL) |
| static const char * | getVersionString (void) |
| static const char * | getVersionToolkitString (void) |
| static FatalErrorCB * | setFatalErrorHandler (SoWin::FatalErrorCB *cb, void *userdata) |
| static SbBool | isDebugLibrary (void) |
| static SbBool | isCompatible (unsigned int major, unsigned int minor) |
| static ABIType | getABIType (void) |
Friends | |
| class | SoGuiP |
| class | SoWinP |
| void SoWin::FatalErrorCB |
An application function callback for handling fatal errors should be of this type.
The first argument is an error message in English describing the details of the error. The second argument is an error code used so the application can identify specific conditions. The third argument is the userdata pointer passed in to SoWin::setFatalErrorHandler().
| enum SoWin::FatalErrors |
Numerical identifiers for classifying the different kinds of possible fatal errors.
| UNSPECIFIED_ERROR | Signifies that we were not able to specify in any greater detail the error condition that came up. |
| NO_OPENGL_CANVAS | Could not construct any valid OpenGL canvas. Something is very wrong on the client system. |
| INTERNAL_ASSERT | An internal error condition that should never happen was detected. The most likely cause of this is programmering errors within the SoWin library itself. |
| enum SoWin::ABIType |
| HWND SoWin::init | ( | const char * | appname, | |
| const char * | classname = "SoWin" | |||
| ) | [static] |
This function initializes the SoWin library, as well as the Inventor API. The latter is done by calling SoDB::init(), SoNodeKit::init() and SoInteraction::init().
The returned HWND is a toplevel shell widget for the application, which can be used as a shell for the main component.
This method is provided for easier porting / compatibility with the original SGI Inventor InventorXt library. It just adds dummy argc and argv arguments and calls the SoWin::init() method below.
| HWND SoWin::init | ( | int & | argc, | |
| char ** | argv, | |||
| const char * | appname, | |||
| const char * | classname = "SoWin" | |||
| ) | [static] |
This function initializes the SoWin library, as well as the Inventor API. The latter is done by calling SoDB::init(), SoNodeKit::init() and SoInteraction::init().
Creates an application framework and constructs and returns a main widget for you.
The returned HWND is a toplevel shell widget for the application, which can be used as a shell for the main component.
| void SoWin::init | ( | HWND | toplevelwidget | ) | [static] |
This function initializes the SoWin library, as well as the Inventor API. The latter is done by calling SoDB::init(), SoNodeKit::init() and SoInteraction::init().
Assumes you are creating your own application framework and main widget. toplevelwidget should be your application's main widget.
| void SoWin::mainLoop | ( | void | ) | [static] |
This is the event dispatch loop.
It doesn't return until application exit is somehow forced, either programmatically from the relevant API-call of the native toolkit, or when the user closes the application's main widget.
An important note: be careful about how you handle SoWinComponent-derived objects after the application control returns from mainLoop(), as SoWin will then have been "cleaned up" with regards to various internal resources. So doing for instance something like this:
SoWin::mainLoop(); viewer->hide();
..spells "undefined behavior, expect a crash".
Deleting a component after mainLoop() returns is allowed, though, and also necessary to avoid getting reports of possible memory leaks from memleak checkers.
| void SoWin::exitMainLoop | ( | void | ) | [static] |
This function will make the main event loop finish looping.
NOTE: exitMainLoop() is not present in the original API for SGI's InventorXt library.
| void SoWin::done | ( | void | ) | [static] |
Cleans up all static data allocated by the SoWin library on initialization.
It should never be invoked more than once, and that is just before application exit, as it deallocates static data allocated as "one-off" operations in SoWin::init().
NOTE: done() is not present in the original API for SGI's InventorXt library.
| HWND SoWin::getTopLevelWidget | ( | void | ) | [static] |
Returns the HWND which is the main widget for the application. When this widget gets closed, SoWin::mainLoop() will return (unless the close event is caught by the user).
| HWND SoWin::getShellWidget | ( | const HWND | w | ) | [static] |
Returns a pointer to the HWND which is the top level widget for the given HWND hwnd.
| void SoWin::show | ( | HWND const | widget | ) | [static] |
This method is provided for easier porting/compatibility with the Open Inventor SoXt component classes. It will call ShowWindow() with the argument SW_SHOW on the provided widget window handle.
| void SoWin::hide | ( | HWND const | widget | ) | [static] |
This method is provided for easier porting/compatibility with the Open Inventor SoXt component classes. It will call ShowWindow() with the argument SW_HIDE on the provided widget window handle.
| void SoWin::setWidgetSize | ( | HWND const | widget, | |
| const SbVec2s | size | |||
| ) | [static] |
This method is provided for easier porting of applications based on the Open Inventor SoXt component classes. It will call SetWindowPos() on the provided widget window handle.
| SbVec2s SoWin::getWidgetSize | ( | const HWND | widget | ) | [static] |
This method is provided for easier porting/compatibility with the Open Inventor SoXt component classes. It will call GetWindowExtEx() on the provided widget window handle's device context (returning an SbVec2s).
| void SoWin::createSimpleErrorDialog | ( | HWND | widget, | |
| const char * | title, | |||
| const char * | string1, | |||
| const char * | string2 = NULL | |||
| ) | [static] |
This is a convenient way for the application programmer to throw up an obtrusive application-global error dialog.
If widget is NULL, the dialog will be modal for the whole application (all windows will be blocked for input). If not, only the window for the given widget will be blocked.
title is the title of the dialog box. string1 and string2 contains the text which will be shown in the dialog box.
There will only be a single "Ok" button for the user to press and continue with the application.
| void SoWin::getVersionInfo | ( | int * | major = NULL, |
|
| int * | minor = NULL, |
|||
| int * | micro = NULL | |||
| ) | [static] |
This method will fill in the integers pointed to by the arguments with the corresponding part of the version release number of the SoWin library.
A NULL pointer will make that part of the version number be ignored.
This method is not part of the original InventorXt API from SGI.
| const char * SoWin::getVersionString | ( | void | ) | [static] |
This method returns a string containing the version id of the library.
This method is not part of the original InventorXt API from SGI.
| const char * SoWin::getVersionToolkitString | ( | void | ) | [static] |
This method returns a string containing the version id of the Win toolkit the SoWin library is linked against.
This method is not part of the original InventorXt API from SGI.
| SoWin::FatalErrorCB * SoWin::setFatalErrorHandler | ( | SoWin::FatalErrorCB * | cb, | |
| void * | userdata | |||
| ) | [static] |
Set up a callback to invoke in the case of unexpected fatal error conditions within the SoWin library.
Almost any error condition within the library is handled in a robust way through return values indicating errors for the offending calls, but there are a few cases that are impossible to handle without seriously crippling the functionality.
(One example is if we fail to find any way of making a valid OpenGL canvas. This is an indication that something is seriously wrong on the end-user's system, and the SoWin library will not work properly.)
In the case of a fatal error, it is expected that the given application callback function communicates the problem to the end-user and then either exits the application or at least refrains from using any part of the SoWin library.
If no callback is explicitly set up by the application, the SoWin library will display an error message to the end-user and then exit the application.
When setting a callback, this method returns a pointer to the previous callback function, or NULL if none.
(This is an extension versus the original SGI InventorXt library API.)
On a related note, be aware that the end-user will still be notified about non-fatal errors and warning messages through a dialog box. If you want to handle these yourself, or if you don't want your end-user to see any of these non-critical messages, you will also need to install an error handler callback function on the Coin library itself:
SoDebugError::setHandlerCallback(myErrorHandlerCB, myCBUserData);
(Please also see the documentation of SoDebugError::setHandlerCallback().)
| SbBool SoWin::isDebugLibrary | ( | void | ) | [static] |
Returns TRUE if this binary version of the SoWin library was compiled with debug settings on.
This method was not part of the original SGI InventorXt library, but is an extension specific to the Coin project.
| SbBool SoWin::isCompatible | ( | unsigned int | major, | |
| unsigned int | minor | |||
| ) | [static] |
Returns TRUE if this version of the SoWin library has an Application Binary Interface compatible with the given version.
This method was not part of the original SGI InventorXt library, but is an extension specific to the Coin project.
| SoWin::ABIType SoWin::getABIType | ( | void | ) | [static] |
Returns an indication on how the library was compiled: as a dynamic library, or as a static library.
This method was not part of the original SGI InventorXt library, but is an extension specific to the Coin project.
Copyright © 1998-2005 by Systems in Motion AS. All rights reserved.
Generated on Tue Oct 7 21:13:44 2008 for SoWin by Doxygen. 1.4.7