Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
RemoteViz::Rendering::RenderAreaListener Class Reference

RemoteViz More...

#include <RemoteViz/Rendering/RenderAreaListener.h>

Public Member Functions

virtual ~RenderAreaListener ()
 Destructor.
 
virtual void onOpenedConnection (std::shared_ptr< RenderArea > renderArea, std::shared_ptr< Connection > connection, std::shared_ptr< FrameEncoders > frameEncoders)
 Triggered when a client connects to the RenderArea.
 
virtual void onInitializedConnection (std::shared_ptr< RenderArea > renderArea, std::shared_ptr< Connection > sender, std::shared_ptr< const FrameEncoders > frameEncoders)
 Triggered when the connection and the frame encoders are initialized successfully.
 
virtual void onClosedConnection (std::shared_ptr< RenderArea > renderArea, const std::string &connectionId, bool aborted)
 Triggered when a connection is closed.
 
virtual void onReceivedMessage (std::shared_ptr< RenderArea > renderArea, std::shared_ptr< Connection > sender, const std::string &message)
 Triggered when a text message is received from a client.
 
virtual void onReceivedMessage (std::shared_ptr< RenderArea > renderArea, std::shared_ptr< Connection > sender, const std::vector< unsigned char > &buffer)
 Triggered when a binary message is received from a client.
 
virtual bool onPreRender (std::shared_ptr< RenderArea > renderArea, bool &clearWindow, bool &clearZbuffer)
 Triggered before a rendering is done.
 
virtual void onPostRender (std::shared_ptr< RenderArea > renderArea)
 Triggered after a rendering is done.
 
virtual void onResize (std::shared_ptr< RenderArea > renderArea, unsigned int width, unsigned int height)
 Triggered when the renderArea is resized.
 
virtual void onRequestedSize (std::shared_ptr< RenderArea > renderArea, std::shared_ptr< Connection > sender, unsigned int width, unsigned int height)
 Triggered when a client requests a new renderArea size.
 
virtual void onRefusedEncoder (std::shared_ptr< RenderArea > renderArea, std::shared_ptr< Connection > sender, std::shared_ptr< FrameEncoders > encoders)
 Triggered when a frame encoder cannot be initialized.
 
virtual bool onMouseUp (std::shared_ptr< RenderArea > renderArea, std::shared_ptr< Connection > sender, int x, int y, SoMouseButtonEvent::Button button)
 Triggered when a MouseUp event is received from the client.
 
virtual bool onMouseDown (std::shared_ptr< RenderArea > renderArea, std::shared_ptr< Connection > sender, int x, int y, SoMouseButtonEvent::Button button)
 Triggered when a MouseDown event is received from the client.
 
virtual bool onMouseDoubleClick (std::shared_ptr< RenderArea > renderArea, std::shared_ptr< Connection > sender, int x, int y, SoMouseButtonEvent::Button button)
 Triggered when a MouseDoubleClick event is received from the client.
 
virtual bool onMouseMove (std::shared_ptr< RenderArea > renderArea, std::shared_ptr< Connection > sender, int x, int y)
 Triggered when a MouseMove event is received from the client.
 
virtual bool onMouseEnter (std::shared_ptr< RenderArea > renderArea, std::shared_ptr< Connection > sender, int x, int y)
 Triggered when a MouseEnter event is received from the client.
 
virtual bool onMouseLeave (std::shared_ptr< RenderArea > renderArea, std::shared_ptr< Connection > sender, int x, int y)
 Triggered when a MouseLeave event is received from the client.
 
virtual bool onMouseWheel (std::shared_ptr< RenderArea > renderArea, std::shared_ptr< Connection > sender, int x, int y, int delta)
 Triggered when a mouse wheel event (rotatation) is received from the client.
 
virtual bool onKeyUp (std::shared_ptr< RenderArea > renderArea, std::shared_ptr< Connection > sender, int x, int y, const SoKeyboardEvent::Key &key)
 Triggered when a KeyUp event is received from the client.
 
