Open Inventor Release 2024.1.0
 
Loading...
Searching...
No Matches
SoQtGLWidget Class Referenceabstract

VSG extension Component for OpenGL rendering. More...

#include <Inventor/Qt/SoQtGLWidget.h>

+ Inheritance diagram for SoQtGLWidget:

Public Types

enum  FloatColorBufferSize {
  FLOAT_16_COLOR_BUFFER = SoGuiGLWidget::FLOAT_16_COLOR_BUFFER ,
  FLOAT_32_COLOR_BUFFER = SoGuiGLWidget::FLOAT_32_COLOR_BUFFER
}
 FloatColorBufferSize. More...
 

Public Member Functions

int getColorMapSize ()
 Returns the color map size.
 
void setColorMapSize (int size)
 Sets the color map size.
 
virtual WindowQt getNormalWindow ()
 Gets the normal GL window (window system identifier of the widget), which is needed as an argument to glXMakeCurrent() (on Xt) or SbGlContextHelper::makeCurrent() (on Windows) when drawing in the normal planes.
 
QOpenGLContext * getQOpenGLContext ()
 Gets the current context, which is needed as an argument to glXMakeCurrent() (on Xt) or SbGlContextHelper::makeCurrent() (on Windows) when drawing in the normal planes.
 
SoGLContextgetNormalSoContext ()
 Gets the current context, which is needed as an argument to glXMakeCurrent() (on Xt) or SbGlContextHelper::makeCurrent() (on Windows) when drawing in the normal planes.
 
QWidget * getNormalWidget ()
 Gets the current normal widget.
 
QSurfaceFormat getQSurfaceFormat ()
 Returns the QSurfaceFormat currently used.
 
virtual void setNormalVisual (QSurfaceFormat vis)
 Sets the visual/pixel format for the normal window.
 
virtual void setNormalVisual (const SoGLFormat &format)
 Sets the visual/pixel format for the normal window.
 
virtual void show ()
 This shows the component.
 
virtual void hide ()
 This hides the component.
 
virtual void setDoubleBuffer (SbBool onOrOff)
 Routine that dynamically changes between single and double buffering.
 
SbBool isDoubleBuffer ()
 Returns whether double buffering is on or off.
 
void setBorder (SbBool onOrOff)
 Included for portability only.
 
int getBorderSize ()
 Included for portability only.
 
SbBool isBorder () const
 Included for portability only.
 
void setDrawToFrontBufferEnable (SbBool enableFlag)
 Sets drawing to the front buffer.
 
SbBool isDrawToFrontBufferEnable () const
 Queries drawing to the front buffer.
 
virtual SbBool bindNormalContext ()
 Makes the normal rendering context the current context.
 
virtual SbBool unbindNormalContext ()
 unbind the current context (previously bind with bindNormalContext );
 
virtual SbBool swapNormalBuffers ()
 Swaps the normal front and back buffers.
 
virtual void setCursor (const QCursor &newCursor)
 Sets the current cursor.
 
QCursor getCursor () const
 Returns the current cursor.
 
void setAntialiasing (const float quality, const SoSceneManager::AntialiasingMode mode=SoSceneManager::AUTO)
 Enable (or disable) antialiasing with specified quality and mode.
 
void setAntialiasing (SoAntialiasingParameters *advancedParameters)
 Enable (or disable) antialiasing with specific parameters.
 
float getAntialiasingQuality () const
 Returns the antialiasing quality set using the setAntialiasing(float,AntialiasingMode) method.
 
SoSceneManager::AntialiasingMode getAntialiasingMode () const
 Returns the antialiasing mode set using the setAntialiasing(float,AntialiasingMode) method.
 
SoAntialiasingParametersgetAntialiasingParameters () const
 Returns the antialiasing parameters set using the setAntialiasing(SoAntialiasingParameters*) method.
 
bool saveSnapshot (const SbString &filename, bool overwrite=true)
 Save a snapshot of the current image displayed in the viewer.
 
- Public Member Functions inherited from SoQtComponent
SbBool isVisible ()
 Returns TRUE if this component is mapped onto the screen.
 
virtual QWidget * getWidget () const
 This returns the base widget handle for this component.
 
SbBool isTopLevelShell () const
 Returns TRUE if this component is a top level shell component (has its own window).
 
