Open Inventor Release 2024.1.1
 
Loading...
Searching...
No Matches
SoXt Class Reference

Routines for Open Inventor/Xt compatibility. More...

#include <Inventor/Xt/SoXt.h>

Static Public Member Functions

static SoWidget init (const char *appName, const char *className="Inventor")
 This is called to initialize Open Inventor and Xt, and bind Open Inventor with X events handling so that Open Inventor sensors will work correctly.
 
static void init (SoWidget topLevelWidget)
 This alternate form of init allows the application to initialize Xt.
 
static bool isInitialized ()
 Returns TRUE if SoXt module is currently initialized.
 
static void finish ()
 Frees Open Inventor's internal static memory allocations.
 
static int mainLoop ()
 Enters the main event loop and waits until exit() is called.
 
static void exit (int returnCode=0)
 Tells the main event loop to exit with a return code.
 
static void nextEvent (XtAppContext appContext, XEvent *event)
 Gets the nextEvent by calling XtAppNextEvent().
 
static Boolean dispatchEvent (XEvent *event)
 Dispatches the passed event to a handler.
 
static XtAppContext getAppContext ()
 This method is included for portability only.
 
static Display * getDisplay ()
 This method is included for portability only.
 
static SoWidget getTopLevelWidget ()
 Returns information based on the initial widget returned by or passed to init.
 
static void show (SoWidget widget)
 Convenience routine to show the passed widget.
 
static void hide (SoWidget widget)
 Convenience routine to hide the passed widget.
 
static XmString encodeString (char *s)
 Convenience routine for encoding a character string as an XmString .
 
static char * decodeString (XmString xs)
 Convenience routine for decoding an XmString back to a character string.
 
static void setWidgetSize (SoWidget w, const SbVec2s &size)
 Convenience routine to set the size of the given window.
 
static SbVec2s getWidgetSize (SoWidget w)
 Convenience routine to get the size of the given window.
 
static SoWidget getShellWidget (SoWidget w)
 Convenience routine which will return the topmost window containing the given widget.
 
static void createSimpleErrorDialog (SoWidget widget, char *dialogTitle, char *errorStr1, char *errorStr2=NULL)
 Convenience routine which brings a simple Xt error dialog box displaying the given error string(s) and window title.
 
static void getPopupArgs (Display *d, int scr, ArgList args, int *n)
 Convenience routine which gets visual args for the popup planes.
 
static void registerColormapLoad (SoWidget widget, SoWidget shell)
 Convenience routine which will register map/unmap callbacks to load and unload the pulldown menu color map right before the menu is about to be posted.
 
static void addColormapToShell (SoWidget widget, SoWidget shell)
 Convenience routine to insert the given widget colormap onto the supplied shell widget.
 
static void removeColormapFromShell (SoWidget widget, SoWidget shell)
 Convenience routine to remove the given widget colormap from the supplied shell widget.
 
Deprecated
static SoDEPRECATED SoWidget threadInit (const char *appName, const char *className="Inventor")
 
static SoDEPRECATED void threadInit (SoWidget topLevelWidget)
 

Detailed Description

Routines for Open Inventor/Xt compatibility.

The SoXt class initializes Open Inventor for use with the Xt toolkit and Motif. SoXt::init() must be called in order for Open Inventor to work properly with Xt SoXt::finish() should be called to clean up static memory allocations.

SoXt::mainLoop() must be called in order for extension device events to be passed to Open Inventor render areas. The other methods are convenience functions.

Refer to the SoXtComponent reference pages for examples on how this class should be used when using Open Inventor Xt components.

SEE ALSO

SoXtComponent

Definition at line 99 of file SoXt.h.

Member Function Documentation

◆ addColormapToShell()

static void SoXt::addColormapToShell ( SoWidget  widget,
SoWidget  shell 
)
static

Convenience routine to insert the given widget colormap onto the supplied shell widget.

This will not replace the existing installed colormaps (or list of windows), but instead insert the new colormap first into the existing list using XGetWMColormapWindows () and XSetWMColormapWindows ().

◆ createSimpleErrorDialog()

static void SoXt::createSimpleErrorDialog ( SoWidget  widget,
char *  dialogTitle,
char *  errorStr1,
char *  errorStr2 = NULL 
)
static

Convenience routine which brings a simple Xt error dialog box displaying the given error string(s) and window title.

The OK button, which destroys the dialog, is the only button displayed.

◆ decodeString()

static char * SoXt::decodeString ( XmString  xs)
static

Convenience routine for decoding an XmString back to a character string.

encodeString() is used for encoding a character string as an XmString . ( XmString is a Motif string). The application is responsible for freeing up the memory pointed to by the return value. Use free () to free a character pointer.

◆ dispatchEvent()

static Boolean SoXt::dispatchEvent ( XEvent event)
static

Dispatches the passed event to a handler.

This returns TRUE if a handler was found, else it returns FALSE.

◆ encodeString()

static XmString SoXt::encodeString ( char *  s)
static

Convenience routine for encoding a character string as an XmString .

decodeString() is used for decoding an XmString back to a character string. ( XmString is a Motif string). The application is responsible for freeing up the memory pointed to by the return value. Use XmStringFree () to free an XmString .

◆ exit()

static void SoXt::exit ( int  returnCode = 0)
static

Tells the main event loop to exit with a return code.

After this function has been called, the mainLoop() function returns returnCode. If the event loop is not running, this function does nothing.

