Interface AnnotationViewParsingResultInterface

The AnnotationViewParsingResultInterface is the attachment of the AnnotationRendererInterfaceSignal.AnnotationViewParsed signal sent by the AnnotationRendererInterface when new annotations are available. The AnnotationRendererInterfaceSignal is sent after a call to AnnotationRendererInterface.addAnnotationView.

This object stores information about the annotation view that was parsed : i.e. the annotations that were included inside it.

Each annotation is assigned an id (tAnnotationId), from AnnotationViewInterface.getFirstAnnotationId to AnnotationViewInterface.getFirstAnnotationId + AnnotationViewInterface.getAnnotationsCount - 1 inclusive, and the added AnnotationViewInterface that was included in the AnnotationRendererInterface is also available (annotationView).

A valid id (annotation or view id) is a strictly positive number (0 is invalid). The requestId is the value that was returned by the successful call to AnnotationRendererInterface.addAnnotationView.

In case of error, error is set with the reason for the error.

The warnings field tells if some values were not handled correctly, but the AnnotationViewInterface can still be displayed.

/** 
* Sample to illustrate the displaying of annotations.
*/
import {
AnnotationGetterInterface, AnnotationGetterInterfaceSignal, InfiniteEvent,
AnnotationResultInterface, InfiniteEngineInterface, AnnotationRendererInterface, AnnotationRendererInterfaceSignal,
tAnnotationViewId, AnnotationInstanceState, AnnotationViewParsingResultInterface, AnnotationViewInterface
} from 'generated_files/documentation/appinfiniteapi';

// created previously
let lAnnotationViewGetter : AnnotationGetterInterface;
// created previously
let lInfiniteEngine : InfiniteEngineInterface;
// retrieve the annotation renderer
const lAnnotationRenderer : AnnotationRendererInterface = lInfiniteEngine.getAnnotationRenderer();

// the annotation view id that has just been parsed
let lAnnotationViewId : tAnnotationViewId = -1;

// what to do when an annotation has been downloaded ?
let onAnnotationRetrieved : (pEvent: InfiniteEvent, pCallbackData: Object | undefined) => void;

// what to do when an annotation is ready to be displayed ?
let onAnnotationReady : (pEvent: InfiniteEvent, pCallbackData: Object | undefined) => void;

// connect to signals
lAnnotationViewGetter.addEventListener(AnnotationGetterInterfaceSignal.AnnotationFetchReady, onAnnotationRetrieved);
lAnnotationRenderer.addEventListener(AnnotationRendererInterfaceSignal.AnnotationViewParsed, onAnnotationReady);

// what to do when an annotation has been downloaded ?
onAnnotationRetrieved = (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) : void =>
{
// the result of the download
const lAnnotationViewsContent : Array<AnnotationResultInterface> | undefined = lAnnotationViewGetter.getAnnotationGroupsResult();
if (!lAnnotationViewsContent || (lAnnotationViewsContent.length === 0))
{
console.log('Weird, annotation is downloaded but no content');
return;
}
if (lAnnotationViewsContent.length > 1)
{
console.log('Only displaying one annotation view at the moment, other annotation views will be discarded');
return;
}
// take the first annotation result, discarding others
const lAnnotationResult : AnnotationResultInterface = lAnnotationViewsContent[0];

// and add the annotation view to be displayed with standard depth
// we want to set the depth and visible state of the annotation
// mask is AnnotationInstanceState.AIS_DepthPriorityMask | AnnotationInstanceState.AIS_Visible
// but we want to be depth std and invisible
// state is AnnotationInstanceState.AIS_DepthPriorityStd | 0 = AnnotationInstanceState.AIS_DepthPriorityStd
const lAnnotationViews : Array<AnnotationViewInterface> = lAnnotationResult.getAnnotationViews();
if(lAnnotationViews.length === 0)
{
console.log('Weird, annotation is downloaded but no result');
return;
}
const lMask : number = AnnotationInstanceState.AIS_DepthPriorityMask | AnnotationInstanceState.AIS_Visible;
const lState : number = AnnotationInstanceState.AIS_DepthPriorityStd;
const lRequestId : number = lAnnotationRenderer.addAnnotationView(lAnnotationViews[0], lAnnotationResult.getGroupMatrix(), lMask, lState);
if (lRequestId < 0)
{
// weird error
console.log('The parsing procedure could not be started');
}
};

// what to do when an annotation is ready to be displayed ?
onAnnotationReady = (pEvent: InfiniteEvent, _pCallbackData: Object | undefined) : void =>
{
// fancy log
console.log('annotation view has finished parsing');

// take the parsing result
const lParsingResult : AnnotationViewParsingResultInterface = pEvent.attachments;
if (lParsingResult.annotationView === undefined)
{
// this is an error
console.log('annotation view parsing has failed ' + JSON.stringify(lParsingResult.error));
return;
}

// store the annotation view id
lAnnotationViewId = lParsingResult.annotationView.getViewId();
const lNbAnnotations : number = lParsingResult.annotationView.getAnnotationsCount();
const lAnnotationStartId : number = lParsingResult.annotationView.getFirstAnnotationId();
// create the list of annotation ids from lParsingResult.annotationIdStart to lParsingResult.annotationIdStart + lParsingResult.nbAnnotations - 1
const lAnnotationIds : number [] = [];
lAnnotationIds.length = lNbAnnotations;
let i : number;
for (i = 0; i < lNbAnnotations; i += 1)
{
lAnnotationIds[i] = lAnnotationStartId + i;
}
// mask for all rendering flags (except priority)
const lMask : number = AnnotationInstanceState.AIS_AppearThroughGeometry | AnnotationInstanceState.AIS_Highlight
| AnnotationInstanceState.AIS_Overprint | AnnotationInstanceState.AIS_Visible;
// state is visible (but we may add AnnotationInstanceState.AIS_AppearThroughGeometry just for fun)
const lState : number = AnnotationInstanceState.AIS_Visible; // | AnnotationInstanceState.AIS_AppearThroughGeometry

lAnnotationRenderer.setAnnotationRenderingState(lAnnotationIds, lMask, lState);
// you should now see the annotation on the next rendering
};

Please see Annotations for more explanations about annotations.
Events

interface AnnotationViewParsingResultInterface {
    annotationView: AnnotationViewInterface;
    error: InfiniteError;
    requestId: number;
    warnings: string[];
}

Properties

annotationView: AnnotationViewInterface

The annotation view as set with AnnotationRendererInterface.addAnnotationView.

An error if relevant (or undefined if no error).

requestId: number

The non zero request id that was returned by the call to AnnotationRendererInterface.addAnnotationView.

warnings: string[]

Warning messages. If some content was not handled, warnings are there.