virtual bool onKeyDown (std::shared_ptr< RenderArea > renderArea, std::shared_ptr< Connection > sender, int x, int y, const SoKeyboardEvent::Key &key)
 Triggered when a KeyDown event is received from the client.
 
virtual bool onTouchStart (std::shared_ptr< RenderArea > renderArea, std::shared_ptr< Connection > sender, unsigned int id, int x, int y)
 Triggered when a TouchStart event is received from the client.
 
virtual bool onTouchMove (std::shared_ptr< RenderArea > renderArea, std::shared_ptr< Connection > sender, unsigned int id, int x, int y)
 Triggered when a TouchMove event is received from the client.
 
virtual bool onTouchEnd (std::shared_ptr< RenderArea > renderArea, std::shared_ptr< Connection > sender, unsigned int id, int x, int y)
 Triggered when a TouchEnd event is received from the client.
 
virtual void onRequestedFrame (std::shared_ptr< RenderArea > renderArea, std::shared_ptr< Connection > sender, SbRasterImage *rasterImage, bool &isInteractive)
 Triggered when a new frame is requested by a connection.
 
virtual void onSendingFrame (std::shared_ptr< RenderArea > renderArea, std::shared_ptr< Connection > sender, std::string &message)
 Triggered before sending a frame to the client.
 

Detailed Description

RemoteViz

This class can be overridden by an application to receive notifications from a RenderArea.

There are several categories of notifications:

  • Connection: To know when a connection has been created, initialized and disposed.
  • Render: To know the start/end of rendering and when an image is sent to the client.
  • Input events: To handle MouseDown, MouseUp, etc. events triggered by the user.
  • Messages: To handle messages sent from the client.

For notifications related to the lifetime of the RenderArea itself, see the ServiceListener class.

Typically the application will attach a listener to the RenderArea in the onInstantiatedRenderArea() method of its ServiceListener. But applications can also create a RenderArea explicitly and attach a listener.

A typical sequence of calls to this listener is:

Definition at line 83 of file RenderAreaListener.h.

Constructor & Destructor Documentation

◆ ~RenderAreaListener()

virtual RemoteViz::Rendering::RenderAreaListener::~RenderAreaListener ( )
virtual

Destructor.

Member Function Documentation

◆ onClosedConnection()

virtual void RemoteViz::Rendering::RenderAreaListener::onClosedConnection ( std::shared_ptr< RenderArea renderArea,
const std::string &  connectionId,
bool  aborted 
)
virtual

Triggered when a connection is closed.

Default behavior : Dispose the renderArea if all its connections are closed and the application does not have a reference to the renderArea. If the application has a reference, it can use RenderArea::isDisposed() to know the state.

Parameters
renderArea: the RenderArea
connectionId: ID identifying the connection
aborted: true if the network connection was closed unexpectedly by the client or has been lost.

◆ onInitializedConnection()

virtual void RemoteViz::Rendering::RenderAreaListener::onInitializedConnection ( std::shared_ptr< RenderArea renderArea,
std::shared_ptr< Connection sender,
std::shared_ptr< const FrameEncoders frameEncoders 
)
virtual

Triggered when the connection and the frame encoders are initialized successfully.

Use the FrameEncoders object to query which frame encoders will actually be used.

Parameters
renderArea: the RenderArea requested by the connection
sender: the Connection
frameEncoders: frame encoders that have been initialized by the connection

◆ onKeyDown()

virtual bool RemoteViz::Rendering::RenderAreaListener::onKeyDown ( std::shared_ptr< RenderArea renderArea,
std::shared_ptr< Connection sender,
int  x,
int  y,
const SoKeyboardEvent::Key key 
)
virtual

Triggered when a KeyDown event is received from the client.

Default behavior : Accept the event by returning true.

Parameters
renderArea: the RenderArea that will process the event
sender: the connection that sent the event
x: horizontal coordinate
y: vertical coordinate
key: pressed key
Returns
true to process the event, this will apply an SoHandleEventAction to the scene graph.
This return value does not have any effect when the ServiceSettings::INDEPENDENT_SERVICE mode is enabled.
If there are many listeners, the logical operator OR will be applied on all the returned value of listeners.
If there are no listeners to call, the event will be processed.

