Interface AnnotationViewInterface

The AnnotationViewInterface interface contains the annotations data of an annotation view.

Please see Annotations for more explanations about annotations.

The AnnotationViewInterface features a 3D plane (X axis, Y Axis, Normal, Origin) from which 2D data (texts, 2D shapes, images) are positioned. The AnnotationViewInterface represents a set of annotations (Functional Tolerancing and Annotations, Product Manufacturing Information, Measures, etc ...) placed in a 3D plane. AnnotationViewInterfaces should be included in the AnnotationRendererInterface.

The AnnotationViewInterface is retrieved from an AnnotationResultInterface that was fetched from an AnnotationGetterInterface.

Below is some code to retrieve an AnnotationViewInterface from an id card request.

/** 
* 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();

Once retrieved, an AnnotationViewInterface may be included in an AnnotationRendererInterface to 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
};

Or asynchronously :
/** 
* Sample to illustrate the asynchronous displaying of annotations.
*/
import {
AnnotationGetterInterface,
AnnotationResultInterface, AnnotationGroupInfoInterface, InfiniteEngineInterface, AnnotationRendererInterface,
tAnnotationViewId, AnnotationInstanceState, AnnotationViewParsingResultInterface, AsyncAnnotationResult, AsyncResultReason,
AnnotationViewInterface,
AsyncAnnotationViewParsingResult
} 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 to fetch
let lAnnotationToFetch : AnnotationGroupInfoInterface;

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

const displayResult = async () : Promise<void> =>
{
const lAsyncAnnotationResult : AsyncAnnotationResult = await lAnnotationViewGetter.asyncFetchAnnotationGroups(lAnnotationToFetch);

// the result of the download
const lAnnotationViewsContent : Array<AnnotationResultInterface> | undefined = lAsyncAnnotationResult.value;
if (!lAnnotationViewsContent || (lAnnotationViewsContent.length === 0))
{
console.log('Weird, annotation download error');
return;
}
if (lAnnotationViewsContent.length > 1)
{
console.log('Weird, annotation is downloaded but too many results');
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
let lMask : number = AnnotationInstanceState.AIS_DepthPriorityMask | AnnotationInstanceState.AIS_Visible;
let lState : number = AnnotationInstanceState.AIS_DepthPriorityStd;
const lAnnotationViews : Array<AnnotationViewInterface> = lAnnotationResult.getAnnotationViews();
if(lAnnotationViews.length === 0)
{
console.log('Weird, annotation is downloaded but no result');
return;
}
const lAnnotationParsingResult : AsyncAnnotationViewParsingResult = await lAnnotationRenderer.asyncAddAnnotationView(lAnnotationViews[0], lAnnotationResult.getGroupMatrix(), lMask, lState);

if (lAnnotationParsingResult.reason !== AsyncResultReason.ARR_Success
|| lAnnotationParsingResult.value === undefined)
{
// weird error
console.log('The parsing procedure could not be started');
return;
}
// fancy log
console.log('annotation view has finished parsing');

// take the parsing result
const lParsingResult : AnnotationViewParsingResultInterface = lAnnotationParsingResult.value;
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)
lMask = 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)
lState = AnnotationInstanceState.AIS_Visible; // | AnnotationInstanceState.AIS_AppearThroughGeometry

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

displayResult();

Please make sure the destination browser supports promises before using async calls.
3D Rendering

interface AnnotationViewInterface {
    getAnnotationIds(pAnnotationIds): boolean;
    getAnnotationNames(pAnnotationNames): boolean;
    getAnnotationViewName(): string;
    getAnnotationsCount(): number;
    getDefaultMatrix(): Matrix4;
    getFirstAnnotationId(): number;
    getPlaneNormal(pPlaneNormal?): Vector3;
    getPlaneOrigin(pPlaneOrigin?): Vector3;
    getPlaneXAxis(pPlaneXAxis?): Vector3;
    getPlaneYAxis(pPlaneYAxis?): Vector3;
    getViewId(): number;
    toJSON(pKey?): Object;
}

Methods

  • Gets all the annotation ids contained in this view.

    Annotations in this view range from [getFirstAnnotationId, ..., getAnnotationsCount - 1].

    Parameters

    • pAnnotationIds: number[]
      out
      The resulting annotation ids.

    Returns boolean

    true if the call was successful.

  • Gets all the annotation names contained in this view.

    Returns true if pAnnotationNames is of the correct type.

    Parameters

    • pAnnotationNames: string[]
      out
      The resulting annotation names.

    Returns boolean

    trueif the call went well.

  • Gets the annotation view name.

    Returns string

    The annotation view name.

  • Gets the annotation id of the first annotation contained in this view.

    Annotations in this view range from [getFirstAnnotationId, ..., getAnnotationsCount - 1].

    Returns number

    The annotation id of the first annotation in this annotation view.

  • An AnnotationViewInterface is defined as a plane.

    The plane normal is the normal to the plane of this AnnotationViewInterface (unit length).

    If pPlaneNormal is omitted, then a new Vector3 is allocated.

    NB : getPlaneNormal = cross(getPlaneXAxis, getPlaneYAxis).

    Parameters

    • Optional pPlaneNormal: Vector3
      out
      The optional normal of the plane of the AnnotationViewInterface.

    Returns Vector3

    pPlaneNormal.

  • Gets the origin of the annotation view in the annotation frame.

    If pPlaneOrigin is omitted, then a new Vector3 is allocated.

    Parameters

    • Optional pPlaneOrigin: Vector3
      out
      The optional 3D point from which any annotation data is calculated.

    Returns Vector3

    pPlaneOrigin.

  • An AnnotationViewInterface is defined as a plane.

    The pPlaneXAxis is the directional unit vector in the annotation view to the right of the annotation view. This is usually the direction of the text contained inside any annotation of this AnnotationViewInterface.

    If pPlaneXAxis is omitted, then a new Vector3 is allocated.

    NB : getPlaneXAxis = cross(getPlaneYAxis, getPlaneNormal).

    Parameters

    • Optional pPlaneXAxis: Vector3
      out
      The optional right vector of the plane of the AnnotationViewInterface.

    Returns Vector3

    pPlaneXAxis.

  • An AnnotationViewInterface is defined as a plane.

    The pPlaneYAxis is the directional unit vector in the annotation view to the up of the annotation view. This is usually the direction of the height of the text contained inside any annotation of this AnnotationViewInterface.

    If pPlaneYAxis is omitted, then a new Vector3 is allocated.

    NB : pPlaneYAxis = cross(getPlaneNormal, getPlaneXAxis).

    Parameters

    • Optional pPlaneYAxis: Vector3
      out
      The optional up vector of the plane of the AnnotationViewInterface.

    Returns Vector3

    pPlaneYAxis.

  • Gets the view id of the annotation view.

    Returns number

    The view id of the annotation view.