QWidget * getShellWidget () const
 Returns the topLevelShell widget handle (NULL if the topLevelShell hasn't been created by this component).
 
QWidget * getParentWidget () const
 Returns the parent widget handle.
 
void setSize (const SbVec2s &size)
 Convenience routine on the widget handle.
 
SbVec2s getSize ()
 Convenience routine on the widget handle.
 
virtual SbBool setFullScreen (const SbBool enable)
 Switches the viewer into (or out of) fullscreen mode.
 
SbBool isFullScreen (void) const
 Queries if the viewer is in fullscreen mode.
 
void setFullScreenEnable (const SbBool enable)
 Enables/disables fullscreen mode.
 
SbBool isFullScreenEnable (void) const
 Queries if it is possible to put the viewer in fullscreen mode.
 
SbGlContextHelper::Display getDisplay ()
 On UNIX, returns the X display associated with this components widget.
 
void setTitle (const char *newTitle)
 Sets window title.
 
void setTitle (const SbString &newTitle)
 Sets window title.
 
void setTitle (const QString &newTitle)
 Sets window title.
 
const QString getTitle () const
 Gets window title.
 
void setIconTitle (const QString &newIconTitle)
 Included for portability only.
 
const QString getIconTitle () const
 Included for portability only.
 
SbString getWidgetName () const
 Returns the widget handle name.
 
SbString getClassName () const
 Returns the class name.
 
void setWindowCloseCallback (SoQtComponentCB *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.
 

Friends

class SoQGLWidgetProxy
 

Additional Inherited Members

- Static Public Member Functions inherited from SoQtComponent
static SoQtComponentgetComponent (QWidget *widget)
 Returns the SoQtComponent for this widget handle.
 
- Public Attributes inherited from SoQtComponent
SbString helpFileName
 Name of help file to open when the viewer Help button is pressed.
 

Detailed Description

VSG extension Component for OpenGL rendering.

This abstract base class provides a C++ wrapper around an OpenGL widget. It allows OpenGL rendering to be performed within a widget and is used by the SoQtRenderArea. SoQtGLWidget uses a parent window with two separate OpenGL widgets (one for single and one for double buffering), with routines to return the appropriate windows.

Subclasses only need to redefine the redraw() routine for rendering and processEvent() routine if they are interested in receiving Q events.

SEE ALSO

SoQtComponent, SoQtRenderArea

Definition at line 90 of file SoQtGLWidget.h.

Member Enumeration Documentation

◆ FloatColorBufferSize

FloatColorBufferSize.

Enumerator
FLOAT_16_COLOR_BUFFER 

16-bit rendering per component.

FLOAT_32_COLOR_BUFFER 

32-bit rendering per component.

Definition at line 97 of file SoQtGLWidget.h.

Member Function Documentation

◆ bindNormalContext()

virtual SbBool SoQtGLWidget::bindNormalContext ( )
virtual

Makes the normal rendering context the current context.

Equivalent to makeNormalCurrent() call.

◆ getAntialiasingMode()

SoSceneManager::AntialiasingMode SoQtGLWidget::getAntialiasingMode ( ) const

Returns the antialiasing mode set using the setAntialiasing(float,AntialiasingMode) method.

Returns AUTO by default. Parameters set using the setAntialiasing(SoAntialiasingParameters*) method may change the antialiasing mode, but do not affect the value returned by this method. Therefore this method does not necessarily return the current actual antialiasing mode.

◆ getAntialiasingParameters()

SoAntialiasingParameters * SoQtGLWidget::getAntialiasingParameters ( ) const

Returns the antialiasing parameters set using the setAntialiasing(SoAntialiasingParameters*) method.

Returns null by default. A quality value set using the setAntialiasing(float,AntialiasingMode) method may modify internal parameters, but does not affect the value returned by this method. Therefore this method does not necessarily return the current actual antialiasing parameters.

◆ getAntialiasingQuality()

float SoQtGLWidget::getAntialiasingQuality ( ) const

Returns the antialiasing quality set using the setAntialiasing(float,AntialiasingMode) method.

Returns 0.0 by default. Parameters set using the setAntialiasing(SoAntialiasingParameters*) method override internal parameters, but do not affect the value returned by this method. Therefore this method does not necessarily return the current actual antialiasing quality.

◆ getBorderSize()

int SoQtGLWidget::getBorderSize ( )
inline

Included for portability only.

Definition at line 221 of file SoQtGLWidget.h.

◆ getColorMapSize()

int SoQtGLWidget::getColorMapSize ( )

Returns the color map size.

◆ getCursor()

QCursor SoQtGLWidget::getCursor ( ) const

Returns the current cursor.

◆ getNormalSoContext()

SoGLContext * SoQtGLWidget::getNormalSoContext ( )

Gets the current context, which is needed as an argument to glXMakeCurrent() (on Xt) or SbGlContextHelper::makeCurrent() (on Windows) when drawing in the normal planes.

Note: This should not be cached by users because it will change as OpenGL format changes.

◆ getNormalWidget()

QWidget * SoQtGLWidget::getNormalWidget ( )

Gets the current normal widget.


Since Open Inventor 8.0, this widget is a QWidget. More information about this class can be found on-line in the Qt documentation.

Note: This should not be cached by users because it will change as OpenGL format changes.

◆ getNormalWindow()

virtual WindowQt SoQtGLWidget::getNormalWindow ( )
virtual

Gets the normal GL window (window system identifier of the widget), which is needed as an argument to glXMakeCurrent() (on Xt) or SbGlContextHelper::makeCurrent() (on Windows) when drawing in the normal planes.

Note: This should not be cached by users because it will change as single/double buffering changes.

◆ getQOpenGLContext()

QOpenGLContext * SoQtGLWidget::getQOpenGLContext ( )

Gets the current context, which is needed as an argument to glXMakeCurrent() (on Xt) or SbGlContextHelper::makeCurrent() (on Windows) when drawing in the normal planes.

Note: This should not be cached by users because it will change as OpenGL format changes.

◆ getQSurfaceFormat()

QSurfaceFormat SoQtGLWidget::getQSurfaceFormat ( )

Returns the QSurfaceFormat currently used.

◆ hide()

virtual void SoQtGLWidget::hide ( )
virtual

This hides the component.

Reimplemented from SoQtComponent.

Reimplemented in SoQtFullViewer.

◆ isBorder()

SbBool SoQtGLWidget::isBorder ( ) const
inline

Included for portability only.

Definition at line 226 of file SoQtGLWidget.h.

◆ isDoubleBuffer()

SbBool SoQtGLWidget::isDoubleBuffer ( )
inline

Returns whether double buffering is on or off.

Definition at line 211 of file SoQtGLWidget.h.

◆ isDrawToFrontBufferEnable()

SbBool SoQtGLWidget::isDrawToFrontBufferEnable ( ) const
inline

Queries drawing to the front buffer.

Definition at line 237 of file SoQtGLWidget.h.

◆ saveSnapshot()

bool SoQtGLWidget::saveSnapshot ( const SbString filename,
bool  overwrite = true 
)

Save a snapshot of the current image displayed in the viewer.

The image is read back from the OpenGL framebuffer and will be the same size as the viewer's drawing window. Returns true if successful.

Notes:

  • Depending on the operating system and graphics hardware, it is possible that the image could be incomplete if the viewer window is overlapped by other windows.
  • The supported image file formats are: BMP (Windows only), JPEG, PNG and TIFF.
    The image file format to write is determined by the extension of the specified filename, e.g. ".png" for PNG format.
  • For BMP and JPEG formats an RGB image is written.
  • For PNG and TIFF formats, an RGBA (RGB plus alpha channel) image is always written.
  • Writing an RGBA image means the image background is transparent. Actually an RGBA snapshot can not be saved without transparency. To get the displayed image without transparency, use the BMP or the JPEG format.
  • To generate an image with a different size or different options, use SoOffscreenRenderArea instead.
  • The specified filename must include a directory or nothing will be written. Can be simply "./filename.png", but just "filename.png" won't work.
Parameters
filenameFully qualified file path for the snapshot file.
The specified filename must end with one of the extensions supported by SoJPEGImageRW (jpg, jpeg, ...), SoPNGImageRW (png), SoBMPImageRW (bmp), or SoTIFFImageRW (tif, ...).
overwriteIf true, overwrite any existing file with the same name (default is true).

◆ setAntialiasing() [1/2]

void SoQtGLWidget::setAntialiasing ( const float  quality,
const SoSceneManager::AntialiasingMode  mode = SoSceneManager::AUTO 
)

Enable (or disable) antialiasing with specified quality and mode.

Specific antialiasing parameters will be set automatically based on the quality value. Note that the quality and mode settings are overridden if specific antialiasing parameters are subsequently set using the setAntialiasing(SoAntialiasingParameters*) method.

The default mode is AUTO but this may be overridden by setting the environment variable OIV_ANTIALIASING_DEFAULT_MODE (see SoPreferences).

Parameters
qualityThe quality is a factor in the range [0.0,1.0].
Use the value 0.0 to turn off antialiasing. 0.5 is a typical value.
modeThe antialiasing algorithm. Default is AUTO, which means use the best for the current hardware.
Use the value NO_ANTIALIASING to turn off antialiasing.

◆ setAntialiasing() [2/2]

void SoQtGLWidget::setAntialiasing ( SoAntialiasingParameters advancedParameters)

Enable (or disable) antialiasing with specific parameters.

Use one of the subclasses of SoAntialiasingParameters. The antialiasing mode is determined by which subclass is used to set the parameters. For example, passing an SoFXAAParameters object automatically sets FXAA mode. Note that the parameters are overridden if a quality and mode are subsequently set using the setAntialiasing(float,AntialiasingMode) method.

NOTES

    • When the antialiasing parameters are modified a listener is called if it has been defined. See also setAntialiasingEventListener().
    • The caller is responsible for allocation and destruction of the advancedParameters object. SoSceneManager makes a copy of the parameter values, so the object can be destroyed after calling this method.
    Parameters
    advancedParametersProvides specific parameters for an antialiasing mode.
    Use a null parameter to turn off antialiasing or use one of the subclasses of SoAntialiasingParameters.

◆ setBorder()

void SoQtGLWidget::setBorder ( SbBool  onOrOff)

Included for portability only.

◆ setColorMapSize()

void SoQtGLWidget::setColorMapSize ( int  size)

Sets the color map size.

◆ setCursor()

virtual void SoQtGLWidget::setCursor ( const QCursor &  newCursor)
virtual

Sets the current cursor.

If you are using a viewer class, the viewer will automatically change the cursor depending on the viewer mode. These changes will override the cursor set with this method unless you also call SoQtGLWidget::setCursorEnabled(FALSE).

◆ setDoubleBuffer()

virtual void SoQtGLWidget::setDoubleBuffer ( SbBool  onOrOff)
virtual

Routine that dynamically changes between single and double buffering.

Default is double buffer off. (The SoQtRenderArea subclass makes it double buffer by default.)

◆ setDrawToFrontBufferEnable()

void SoQtGLWidget::setDrawToFrontBufferEnable ( SbBool  enableFlag)

Sets drawing to the front buffer.

Controls drawing to the front buffer when an obscured portion of the window is exposed. Default: TRUE.

◆ setNormalVisual() [1/2]

virtual void SoQtGLWidget::setNormalVisual ( const SoGLFormat format)
virtual

Sets the visual/pixel format for the normal window.


This allows the user to create all possible visuals supported by OpenGL. The OpenGL drivers or accelerated hardware may or may not support advanced features such as alpha channel or stereographic viewing. If you request some features that the driver/hardware does not provide when you set the QGLFormat , you will get a rendering context with the nearest subset of features.

The methods for setting the visual are virtual so that derived classes can know when the visual is changing.

◆ setNormalVisual() [2/2]

virtual void SoQtGLWidget::setNormalVisual ( QSurfaceFormat  vis)
virtual

Sets the visual/pixel format for the normal window.


This allows the user to create all possible visuals supported by OpenGL. The OpenGL drivers or accelerated hardware may or may not support advanced features such as alpha channel or stereographic viewing. If you request some features that the driver/hardware does not provide when you set the QGLFormat , you will get a rendering context with the nearest subset of features.

The methods for setting the visual are virtual so that derived classes can know when the visual is changing.

◆ show()

virtual void SoQtGLWidget::show ( )
virtual

This shows the component.

Reimplemented from SoQtComponent.

◆ swapNormalBuffers()

virtual SbBool SoQtGLWidget::swapNormalBuffers ( )
virtual

Swaps the normal front and back buffers.

◆ unbindNormalContext()

virtual SbBool SoQtGLWidget::unbindNormalContext ( )
virtual

unbind the current context (previously bind with bindNormalContext );

Friends And Related Symbol Documentation

◆ SoQGLWidgetProxy

friend class SoQGLWidgetProxy
friend

Definition at line 563 of file SoQtGLWidget.h.


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