ShapeDiver Viewer - State API
The state interface is part of the global API.
It allows to
- get an overview of the current state of the viewer instance,
 - influence the state of the viewer instance and its visual representation,
 - add and remove listeners for related events.
 
Methods
- 
    
addEventListener(type, callback)
 - 
    
    
Add a callback to be invoked when a certain event occurs
Parameters:
Name Type Description typeStateEventType Type of event to subscribe to
callbackEventListenerCallback Function to be called when the event fires
Returns:
- 
            
Type Description APIResponse APIResponse with an EventListenerToken object. The event listener token can be used to remove the event listener by calling removeEventListener.
 
 - 
            
 - 
    
get()
 - 
    
    
Retrieve the current state of the viewer
Returns:
- 
            
Type Description APIResponse API response with data of type ViewerAppState. Description of the current state of the viewer application.
 
 - 
            
 - 
    
removeEventListener(token)
 - 
    
    
Remove an event listener
Parameters:
Name Type Description tokenEventListenerToken event listener token for event listener to be removed
Returns:
- 
            
Type Description APIResponse APIResponse with a Boolean data, indicating whether the event listener could be removed.
 
 - 
            
 - 
    
setBusy(busy [, progress])
 - 
    
    
Register the API as a busy process of the viewer app
Parameters:
Name Type Argument Description busyBoolean If true, a busy process will be registered, causing the viewer app to enter busy mode. If false and a busy process of the API had been registered before, it will be removed.
progressNumber <optional> 
Set the percentage of completion in interval [0,1]. If progress bars are displayed, this will influence them.
Returns:
- 
            
Type Description APIResponse API response with data of type ViewerAppState. Description of the current state of the viewer application.
 
 - 
            
 
Members
- 
    
<readonly> EVENTTYPE
 - 
    
    
Enum for supported state event types.
Properties:
Name Type Default Description BUSYbusy The viewer has entered busy state, which means at least one update process is currently going on.
IDLEidle The viewer has entered idle state, which means there are no more update processes going on.
MESSAGEmessage a message which may be displayed to the user
FAILEDfailed a message reporting a fatal error, e.g. the WebGL context was lost and could not be recovered
 
Type Definitions
- 
    
StateEventType
 - 
    
    
Status event type, see EVENTTYPE for values
Type:
- String
 
 - 
    
ViewerAppState
 - 
    
    
Viewer state description
Type:
- Object
 
Properties:
Name Type Description busyBoolean true if the viewer is in busy mode, false if the viewer is in idle mode
progressNumber minimum progress of all processes currently reporting a progress, interval [0,1]
processesObject.<String, Object> List of currently active processes
failedStatusMessagesArray array of status messages corresponding to fatal errors