◆ onKeyUp()

virtual bool RemoteViz::Rendering::RenderAreaListener::onKeyUp ( std::shared_ptr< RenderArea renderArea,
std::shared_ptr< Connection sender,
int  x,
int  y,
const SoKeyboardEvent::Key key 
)
virtual

Triggered when a KeyUp event is received from the client.

Default behavior : accept the event by returning true.

Parameters
renderArea: the RenderArea that will process the event
sender: the connection that sent the event
x: horizontal coordinate
y: vertical coordinate
key: released key
Returns
true to process the event, this will apply an SoHandleEventAction to the scene graph.
This return value does not have any effect when the ServiceSettings::INDEPENDENT_SERVICE mode is enabled.
If there are many listeners, the logical operator OR will be applied on all the returned value of listeners.
If there are no listeners to call, the event will be processed.

◆ onMouseDoubleClick()

virtual bool RemoteViz::Rendering::RenderAreaListener::onMouseDoubleClick ( std::shared_ptr< RenderArea renderArea,
std::shared_ptr< Connection sender,
int  x,
int  y,
SoMouseButtonEvent::Button  button 
)
virtual

Triggered when a MouseDoubleClick event is received from the client.

Default behavior : Accept the event by returning true.

Parameters
renderArea: the RenderArea that will process the event
sender: the connection that sent the event
x: horizontal coordinate
y: vertical coordinate
button: The button that was pressed when the mouse event was fired.
Returns
true to process the event, this will apply an SoHandleEventAction to the scene graph.
This return value does not have any effect when the ServiceSettings::INDEPENDENT_SERVICE mode is enabled.
If there are many listeners, the logical operator OR will be applied on all the returned value of listeners.
If there are no listeners to call, the event will be processed.

◆ onMouseDown()

virtual bool RemoteViz::Rendering::RenderAreaListener::onMouseDown ( std::shared_ptr< RenderArea renderArea,
std::shared_ptr< Connection sender,
int  x,
int  y,
SoMouseButtonEvent::Button  button 
)
virtual

Triggered when a MouseDown event is received from the client.


Default behavior : Accept the event by returning true.

Parameters
renderArea: the RenderArea that will process the event
sender: the connection that sent the event
x: horizontal coordinate
y: vertical coordinate
button: The button that was pressed when the mouse event was fired.
Returns
true to process the event, this will apply an SoHandleEventAction to the scene graph.
This return value does not have any effect when the ServiceSettings::INDEPENDENT_SERVICE mode is enabled.
If there are many listeners, the logical operator OR will be applied on all the returned value of listeners.
If there are no listeners to call, the event will be processed.

◆ onMouseEnter()

virtual bool RemoteViz::Rendering::RenderAreaListener::onMouseEnter ( std::shared_ptr< RenderArea renderArea,
std::shared_ptr< Connection sender,
int  x,
int  y 
)
virtual

Triggered when a MouseEnter event is received from the client.

Default behavior : Accept the event by returning true.

Parameters
renderArea: the RenderArea that will process the event
sender: the connection that sent the event
x: horizontal coordinate
y: vertical coordinate
Returns
true to process the event, this will apply an SoHandleEventAction to the scene graph.
This return value does not have any effect when the ServiceSettings::INDEPENDENT_SERVICE mode is enabled.
If there are many listeners, the logical operator OR will be applied on all the returned value of listeners.
If there are no listeners to call, the event will be processed.

◆ onMouseLeave()

virtual bool RemoteViz::Rendering::RenderAreaListener::onMouseLeave ( std::shared_ptr< RenderArea renderArea,
std::shared_ptr< Connection sender,
int  x,
int  y 
)
virtual

Triggered when a MouseLeave event is received from the client.

Default behavior : Accept the event by returning true.

Parameters
renderArea: the RenderArea that will process the event
sender: the connection that sent the event
x: horizontal coordinate
y: vertical coordinate
Returns
true to process the event, this will apply an SoHandleEventAction to the scene graph.
This return value does not have any effect when the ServiceSettings::INDEPENDENT_SERVICE mode is enabled.
If there are many listeners, the logical operator OR will be applied on all the returned value of listeners.
If there are no listeners to call, the event will be processed.

