|
VR-Engage
2.2
|
DtVrvOverlay provides functionality for creating and managing 2D overlay elements (text, lines, quads, and textures) that are rendered on top of a 3D scene within a specific window and channel. It handles viewport transformations, resource management, and cleanup.
#include <vrvOverlay.h>
Public Member Functions | |
| DtVrvOverlay (const std::string &windowName, const std::string &channelName) | |
| DtVrvOverlay (makVrv::DtOsgChannel *channel) | |
| virtual | ~DtVrvOverlay () |
| virtual makVrv::DtOverlayRenderer * | overlay () |
| virtual osg::Geode * | geode () |
| virtual makVrv::DtOsgChannel * | channel () |
| virtual DtFontHolder * | createFont (const std::string &filename, float size) |
| virtual makVrv::DtTextProxy * | createText () |
| virtual makVrv::DtLineSegment * | createLine () |
| virtual makVrv::DtQuadProxy * | createQuad () |
| virtual makVrv::DtOsgTextureWrapper * | createTexture (const std::string &filename) |
| virtual float | pixelX (float normalizedX) |
| virtual float | pixelY (float normalizedY) |
| virtual float | pixelH (float normalizedH) |
| virtual float | pixelW (float normalizedW) |
| virtual void | addOverlayResizedHandler (const DtOverlayResizedDelegate &del) |
| virtual void | removeOverlayResizedHandler (const DtOverlayResizedDelegate &del) |
Protected Types | |
| using | OverlayResizedList = std::vector<DtOverlayResizedDelegate> |
Protected Member Functions | |
| virtual bool | findChannel (const std::string &windowName, const std::string &channelName) |
| virtual bool | setChannel (makVrv::DtOsgChannel *channel) |
| virtual bool | createOverlay () |
| virtual void | destroyOverlay () |
| virtual void | onViewportChanged () |
| virtual void | onChannelDestroyed (const std::string &displayName, const std::string &windowName, const std::string &channelName) |
Protected Attributes | |
| makVrv::DtDe * | myDe |
| makVrv::DtOverlayRenderer * | myOverlayRenderer |
| makVrv::DtOsgChannel * | myChannel |
| osg::ref_ptr< osg::Geode > | myGeode |
| int | myX |
| int | myY |
| int | myW |
| int | myH |
| std::vector< DtFontHolder * > | myCachedFonts |
| std::vector< osg::ref_ptr< osg::Texture2D > > | myCachedTextures |
| OverlayResizedList | myOverlayResizedCallbacks |
|
protected |
Type definition for a list of resize handlers.
| makVre::DtVrvOverlay::DtVrvOverlay | ( | const std::string & | windowName, |
| const std::string & | channelName ) |
Constructor that creates an overlay for a specific window and channel.
| windowName | The name of the window to create the overlay on |
| channelName | The name of the channel within the window |
Creates a new overlay on the specified window and channel. Throws an exception if the window or channel cannot be found, or if the overlay cannot be created.
| makVre::DtVrvOverlay::DtVrvOverlay | ( | makVrv::DtOsgChannel * | channel | ) |
Constructor that creates an overlay for a specific channel.
| channel | Pointer to the OSG channel to create the overlay on |
Creates a new overlay on the specified channel. Throws an exception if the channel is invalid or if the overlay cannot be created.
References channel().
|
virtual |
Virtual destructor that cleans up resources.
Destroys the overlay and cleans up associated resources.
|
virtual |
Gets the overlay renderer object.
Returns the underlying overlay renderer that can be used for direct rendering operations.
|
virtual |
Gets the geode node used for the overlay.
Returns the OSG geode node that contains the overlay drawable.
|
virtual |
Gets the channel associated with this overlay.
Returns the OSG channel that this overlay is attached to.
Referenced by DtVrvOverlay(), and setChannel().
|
virtual |
Creates a font for use with overlay text.
| filename | The font file path (will be resolved through path configuration) |
| size | The font size in points |
Creates and caches a font that can be used for rendering text in the overlay. Throws an exception if the font cannot be loaded.
|
virtual |
Creates a text element for the overlay.
Creates a new text element that can be configured and added to the overlay.
|
virtual |
Creates a line element for the overlay.
Creates a new line segment that can be configured and added to the overlay.
|
virtual |
Creates a quad element for the overlay.
Creates a new quad that can be textured and added to the overlay. By default, creates textured quads.
|
virtual |
Creates a texture from an image file.
| filename | The image file path (will be resolved through path configuration) |
Loads an image from the specified file and creates a texture that can be used with quads in the overlay. The texture is cached to prevent it from being garbage collected.
|
virtual |
Converts a normalized X coordinate to pixel coordinates.
| normalizedX | The normalized X coordinate (0.0 to 1.0, left to right) |
|
virtual |
Converts a normalized Y coordinate to pixel coordinates.
| normalizedY | The normalized Y coordinate (0.0 to 1.0, top to bottom) |
|
virtual |
Converts a normalized height to pixel height.
| normalizedH | The normalized height (0.0 to 1.0) |
|
virtual |
Converts a normalized width to pixel width.
| normalizedW | The normalized width (0.0 to 1.0) |
|
virtual |
Adds a handler for overlay resize events.
| del | The delegate to call when the overlay is resized |
Registers a callback function that will be called whenever the overlay's viewport changes size. Multiple callbacks can be registered, and each will be called in the order they were added.
|
virtual |
Removes a previously added resize handler.
| del | The delegate to remove |
Unregisters a callback function that was previously added with addOverlayResizedHandler. If the delegate is not found, a warning is logged.
|
protectedvirtual |
Finds a channel by name and sets it as the current channel.
| windowName | The name of the window containing the channel |
| channelName | The name of the channel to find |
Searches for a channel with the specified name in the specified window and sets it as the current channel for this overlay.
|
protectedvirtual |
Sets the channel for this overlay.
| channel | Pointer to the channel to use |
Sets the specified channel as the current channel for this overlay and registers for viewport change notifications.
References channel().
|
protectedvirtual |
Creates the overlay rendering system.
Creates the overlay renderer and adds it to the channel's scene graph.
|
protectedvirtual |
Destroys the overlay and cleans up resources.
Removes the overlay from the channel's scene graph and releases allocated resources.
|
protectedvirtual |
Called when the viewport of the channel changes.
Updates the cached viewport dimensions and notifies registered resize handlers of the change.
|
protectedvirtual |
Called when a channel is about to be destroyed.
| displayName | The name of the display containing the channel |
| windowName | The name of the window containing the channel |
| channelName | The name of the channel being destroyed |
Checks if the channel being destroyed is the one used by this overlay, and if so, cleans up the overlay resources.
|
protected |
Pointer to the display engine.
|
protected |
Pointer to the overlay renderer.
|
protected |
Pointer to the channel this overlay is attached to.
|
protected |
The OSG geode node containing the overlay drawable.
|
protected |
The X position of the channel viewport.
|
protected |
The Y position of the channel viewport.
|
protected |
The width of the channel viewport.
|
protected |
The height of the channel viewport.
|
protected |
Collection of cached fonts to prevent garbage collection.
|
protected |
Collection of cached textures to prevent garbage collection.
|
protected |
List of callbacks to notify when the overlay is resized.