By convention, a returnCode of 0 means success, and any non-zero value indicates an error.

◆ finish()

static void SoXt::finish ( )
static

Frees Open Inventor's internal static memory allocations.

This avoids false positives from memory leak checking software. We recommend calling this method and it should be the last Open Inventor method called by the application. This method calls SoDB::finish(), SoNodeKit::finish(), and SoInteraction::finish().

Note: Open Inventor objects should be destroyed before you call this method.

For example:

Wrong Open Inventor Ending Safe Open Inventor Endings

void main() {
SoWidget myW = SoXt::init("");
SoXtExaminerViewer viewer(myW);
....
....
}
Viewer component which uses a virtual trackball to view the data.
static int mainLoop()
Enters the main event loop and waits until exit() is called.
static void finish()
Frees Open Inventor's internal static memory allocations.
static SoWidget init(const char *appName, const char *className="Inventor")
This is called to initialize Open Inventor and Xt, and bind Open Inventor with X events handling so t...

void runApp() {
SoXtExaminerViewer viewer(myW);
....
....
}
void main () {
SoWidget myW = SoXt::init("");
runApp();
SoXt::finish();
}

void main () {
SoWidget myW = SoXt::init("");
= new SoXtExaminerViewer(myW);
....
....
delete viewer;
}

SoXt doesn't end properly: SoXtExaminerViewer is destroyed after the finish() method has been called. The SoXtExaminerViewer (that uses OpenInventor) is destroyed before calling the finish() method.

◆ getAppContext()

static XtAppContext SoXt::getAppContext ( )
static

This method is included for portability only.

◆ getDisplay()

static Display * SoXt::getDisplay ( )
static

This method is included for portability only.

◆ getPopupArgs()

static void SoXt::getPopupArgs ( Display *  d,
int  scr,
ArgList  args,
int *  n 
)
static

Convenience routine which gets visual args for the popup planes.

These args can then be passed in to XmCreatePulldownMenu () or XmCreatePopupMenu () to create menus in the popup planes. addColormapToShell() has to be called on the main popup window to set the proper color map.

◆ getShellWidget()

static SoWidget SoXt::getShellWidget ( SoWidget  w)
static

Convenience routine which will return the topmost window containing the given widget.

The widget tree is traversed up until the last widget is found using GetParent .

◆ getTopLevelWidget()

static SoWidget SoXt::getTopLevelWidget ( )
static

Returns information based on the initial widget returned by or passed to init.

◆ getWidgetSize()

static SbVec2s SoXt::getWidgetSize ( SoWidget  w)
static

Convenience routine to get the size of the given window.

◆ hide()

static void SoXt::hide ( SoWidget  widget)
static

Convenience routine to hide the passed widget.

This includes any children the window may have.

◆ init() [1/2]

static SoWidget SoXt::init ( const char *  appName,
const char *  className = "Inventor" 
)
static

This is called to initialize Open Inventor and Xt, and bind Open Inventor with X events handling so that Open Inventor sensors will work correctly.

This returns the top level shell widget. This method calls SoDB::init(), SoNodeKit::init(), and SoInteraction::init() and creates an initial window.

◆ init() [2/2]

static void SoXt::init ( SoWidget  topLevelWidget)
static

This alternate form of init allows the application to initialize Xt.

The passed widget should be the top level widget returned from the Xt initialization. This method will call SoDB::init(), SoNodeKit::init(), and SoInteraction::init().

◆ isInitialized()

static bool SoXt::isInitialized ( )
static

Returns TRUE if SoXt module is currently initialized.

◆ mainLoop()

static int SoXt::mainLoop ( )
static

Enters the main event loop and waits until exit() is called.

Returns the value that was passed to exit().

It calls nextEvent() and dispatchEvent() to retrieve and dispatch events.

◆ nextEvent()

static void SoXt::nextEvent ( XtAppContext  appContext,
XEvent event 
)
inlinestatic

Gets the nextEvent by calling XtAppNextEvent().

The appContext can be had by calling SoXt::getAppContext().

Definition at line 220 of file SoXt.h.

◆ registerColormapLoad()

static void SoXt::registerColormapLoad ( SoWidget  widget,
SoWidget  shell 
)
static

Convenience routine which will register map/unmap callbacks to load and unload the pulldown menu color map right before the menu is about to be posted.

This should be called when creating pulldown or popup menus in the overlays. This will make sure that the right color map is loaded into the shell widget (to make the pulldown/popup look right) and remove it when no longer needed (to make sure the OpenGL overlay widget color map is correctly loaded for 8 bit machines).

◆ removeColormapFromShell()

static void SoXt::removeColormapFromShell ( SoWidget  widget,
SoWidget  shell 
)
static

Convenience routine to remove the given widget colormap from the supplied shell widget.

◆ setWidgetSize()

static void SoXt::setWidgetSize ( SoWidget  w,
const SbVec2s size 
)
static

Convenience routine to set the size of the given window.

◆ show()

static void SoXt::show ( SoWidget  widget)
static

Convenience routine to show the passed widget.

This includes any children the window may have.

◆ threadInit() [1/2]

static SoDEPRECATED SoWidget SoXt::threadInit ( const char *  appName,
const char *  className = "Inventor" 
)
static

◆ threadInit() [2/2]

static SoDEPRECATED void SoXt::threadInit ( SoWidget  topLevelWidget)
static

The documentation for this class was generated from the following file: