SOXTCOMPONENT(3iv)

πŸ‘‘ SoXtComponent β€” the abstract base class era

okay bestie, welcome to SoXtComponent(3IV) β€” yes, the (3IV) is the manual section, she's fancy like that πŸ’…

This is the abstract base class for all Inventor Xt components. Every single one. She's the mother, the blueprint, the blueprint-iest blueprint. Nobody instantiates her directly, but everybody inherits from her.


🌸 INHERITS FROM

SoXtComponent

(yeah, she's the root of this tree β€” no parent above her, she IS the parent πŸ’–)


✨ SYNOPSIS

#include <Inventor/Xt/SoXtComponent.h>

typedef void        SoXtComponentCB(void *userData, SoXtComponent *comp)

Methods from class SoXtComponent:

virtual void            show()
virtual void            hide()
SbBool                  isVisible()
Widget                  getWidget() const
SbBool                  isTopLevelShell() const
Widget                  getShellWidget() const
Widget                  getParentWidget() const
void                    setSize(const SbVec2s &size)
SbVec2s                 getSize()
Display *               getDisplay()
void                    setTitle(const char *newTitle)
const char *            getTitle() const
void                    setIconTitle(const char *newIconTitle)
const char *            getIconTitle() const
void                    setWindowCloseCallback(SoXtComponentCB *func, void
                             *data = NULL)
static SoXtComponent *  getComponent(Widget w)
const char *            getWidgetName() const
const char *            getClassName() const

πŸ¦‹ DESCRIPTION

So. She's the abstract base class from which all Inventor Xt components are derived. No cap. This class hands you a basic C++ protocol for building and displaying Motif components.

And what's a component, you ask? A component is how you take some function or task and wrap it up all cozy into a reusable package in the form of a Motif widget πŸŽ€ β€” a widget that can be dropped into literally any Inventor Xt program. Reusable. Iconic. Main character energy.

Wanna see how to build and use SoXtComponents for real? Scroll down to the Example section, babe, it's right there ✨


πŸ’… METHODS

  • virtual void show()
  • virtual void hide()

This shows and hides the component, duh. Here's the tea though: if this is a topLevelShell component, then show() will Realize and Map the window. Otherwise it'll just Manage the widget. hide() calls the appropriate unmap or unmanage routines.

Oh and also β€” show() will pop the component window to the top and de-iconify if necessary, so the component is actually visible to the user. She's not gonna let you get buried behind seventeen other windows, bestie. She makes sure you're SEEN. πŸ”₯

  • SbBool isVisible()

Returns TRUE if this component is mapped onto the screen. For a component to count as visible, both its widget and the shell containing that widget must be mapped β€” which is FALSE when the component is iconified, jsyk.

Subclasses should call this routine before redrawing anything, and in any sensor trigger methods. Calling it checks the current visibility (which is really cheap, like genuinely, it costs basically nothing) and invokes the visibility changed callbacks if the state changes (see addVisibilityChangeCallback()).

  • Widget getWidget() const

Returns the base widget for this component. If the component created its own shell, this returns the topmost widget beneath the shell. Want the shell itself? Call getShellWidget().

  • SbBool isTopLevelShell() const
  • Widget getShellWidget() const

Returns TRUE if this component is a top level shell component (aka she has her own window πŸ‘‘). Subclasses may use this to decide if they're allowed to resize themselves. Also, the method that returns the shell widget β€” that's NULL if the shell hasn't been created by this component.

  • Widget getParentWidget() const

Returns the parent widget. Shell or not, doesn't matter, you get the parent. πŸ’–

  • void setSize(const SbVec2s &size)
  • SbVec2s getSize()

Convenience routines on the widget β€” setSize calls XtSetValue.

  • Display *getDisplay()

Returns the X display associated with this component's widget.

  • void setTitle(const char *newTitle)
  • const char *getTitle() const
  • void setIconTitle(const char *newIconTitle)
  • const char *getIconTitle() const

The window title and icon title can be set for topLevelShell components β€” or for components which are directly under a shell widget (i.e. components which have their own window).

  • void setWindowCloseCallback(SoXtComponentCB *func, void *data = NULL)

Sets which callback to call when the user closes this component (double click in the upper left corner πŸ–±οΈ). By default, hide() is called on this component β€” unless a callback is set to something other than NULL. A pointer to this class gets passed as the callback data.

Note: this callback is supplied because the user may wish to delete this component when it is closed. So like, heads up, that's a whole thing you might wanna do.
  • static SoXtComponent *getComponent(Widget w)

Returns the SoXtComponent for this widget. If the widget isn't an Inventor component, then NULL is returned. Simple as that. πŸ™ˆ

  • const char *getWidgetName() const
  • const char *getClassName() const

Routines that return the widget name and the class name. The widget name is passed to the build method. The class name is predefined by each component. These names are used when retrieving X resource values for the component. iykyk. ⭐


🌈 EXAMPLE

okay this is the part where it gets good. This example shows how an Inventor component can be built inside a program using the Xt widget set. It uses the SoXtExaminerViewer widget to view some simple geometry. Slay.

#include <Inventor/Xt/SoXt.h>
#include <Inventor/nodes/SoCone.h>
#include <Inventor/Xt/viewers/SoXtExaminerViewer.h>

void main(int, char **argv)
{
    // Initialize Inventor and Xt, which must be done
    // before any Inventor calls are made.
    Widget myWindow = SoXt::init(argv[0]);

    // create the viewer in the toplevel window
    // and set some scene to display
    SoXtExaminerViewer *myViewer = new SoXtExaminerViewer(myWindow);
    myViewer->setSceneGraph( new SoCone() );

    // manage and map window on screen
    myViewer->show();
    SoXt::show(myWindow); // calls XtRealizeWidget()

    // Loop forever
    SoXt::mainLoop();
}

like... look at her. SoXt::mainLoop() and she never comes back. iconic behavior honestly 🫢


🧚 SEE ALSO

SoXt, SoXtRenderArea, SoXtViewer, SoXtMaterialEditor

go read those too, bestie, they're all in the same friend group πŸ’œ


and that's the whole page!! this was SoXtComponent(3IV) from the SoXtComponent(3IV) manual β€” she's dated, she's versioned, she's been sitting in your /usr/share/man this whole time waiting for you to love her. mwah πŸ’‹πŸŒΈβœ¨