◆ onMouseMove()

virtual bool RemoteViz::Rendering::RenderAreaListener::onMouseMove ( std::shared_ptr< RenderArea renderArea,
std::shared_ptr< Connection sender,
int  x,
int  y 
)
virtual

Triggered when a MouseMove event is received from the client.

Default behavior : Accept the event by returning true.

Parameters
renderArea: the RenderArea that will process the event
sender: the connection that sent the event
x: horizontal coordinate
y: vertical coordinate
Returns
true to process the event, this will apply an SoHandleEventAction to the scene graph.
This return value does not have any effect when the ServiceSettings::INDEPENDENT_SERVICE mode is enabled.
If there are many listeners, the logical operator OR will be applied on all the returned value of listeners.
If there are no listeners to call, the event will be processed.

◆ onMouseUp()

virtual bool RemoteViz::Rendering::RenderAreaListener::onMouseUp ( std::shared_ptr< RenderArea renderArea,
std::shared_ptr< Connection sender,
int  x,
int  y,
SoMouseButtonEvent::Button  button 
)
virtual

Triggered when a MouseUp event is received from the client.

Default behavior : Accept the event by returning true.

Parameters
renderArea: the RenderArea that will process the event
sender: the connection that sent the event
x: horizontal coordinate
y: vertical coordinate
button: The button that was pressed when the mouse event was fired.
Returns
true to process the event, this will apply an SoHandleEventAction to the scene graph.
This return value does not have any effect when the ServiceSettings::INDEPENDENT_SERVICE mode is enabled.
If there are many listeners, the logical operator OR will be applied on all the returned value of listeners.
If there are no listeners to call, the event will be processed.

◆ onMouseWheel()

virtual bool RemoteViz::Rendering::RenderAreaListener::onMouseWheel ( std::shared_ptr< RenderArea renderArea,
std::shared_ptr< Connection sender,
int  x,
int  y,
int  delta 
)
virtual

Triggered when a mouse wheel event (rotatation) is received from the client.

Default behavior : Accept the event by returning true.

Parameters
renderArea: the RenderArea that will process the event
sender: the connection that sent the event
x: horizontal coordinate
y: vertical coordinate
delta: abstract value which indicates how far the wheel turned
Returns
true to process the event, this will apply an SoHandleEventAction to the scene graph.
This return value does not have any effect when the ServiceSettings::INDEPENDENT_SERVICE mode is enabled.
If there are many listeners, the logical operator OR will be applied on all the returned value of listeners.
If there are no listeners to call, the event will be processed.

◆ onOpenedConnection()

virtual void RemoteViz::Rendering::RenderAreaListener::onOpenedConnection ( std::shared_ptr< RenderArea renderArea,
std::shared_ptr< Connection connection,
std::shared_ptr< FrameEncoders frameEncoders 
)
virtual

Triggered when a client connects to the RenderArea.

Use this method to set the encoding format for images sent to the client, using the frameEncoders parameter. The default is JPEG for interactive frames (i.e. while the user is interacting) and PNG for still frames. Video encoding (H264 or VP9) may provide better performance by reducing bandwidth requirements. Use the ConnectionSettings::isSupportedEncoders() method to query if the proposed encoders are available. If a requested frame encoder cannot be initialized, RenderAreaListener::onRefusedEncoder will be triggered. Otherwise, RenderAreaListener::onInitializedConnection will be triggered.

Parameters
renderArea: the RenderArea requested by the connection
connection: the Connection
frameEncoders: frame encoders for interactive and still frames
Supported pairs of frame encoders (still/interactive): JPEG/JPEG, PNG/JPEG, H264_NVENC/H264_NVENC, H264_OPENH264/H264_OPENH264, VP9_VPX/VP9_VPX
Default behavior: PNG/JPEG.

◆ onPostRender()

virtual void RemoteViz::Rendering::RenderAreaListener::onPostRender ( std::shared_ptr< RenderArea renderArea)
virtual

