Class RenderArea
- java.lang.Object
-
- com.openinventor.inventor.Inventor
-
- com.openinventor.remoteviz.rendering.RenderArea
-
public class RenderArea extends Inventor
Defines the rendering area for Open Inventor rendering. Implement the classRenderAreaListener
to receiveRenderArea
events.When using
ServiceSettings.INVENTOR_SERVICE
orServiceSettings.INVENTOR_APPLICATION
service mode, this class provides access to the scene manager and the touch manager to modify the rendering.A
RenderArea
object may be created automatically by RemoteViz or created explicitly by the application. When a client requests a connection (see RemoteVizRenderArea.connectTo()), it specifies a render area id. If a render area with that id does not exist, RemoteViz will create one and ServiceListener.onPendingCreateRenderArea() will be called. If a render area with the requested id exists, RemoteViz will use that one andServiceListener.onPendingShareRenderArea()
will be called. An application might want to explicitly create a render area, for example, to preload a default scene graph.A
RenderArea
may have zero, one or multiple connections.A
RenderArea
allows the application to send text or binary messages to the associated client. A JavaScript client will receive the message using a listener (see RemoteVizRenderArea.addServiceListener). Messages from a client are received using one of theRenderAreaListener.onReceivedMessage()
methods.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.openinventor.inventor.Inventor
Inventor.ConstructorCommand
-
-
Field Summary
-
Fields inherited from class com.openinventor.inventor.Inventor
VERBOSE_LEVEL, ZeroHandle
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(RenderAreaListener listener)
Adds aRenderAreaListener
to manage the renderArea.void
closeConnectionsAndDispose()
Closes all connections of the renderArea and disposes it.Connection
getConnection(int index)
Gets an existingConnection
to the renderArea.Connection
getConnection(java.lang.String id)
Gets an existingConnection
to the renderArea.SoGLContext
getGLContext()
Gets the OpenGL context associated with the renderArea.java.lang.String
getGpu()
Gets the Graphics Processing Unit (GPU) used to render images.int
getHeight()
Gets the renderArea height.java.lang.String
getId()
Gets the renderArea id.int
getNumConnections()
Gets the number of connections (seeConnection
) that exist for this renderArea.int
getNumListeners()
Gets the number ofRenderAreaListener
.SoSceneManager
getSceneManager()
Gets the Open Inventor scene manager associated with the renderArea.SoTouchManager
getTouchManager()
Gets the Open Inventor touch manager associated with the renderArea.int
getWidth()
Gets the renderArea width.boolean
isDisposed()
Gets the state of theRenderArea
: alive or disposed.void
removeAllListeners()
Removes all RenderAreaListeners.void
removeListener(RenderAreaListener listener)
Removes aRenderAreaListener
.void
resize(int width, int height)
Resizes the renderArea at a specific size.boolean
sendMessage(java.lang.String message)
Calls sendMessage(message, new java.util.ArrayList<>()).boolean
sendMessage(java.lang.String message, java.util.Collection<Connection> excludedConnections)
Sends a text message to the renderArea connections.boolean
sendMessage(java.util.Collection<java.lang.Byte> buffer)
Calls sendMessage(buffer, new java.util.ArrayList<>()).boolean
sendMessage(java.util.Collection<java.lang.Byte> buffer, java.util.Collection<Connection> excludedConnections)
Sends a binary message to the renderArea connections.void
setFrameMessage(java.lang.String message)
Sets the message which will be associate with the next rendered frames.-
Methods inherited from class com.openinventor.inventor.Inventor
dispose, getNativeResourceHandle
-
-
-
-
Method Detail
-
sendMessage
public boolean sendMessage(java.util.Collection<java.lang.Byte> buffer)
Calls sendMessage(buffer, new java.util.ArrayList<>()).
-
sendMessage
public boolean sendMessage(java.lang.String message)
Calls sendMessage(message, new java.util.ArrayList<>()).
-
getConnection
public Connection getConnection(java.lang.String id)
Gets an existingConnection
to the renderArea.- Parameters:
id
- : ID identifying theConnection
- Returns:
- the connection object if the id exists, otherwise returns null.
-
getGpu
public java.lang.String getGpu()
Gets the Graphics Processing Unit (GPU) used to render images. GPU can be defined in ServiceListener.onPendingCreateRenderArea.- Returns:
- gpu used to compute the render.
- See Also:
RenderAreaHardware.setGpu
-
getConnection
public Connection getConnection(int index)
Gets an existingConnection
to the renderArea.- Parameters:
index
- : index identifying theConnection
- Returns:
- the connection object if the index exists, otherwise returns null.
-
setFrameMessage
public void setFrameMessage(java.lang.String message)
Sets the message which will be associate with the next rendered frames. This message can be recovered on aEncodedFrame
.
-
getHeight
public int getHeight()
Gets the renderArea height.- Returns:
- the renderArea height
-
isDisposed
public boolean isDisposed()
Gets the state of theRenderArea
: alive or disposed. RemoteViz does not keep a reference to theRenderArea
object after the object is disposed. If the application kept a reference to the object, this method can be used to query its state.The state "disposed" will be set just after triggering the listener
ServiceListener.onDisposingRenderArea
.- Returns:
- true if the renderArea is disposed or false if the renderArea is alive.
-
getId
public java.lang.String getId()
Gets the renderArea id.- Returns:
- the ID identifying the renderArea
-
getNumListeners
public int getNumListeners()
Gets the number ofRenderAreaListener
.- Returns:
- number of
RenderAreaListener
.
-
sendMessage
public boolean sendMessage(java.lang.String message, java.util.Collection<Connection> excludedConnections)
Sends a text message to the renderArea connections.- Parameters:
message
- : the message to be sent to all connections of the renderAreaexcludedConnections
- : an excluded connections array- Returns:
- true if the message has been successfully sent to all connections, otherwise returns false.
-
closeConnectionsAndDispose
public void closeConnectionsAndDispose()
Closes all connections of the renderArea and disposes it. If connections are still open, this method will close them and dispose the renderArea. While executing this method, the listenersServiceListener.onDisposingRenderArea
andServiceListener.onDisposedRenderArea
will be triggered and a DISPOSED disconnect message will be sent to all clients of the renderArea. The listenerRenderAreaListener.onClosedConnection
will not be triggered after closing connections.See
isDisposed()
.
-
getGLContext
public SoGLContext getGLContext()
Gets the OpenGL context associated with the renderArea. This object is created automatically by RemoteViz.In the
ServiceSettings.INDEPENDENT_SERVICE
mode, this method returns null.- Returns:
- the OpenGL context
-
getWidth
public int getWidth()
Gets the renderArea width.- Returns:
- the renderArea width
-
sendMessage
public boolean sendMessage(java.util.Collection<java.lang.Byte> buffer, java.util.Collection<Connection> excludedConnections)
Sends a binary message to the renderArea connections.- Parameters:
buffer
- : the binary buffer to be sent to all connections of the renderAreaexcludedConnections
- : an excluded connections array- Returns:
- true if the message has been successfully sent to all connections, otherwise returns false.
-
resize
public void resize(int width, int height)
Resizes the renderArea at a specific size. After resizing, a notification will be sent to all the renderArea clients. The minimum size is (128, 128) and the maximum size is (3840, 2160). If the size is inferior or superior to the limit, it will be adjusted automatically.- Parameters:
width
- : new width of the renderAreaheight
- : new height of the renderArea- See Also:
RenderAreaListener.onResize
-
getSceneManager
public SoSceneManager getSceneManager()
Gets the Open Inventor scene manager associated with the renderArea. This object is created automatically by RemoteViz.In the
ServiceSettings.INDEPENDENT_SERVICE
mode, this method returns null.- Returns:
- the sceneManager
-
removeAllListeners
public void removeAllListeners()
Removes all RenderAreaListeners.
-
getNumConnections
public int getNumConnections()
Gets the number of connections (seeConnection
) that exist for this renderArea.- Returns:
- the number of connections
-
addListener
public void addListener(RenderAreaListener listener)
Adds aRenderAreaListener
to manage the renderArea.- Parameters:
listener
- : object that listens to the renderArea events
-
getTouchManager
public SoTouchManager getTouchManager()
Gets the Open Inventor touch manager associated with the renderArea. This object is created automatically by RemoteViz.In the
ServiceSettings.INDEPENDENT_SERVICE
mode, this method returns null.- Returns:
- the touchManager
-
removeListener
public void removeListener(RenderAreaListener listener)
Removes aRenderAreaListener
.- Parameters:
listener
- : object that listens to the renderArea events
-
-