Interface AnnotationResultInterface

The AnnotationResultInterface interface is the result of an annotation retrieval query from an AnnotationGetterInterface.

Its API is very similar to the AnnotationGroupInfoInterface since it is the result of the AnnotationGetterInterface.fetchAnnotationGroups of an AnnotationGroupInfoInterface.

The AnnotationResultInterface also contains the application matrix to set for the given annotation views, and of course the AnnotationViewInterfaces to be added to the AnnotationRendererInterface for display. The application matrix is also set as default matrix for all AnnotationViewInterface (AnnotationViewInterface.getDefaultMatrix).

/** 
* Sample to illustrate the use of an AnnotationGetterInterface to retrieve multiple annotation views.
*/
import {
DataSessionInterface, IdCardGetterInterface, IdCardGetterInterfaceSignal, AnnotationGetterInterfaceSignal,
InfiniteEvent, PartInstanceInfoInterface, AnnotationGroupInfoInterface, AnnotationGetterInterface,
AnnotationResultInterface, AncestryInstanceMetadataInterface, WorkingSetInterface,
} from 'generated_files/documentation/appinfiniteapi';

// the DataSessionInterface has been created previously and is connected
let lDataSession : DataSessionInterface;
// created previously
let lIdCardGetterInterface : IdCardGetterInterface;
// created previously, the working set to use for the id card query
let lWorkingSet : WorkingSetInterface;
// the part instance id to fetch
let lPartInstanceId : number;

// to retrieve the annotations
const lAnnotationViewGetter : AnnotationGetterInterface = lDataSession.createAnnotationGetter();

// what to do when we have retrieved id card information ?
let onIdCardReady : (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) => void;

// what to do when annotation data has been downloaded ?
let onAnnotationViewDownloaded : (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) => void;

// what to do when id card is ready ?
lIdCardGetterInterface.addEventListener(IdCardGetterInterfaceSignal.IdCardReady, onIdCardReady);
// what to do when the download of the annotation view is ready ?
lAnnotationViewGetter.addEventListener(AnnotationGetterInterfaceSignal.AnnotationFetchReady, onAnnotationViewDownloaded);

// onIdCardReady will be called when id-card data is available
onIdCardReady = (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) : void =>
{
if (lIdCardGetterInterface.getLastError() !== undefined) {
// do nothing in case of error
// perhaps some GUI code ?
}
const lPartInstanceInfos : Array<PartInstanceInfoInterface> | undefined = lIdCardGetterInterface.getPartInstanceInfos();
if (!lPartInstanceInfos || lPartInstanceInfos.length !== 1)
{
// no data (isCancelled ?)
return;
}
// get the first the instantiation chain
const lCurrentChain : PartInstanceInfoInterface = lPartInstanceInfos[0];
// the annotation views that will be fetched
const lAnnotationsToFetch : Array<AnnotationGroupInfoInterface> = [];
// iterate over the metadata infos to retrieve all views at once
const lAllInstanceMetadata : Array<AncestryInstanceMetadataInterface> = lCurrentChain.getAncestorInstanceInfos();
// loops
let i : number;
let j : number;
// number of annotation views for this instance
let lNbAnnotationViews : number;
// number of ancestors
const lNbAncestors : number = lAllInstanceMetadata.length;
let lAnnotationViewsOfPartInstance :Array<AnnotationGroupInfoInterface>;
let lCurAnnotationView : AnnotationGroupInfoInterface;
for (i = 0; i < lNbAncestors; i += 1)
{
lAnnotationViewsOfPartInstance = lAllInstanceMetadata[i].getAnnotationGroups();
lNbAnnotationViews = lAnnotationViewsOfPartInstance.length;
for (j = 0; j < lNbAnnotationViews; j += 1)
{
lCurAnnotationView = lAnnotationViewsOfPartInstance[j];
// some fancy log
console.log('Will fetch annotation view ' + lCurAnnotationView.getGroupName() + ' of type ' + lCurAnnotationView.getGroupTypeName()
+ ' with ' + lCurAnnotationView.getAnnotationsCount() + ' annotations');
// add the annotation view to be fetched
lAnnotationsToFetch.push(lCurAnnotationView);
}
}
// and download
lAnnotationViewGetter.fetchAnnotationGroups(lAnnotationsToFetch);
};

// what to do when annotation data has been downloaded ?
onAnnotationViewDownloaded = (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) : void =>
{
// annotation are ready
const lAnnotationViewsContent : Array<AnnotationResultInterface> | undefined = lAnnotationViewGetter.getAnnotationGroupsResult();
if ((!lAnnotationViewsContent) || (lAnnotationViewsContent.length === 0))
{
console.log('error while fetching annotation content');
return;
}
// now annotation content is there, just need to display them
// use only the first view
const lCurAnnotationViewResult : AnnotationResultInterface = lAnnotationViewsContent[0];
console.log('display annotation view ' + lCurAnnotationViewResult.getGroupName() + ' (of type ' + lCurAnnotationViewResult.getGroupTypeName() + ')');
};