Triggered after a rendering is done.

Default behavior : Do nothing.

In the ServiceSettings::INDEPENDENT_SERVICE mode, this callback is never triggered.

Parameters
renderArea: the RenderArea that performed the rendering.

◆ onPreRender()

virtual bool RemoteViz::Rendering::RenderAreaListener::onPreRender ( std::shared_ptr< RenderArea renderArea,
bool &  clearWindow,
bool &  clearZbuffer 
)
virtual

Triggered before a rendering is done.

Default behavior : Do the rendering by returning true.

In the ServiceSettings::INDEPENDENT_SERVICE mode, this callback is never triggered.

Parameters
renderArea: the RenderArea that will perform the rendering.
clearWindow: if true, this clears the graphics window before rendering
clearZbuffer: if true, the z buffer will be cleared before rendering
Returns
false to abort the rendering.
If there are many listeners, the logical operator OR will be applied on all the returned value of listeners.
If there are no listeners to call, the rendering will be not aborted.

◆ onReceivedMessage() [1/2]

virtual void RemoteViz::Rendering::RenderAreaListener::onReceivedMessage ( std::shared_ptr< RenderArea renderArea,
std::shared_ptr< Connection sender,
const std::string &  message 
)
virtual

Triggered when a text message is received from a client.

Default behavior : do nothing

Parameters
renderArea: the RenderArea requested by the connection
sender: the Connection that receives the text message
message: the received message sent by the client

◆ onReceivedMessage() [2/2]

virtual void RemoteViz::Rendering::RenderAreaListener::onReceivedMessage ( std::shared_ptr< RenderArea renderArea,
std::shared_ptr< Connection sender,
const std::vector< unsigned char > &  buffer 
)
virtual

Triggered when a binary message is received from a client.

Default behavior : do nothing

Parameters
renderArea: the RenderArea
sender: the Connection that receives the binary message
buffer: the received binary buffer sent by the client

◆ onRefusedEncoder()

virtual void RemoteViz::Rendering::RenderAreaListener::onRefusedEncoder ( std::shared_ptr< RenderArea renderArea,
std::shared_ptr< Connection sender,
std::shared_ptr< FrameEncoders encoders 
)
virtual

Triggered when a frame encoder cannot be initialized.

If this case occurs, set another frame encoder. The status of encoders explains the reason for refusal.

Default behavior: Try to load other encoders automatically (fallback): H264_NVENC/H264_NVENC => VP9_VPX/VP9_VPX => H264_OPENH264/H264_OPENH264 => PNG/JPEG => JPEG/JPEG Fallback directly to JPEG/JPEG if the pair of frame encoders are incompatible. If none of frame encoders can be initialized, the connection will be closed.

Parameters
renderArea: the RenderArea of the Connection
sender: the connection that requests frame encoders
encoders: frame encoders refused by the connection

◆ onRequestedFrame()

virtual void RemoteViz::Rendering::RenderAreaListener::onRequestedFrame ( std::shared_ptr< RenderArea renderArea,
std::shared_ptr< Connection sender,
SbRasterImage rasterImage,
bool &  isInteractive 
)
virtual

Triggered when a new frame is requested by a connection.

This method only works when the ServiceSettings::INDEPENDENT_SERVICE mode is enabled.

To send a new frame to the client, set the pixel buffer of the raster image using a buffer object. If the buffer object of the raster image is NULL, no frame will be sent to the client. IMPORTANT: This callback is executed in a separate thread for each connection requesting a frame.

See also
ServiceSettings::setRunMode
Parameters
renderArea: the RenderArea of the Connection
sender: the connection that requests a new frame
rasterImage: contains the RGB raster image to render.
isInteractive: This value can be modified to indicate if an user interaction is in progress. Default value is true.
If true (interactive frame), the frame will be compressed with the interactive frame encoder and a quality adapted to the bandwidth setting.
If false (still frame), the frame will be compressed with the still frame encoder and the best available quality.

◆ onRequestedSize()

