VR-Engage  2.2
Loading...
Searching...
No Matches
makVre::DtVrvOverlay Class Reference

Detailed Description

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 DtFontHoldercreateFont (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
 

Member Typedef Documentation

◆ OverlayResizedList

Type definition for a list of resize handlers.

Constructor & Destructor Documentation

◆ DtVrvOverlay() [1/2]

makVre::DtVrvOverlay::DtVrvOverlay ( const std::string & windowName,
const std::string & channelName )

Constructor that creates an overlay for a specific window and channel.

Parameters
windowNameThe name of the window to create the overlay on
channelNameThe 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.

◆ DtVrvOverlay() [2/2]

makVre::DtVrvOverlay::DtVrvOverlay ( makVrv::DtOsgChannel * channel)

Constructor that creates an overlay for a specific channel.

Parameters
channelPointer 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().

◆ ~DtVrvOverlay()

virtual makVre::DtVrvOverlay::~DtVrvOverlay ( )
virtual

Virtual destructor that cleans up resources.

Destroys the overlay and cleans up associated resources.

Member Function Documentation

◆ overlay()

virtual makVrv::DtOverlayRenderer * makVre::DtVrvOverlay::overlay ( )
virtual

Gets the overlay renderer object.

Returns
Pointer to the overlay renderer, or nullptr if not initialized

Returns the underlying overlay renderer that can be used for direct rendering operations.

◆ geode()

virtual osg::Geode * makVre::DtVrvOverlay::geode ( )
virtual

Gets the geode node used for the overlay.

Returns
Pointer to the OSG geode node

Returns the OSG geode node that contains the overlay drawable.

◆ channel()

virtual makVrv::DtOsgChannel * makVre::DtVrvOverlay::channel ( )
virtual

Gets the channel associated with this overlay.

Returns
Pointer to the OSG channel

Returns the OSG channel that this overlay is attached to.

Referenced by DtVrvOverlay(), and setChannel().

◆ createFont()

virtual DtFontHolder * makVre::DtVrvOverlay::createFont ( const std::string & filename,
float size )
virtual

Creates a font for use with overlay text.

Parameters
filenameThe font file path (will be resolved through path configuration)
sizeThe font size in points
Returns
A font holder containing the created font

Creates and caches a font that can be used for rendering text in the overlay. Throws an exception if the font cannot be loaded.

◆ createText()

virtual makVrv::DtTextProxy * makVre::DtVrvOverlay::createText ( )
virtual

Creates a text element for the overlay.

Returns
A new text proxy object

Creates a new text element that can be configured and added to the overlay.

◆ createLine()

virtual makVrv::DtLineSegment * makVre::DtVrvOverlay::createLine ( )
virtual

Creates a line element for the overlay.

Returns
A new line segment object

Creates a new line segment that can be configured and added to the overlay.

◆ createQuad()

virtual makVrv::DtQuadProxy * makVre::DtVrvOverlay::createQuad ( )
virtual

Creates a quad element for the overlay.

Returns
A new quad proxy object

Creates a new quad that can be textured and added to the overlay. By default, creates textured quads.

◆ createTexture()

virtual makVrv::DtOsgTextureWrapper * makVre::DtVrvOverlay::createTexture ( const std::string & filename)
virtual

Creates a texture from an image file.

Parameters
filenameThe image file path (will be resolved through path configuration)
Returns
A texture wrapper containing the loaded texture, or nullptr if loading failed

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.

◆ pixelX()

virtual float makVre::DtVrvOverlay::pixelX ( float normalizedX)
virtual

Converts a normalized X coordinate to pixel coordinates.

Parameters
normalizedXThe normalized X coordinate (0.0 to 1.0, left to right)
Returns
The pixel X coordinate relative to the channel viewport

◆ pixelY()

virtual float makVre::DtVrvOverlay::pixelY ( float normalizedY)
virtual

Converts a normalized Y coordinate to pixel coordinates.

Parameters
normalizedYThe normalized Y coordinate (0.0 to 1.0, top to bottom)
Returns
The pixel Y coordinate relative to the channel viewport

◆ pixelH()

virtual float makVre::DtVrvOverlay::pixelH ( float normalizedH)
virtual

Converts a normalized height to pixel height.

Parameters
normalizedHThe normalized height (0.0 to 1.0)
Returns
The height in pixels

◆ pixelW()

virtual float makVre::DtVrvOverlay::pixelW ( float normalizedW)
virtual

Converts a normalized width to pixel width.

Parameters
normalizedWThe normalized width (0.0 to 1.0)
Returns
The width in pixels

◆ addOverlayResizedHandler()

virtual void makVre::DtVrvOverlay::addOverlayResizedHandler ( const DtOverlayResizedDelegate & del)
virtual

Adds a handler for overlay resize events.

Parameters
delThe 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.

◆ removeOverlayResizedHandler()

virtual void makVre::DtVrvOverlay::removeOverlayResizedHandler ( const DtOverlayResizedDelegate & del)
virtual

Removes a previously added resize handler.

Parameters
delThe delegate to remove

Unregisters a callback function that was previously added with addOverlayResizedHandler. If the delegate is not found, a warning is logged.

◆ findChannel()

virtual bool makVre::DtVrvOverlay::findChannel ( const std::string & windowName,
const std::string & channelName )
protectedvirtual

Finds a channel by name and sets it as the current channel.

Parameters
windowNameThe name of the window containing the channel
channelNameThe name of the channel to find
Returns
True if the channel was found, false otherwise

Searches for a channel with the specified name in the specified window and sets it as the current channel for this overlay.

◆ setChannel()

virtual bool makVre::DtVrvOverlay::setChannel ( makVrv::DtOsgChannel * channel)
protectedvirtual

Sets the channel for this overlay.

Parameters
channelPointer to the channel to use
Returns
True if the channel was set successfully, false otherwise

Sets the specified channel as the current channel for this overlay and registers for viewport change notifications.

References channel().

◆ createOverlay()

virtual bool makVre::DtVrvOverlay::createOverlay ( )
protectedvirtual

Creates the overlay rendering system.

Returns
True if the overlay was created successfully, false otherwise

Creates the overlay renderer and adds it to the channel's scene graph.

◆ destroyOverlay()

virtual void makVre::DtVrvOverlay::destroyOverlay ( )
protectedvirtual

Destroys the overlay and cleans up resources.

Removes the overlay from the channel's scene graph and releases allocated resources.

◆ onViewportChanged()

virtual void makVre::DtVrvOverlay::onViewportChanged ( )
protectedvirtual

Called when the viewport of the channel changes.

Updates the cached viewport dimensions and notifies registered resize handlers of the change.

◆ onChannelDestroyed()

virtual void makVre::DtVrvOverlay::onChannelDestroyed ( const std::string & displayName,
const std::string & windowName,
const std::string & channelName )
protectedvirtual

Called when a channel is about to be destroyed.

Parameters
displayNameThe name of the display containing the channel
windowNameThe name of the window containing the channel
channelNameThe 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.

Member Data Documentation

◆ myDe

makVrv::DtDe* makVre::DtVrvOverlay::myDe
protected

Pointer to the display engine.

◆ myOverlayRenderer

makVrv::DtOverlayRenderer* makVre::DtVrvOverlay::myOverlayRenderer
protected

Pointer to the overlay renderer.

◆ myChannel

makVrv::DtOsgChannel* makVre::DtVrvOverlay::myChannel
protected

Pointer to the channel this overlay is attached to.

◆ myGeode

osg::ref_ptr<osg::Geode> makVre::DtVrvOverlay::myGeode
protected

The OSG geode node containing the overlay drawable.

◆ myX

int makVre::DtVrvOverlay::myX
protected

The X position of the channel viewport.

◆ myY

int makVre::DtVrvOverlay::myY
protected

The Y position of the channel viewport.

◆ myW

int makVre::DtVrvOverlay::myW
protected

The width of the channel viewport.

◆ myH

int makVre::DtVrvOverlay::myH
protected

The height of the channel viewport.

◆ myCachedFonts

std::vector<DtFontHolder*> makVre::DtVrvOverlay::myCachedFonts
protected

Collection of cached fonts to prevent garbage collection.

◆ myCachedTextures

std::vector<osg::ref_ptr<osg::Texture2D> > makVre::DtVrvOverlay::myCachedTextures
protected

Collection of cached textures to prevent garbage collection.

◆ myOverlayResizedCallbacks

OverlayResizedList makVre::DtVrvOverlay::myOverlayResizedCallbacks
protected

List of callbacks to notify when the overlay is resized.


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