lIdCardGetterInterface.retrieveIdCard(lPartInstanceId, lWorkingSet);

Or with async calls :
/** 
* Sample to illustrate the asynchronous use of an AnnotationGetterInterface to retrieve multiple annotation views.
*/
import {
DataSessionInterface, IdCardGetterInterface, AsyncResultReason, AsyncPartInstanceInfoResult,
PartInstanceInfoInterface, AnnotationGroupInfoInterface, AnnotationGetterInterface, AnnotationResultInterface, AsyncAnnotationResult, AncestryInstanceMetadataInterface, WorkingSetInterface
} from 'generated_files/documentation/appinfiniteapi';

// the DataSessionInterface has been created previously and is connected
let lDataSession : DataSessionInterface;
// created previously
let lIdCardGetterInterface : IdCardGetterInterface;
// created previously, the working set to use for the id card query
let lWorkingSet : WorkingSetInterface;
// the part instance id to fetch
let lPartInstanceId : number;

// to retrieve the annotations
const lAnnotationViewGetter : AnnotationGetterInterface = lDataSession.createAnnotationGetter();

const fetchAnnotation = async () : Promise<void> =>
{
const lIdCardRes : AsyncPartInstanceInfoResult = await lIdCardGetterInterface.asyncRetrieveIdCard(lPartInstanceId, lWorkingSet);
if (!lIdCardRes.value || !lIdCardRes.value.length)
{
// display some fancy error message
return;
}
console.assert(lIdCardRes.reason === AsyncResultReason.ARR_Success);

// get the first the instantiation chain
const lCurrentChain : PartInstanceInfoInterface = lIdCardRes.value[0];
// the annotation views that will be fetched
const lAnnotationsToFetch : Array<AnnotationGroupInfoInterface> = [];
// iterate over the metadata infos to retrieve all views at once
const lAllInstanceMetadata : Array<AncestryInstanceMetadataInterface> = lCurrentChain.getAncestorInstanceInfos();
// loops
let i : number;
let j : number;
// number of annotation views for this instance
let lNbAnnotationViews : number;
// number of ancestors
const lNbAncestors : number = lAllInstanceMetadata.length;
let lAnnotationViewsOfPartInstance :Array<AnnotationGroupInfoInterface>;
let lCurAnnotationView : AnnotationGroupInfoInterface;
for (i = 0; i < lNbAncestors; i += 1)
{
lAnnotationViewsOfPartInstance = lAllInstanceMetadata[i].getAnnotationGroups();
lNbAnnotationViews = lAnnotationViewsOfPartInstance.length;
for (j = 0; j < lNbAnnotationViews; j += 1)
{
lCurAnnotationView = lAnnotationViewsOfPartInstance[j];
// some fancy log
console.log('Will fetch annotation view ' + lCurAnnotationView.getGroupName() + ' of type ' + lCurAnnotationView.getGroupTypeName()
+ ' with ' + lCurAnnotationView.getAnnotationsCount() + ' annotations');
// add the annotation view to be fetched
lAnnotationsToFetch.push(lCurAnnotationView);
}
}
// and download
const lAnnotationContentResult : AsyncAnnotationResult = await lAnnotationViewGetter.asyncFetchAnnotationGroups(lAnnotationsToFetch);
// annotation are ready
// const lAnnotationViewsContent : Array<AnnotationResultInterface> | undefined = lAnnotationViewGetter.getAnnotationGroupsResult();
if ((!lAnnotationContentResult.value) || (lAnnotationContentResult.value.length === 0))
{
console.log('error while fetching annotation content');
return;
}
// now annotation content is there, just need to display them
// use only the first view
const lCurAnnotationViewResult : AnnotationResultInterface = lAnnotationContentResult.value[0];
console.log('display annotation view ' + lCurAnnotationViewResult.getGroupName() + ' (of type ' + lCurAnnotationViewResult.getGroupTypeName() + ')');
};

fetchAnnotation();

Please see Annotations for more explanations about annotations.
Data Retrievers

interface AnnotationResultInterface {
    getAnnotationCaptures(): AnnotationCaptureInterface[];
    getAnnotationViews(): AnnotationViewInterface[];
    getAnnotationsCount(): number;
    getGroupMatrix(): Matrix4;
    getGroupName(): string;
    getGroupTypeName(): string;
}

Methods

  • Gets the application matrix of the annotation group.

    DO NOT modify the resulting Matrix4 in place, this results in undefined behavior.

    Returns Matrix4

    const
    the matrix of the given annotation view group.