virtual void RemoteViz::Rendering::RenderAreaListener::onRequestedSize ( std::shared_ptr< RenderArea renderArea,
std::shared_ptr< Connection sender,
unsigned int  width,
unsigned int  height 
)
virtual

Triggered when a client requests a new renderArea size.

To resize the renderArea, call the method RenderArea::resize.
Default behavior : Resize the renderArea to the requested size.

See also
onResize, RenderArea::resize
Parameters
renderArea: the RenderArea of the Connection
sender: the connection that made the size request
width: requested width
height: requested height

◆ onResize()

virtual void RemoteViz::Rendering::RenderAreaListener::onResize ( std::shared_ptr< RenderArea renderArea,
unsigned int  width,
unsigned int  height 
)
virtual

Triggered when the renderArea is resized.

See RenderArea::resize(). Default behavior : Do nothing.

Parameters
renderArea: the resized RenderArea
width: new width of the renderArea
height: new height of the renderArea

◆ onSendingFrame()

virtual void RemoteViz::Rendering::RenderAreaListener::onSendingFrame ( std::shared_ptr< RenderArea renderArea,
std::shared_ptr< Connection sender,
std::string &  message 
)
virtual

Triggered before sending a frame to the client.

The sending frame can be retrieved using Connection::getLastEncodedFrame. IMPORTANT: This callback is executed in a separate thread for each connection sending a frame.

Parameters
renderArea: the RenderArea of the Connection
sender: the connection that will send the frame to the client
message: This value can be modified to attach a text message to the frame. Default value is an empty string. This message can be retrieved from the client listeners: onReceivedFrame and onDecodedFrame.

◆ onTouchEnd()

virtual bool RemoteViz::Rendering::RenderAreaListener::onTouchEnd ( std::shared_ptr< RenderArea renderArea,
std::shared_ptr< Connection sender,
unsigned int  id,
int  x,
int  y 
)
virtual

Triggered when a TouchEnd event is received from the client.

Default behavior : Accept the event by returning true.

Parameters
renderArea: the RenderArea that will process the event
sender: the connection that sent the event
id: touch identifier
x: horizontal coordinate
y: vertical coordinate
Returns
true to process the event, this will apply an SoHandleEventAction to the scene graph.
This return value does not have any effect when the ServiceSettings::INDEPENDENT_SERVICE mode is enabled.
If there are many listeners, the logical operator OR will be applied on all the returned value of listeners.
If there are no listeners to call, the event will be processed.

◆ onTouchMove()

virtual bool RemoteViz::Rendering::RenderAreaListener::onTouchMove ( std::shared_ptr< RenderArea renderArea,
std::shared_ptr< Connection sender,
unsigned int  id,
int  x,
int  y 
)
virtual

Triggered when a TouchMove event is received from the client.

Default behavior : Accept the event by returning true.

Parameters
renderArea: the RenderArea that will process the event
sender: the connection that sent the event
id: touch identifier
x: horizontal coordinate
y: vertical coordinate
Returns
true to process the event, this will apply an SoHandleEventAction to the scene graph.
This return value does not have any effect when the ServiceSettings::INDEPENDENT_SERVICE mode is enabled.
If there are many listeners, the logical operator OR will be applied on all the returned value of listeners.
If there are no listeners to call, the event will be processed.

◆ onTouchStart()

virtual bool RemoteViz::Rendering::RenderAreaListener::onTouchStart ( std::shared_ptr< RenderArea renderArea,
std::shared_ptr< Connection sender,
unsigned int  id,
int  x,
int  y 
)
virtual

Triggered when a TouchStart event is received from the client.

Default behavior : Accept the event by returning true.

Parameters
renderArea: the RenderArea that will process the event
sender: the connection that sent the event
id: touch identifier
x: horizontal coordinate
y: vertical coordinate
Returns
true to process the event, this will apply an SoHandleEventAction to the scene graph.
This return value does not have any effect when the ServiceSettings::INDEPENDENT_SERVICE mode is enabled.
If there are many listeners, the logical operator OR will be applied on all the returned value of listeners.
If there are no listeners to call, the event will be processed.

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