The AnnotationResultInterface also contains the application matrix to set for the given annotation view, and
of the course the AnnotationViewInterface to be added to the AnnotationRendererInterface for display.
/** * Sample to illustrate the use of an AnnotationGetterInterface to retrieve multiple annotation views. */ import { DataSessionInterface, IdCardGetterInterface, IdCardGetterInterfaceSignal, InfiniteEvent, PartInstanceInfoInterface, AnnotationViewInfoInterface, AnnotationGetterInterface, AnnotationGetterInterfaceSignal, AnnotationResultInterface, VisibilityContextInterface, } from'generated/documentation/appinfiniteapi';
// the DataSessionInterface has been created previously and is connected letlDataSession : DataSessionInterface; // created previously letlIdCardGetterInterface : IdCardGetterInterface; // created previously, the visibility context to use for the id card query letlVisibilityContext : VisibilityContextInterface; // the part instance id to fetch letlPartInstanceId : number;
// to retrieve the annotations constlAnnotationViewGetter : AnnotationGetterInterface = lDataSession.createAnnotationGetter();
// what to do when we have retrieved id card information ? letonIdCardReady : (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) =>void;
// what to do when annotation data has been downloaded ? letonAnnotationViewDownloaded : (_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 idcard data is available onIdCardReady = (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) : void=> { if (lIdCardGetterInterface.getLastError().length !== 0) { // do nothing in case of error // perhaps some GUI code ? } constlPartInstanceInfos : Array<PartInstanceInfoInterface> | undefined = lIdCardGetterInterface.getPartInstanceInfos(); if (!lPartInstanceInfos || lPartInstanceInfos.length !== 1) { // no data (isCancelled ?) return; } // get the first the instantiation chain constlCurrentChain : PartInstanceInfoInterface = lPartInstanceInfos[0]; // the annotation views that will be fetched constlAnnotationsToFetch : Array<AnnotationViewInfoInterface> = []; // iterate over the annotation views to retrieve all views at once constlAllAnnotationViews : Array<Array<AnnotationViewInfoInterface>> = lCurrentChain.getAnnotationViews(); // loops leti : number; letj : number; // number of annotation views for this instance letlNbAnnotationViews : number; // number of ancestors constlNbAncestors : number = lAllAnnotationViews.length; letlAnnotationViewsOfPartInstance :Array<AnnotationViewInfoInterface>; letlCurAnnotationView : AnnotationViewInfoInterface; for (i = 0; i < lNbAncestors; ++i) { lAnnotationViewsOfPartInstance = lAllAnnotationViews[i]; lNbAnnotationViews = lAnnotationViewsOfPartInstance.length; for (j = 0; j < lNbAnnotationViews; ++j) { lCurAnnotationView = lAnnotationViewsOfPartInstance[j]; // some fancy log console.log('Will fetch annotation view ' + lCurAnnotationView.getAnnotationViewName() + ' of type ' + lCurAnnotationView.getAnnotationViewTypeName() + ' with ' + lCurAnnotationView.getAnnotationViewAnnotationCount() + ' annotations'); // add the annotation view to be fetched lAnnotationsToFetch.push(lCurAnnotationView); } } // and download lAnnotationViewGetter.fetchAnnotationViews(lAnnotationsToFetch); }
// what to do when annotation data has been downloaded ? onAnnotationViewDownloaded = (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) : void=> { // annotation are ready constlAnnotationViewsContent : Array<AnnotationResultInterface> | undefined = lAnnotationViewGetter.getAnnotationViewsResult(); 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 constlCurAnnotationViewResult : AnnotationResultInterface = lAnnotationViewsContent[0]; console.log('display annotation view ' + lCurAnnotationViewResult.getAnnotationViewName() + ' (of type ' + lCurAnnotationViewResult.getAnnotationViewTypeName() + ')'); }
/** * Sample to illustrate the asynchronous use of an AnnotationGetterInterface to retrieve multiple annotation views. */ import { DataSessionInterface, IdCardGetterInterface, VisibilityContextInterface, AsyncResultReason, AsyncPartInstanceInfoResult, PartInstanceInfoInterface, AnnotationViewInfoInterface, AnnotationGetterInterface, AnnotationResultInterface, AsyncAnnotationResult } from'generated/documentation/appinfiniteapi';
// the DataSessionInterface has been created previously and is connected letlDataSession : DataSessionInterface; // created previously letlIdCardGetterInterface : IdCardGetterInterface; // created previously, the visibility context to use for the id card query letlVisibilityContext : VisibilityContextInterface; // the part instance id to fetch letlPartInstanceId : number;
// to retrieve the annotations constlAnnotationViewGetter : AnnotationGetterInterface = lDataSession.createAnnotationGetter();
// get the first the instantiation chain constlCurrentChain : PartInstanceInfoInterface = lIdCardRes.value[0]; // the annotation views that will be fetched constlAnnotationsToFetch : Array<AnnotationViewInfoInterface> = []; // iterate over the annotation views to retrieve all views at once constlAllAnnotationViews : Array<Array<AnnotationViewInfoInterface>> = lCurrentChain.getAnnotationViews(); // loops leti : number; letj : number; // number of annotation views for this instance letlNbAnnotationViews : number; // number of ancestors constlNbAncestors : number = lAllAnnotationViews.length; letlAnnotationViewsOfPartInstance :Array<AnnotationViewInfoInterface>; letlCurAnnotationView : AnnotationViewInfoInterface; for (i = 0; i < lNbAncestors; ++i) { lAnnotationViewsOfPartInstance = lAllAnnotationViews[i]; lNbAnnotationViews = lAnnotationViewsOfPartInstance.length; for (j = 0; j < lNbAnnotationViews; ++j) { lCurAnnotationView = lAnnotationViewsOfPartInstance[j]; // some fancy log console.log('Will fetch annotation view ' + lCurAnnotationView.getAnnotationViewName() + ' of type ' + lCurAnnotationView.getAnnotationViewTypeName() + ' with ' + lCurAnnotationView.getAnnotationViewAnnotationCount() + ' annotations'); // add the annotation view to be fetched lAnnotationsToFetch.push(lCurAnnotationView); } } // and download constlAnnotationContentResult : AsyncAnnotationResult = awaitlAnnotationViewGetter.asyncFetchAnnotationViews(lAnnotationsToFetch); // annotation are ready // const lAnnotationViewsContent : Array<AnnotationResultInterface> | undefined = lAnnotationViewGetter.getAnnotationViewsResult(); 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 constlCurAnnotationViewResult : AnnotationResultInterface = lAnnotationContentResult.value[0]; console.log('display annotation view ' + lCurAnnotationViewResult.getAnnotationViewName() + ' (of type ' + lCurAnnotationViewResult.getAnnotationViewTypeName() + ')'); }
fetchAnnotation();
Please see Annotations for more explanations about annotations.
The AnnotationResultInterface interface is the result of an annotation retrieval query from an AnnotationGetterInterface.
Its API is very similar to the AnnotationViewInfoInterface since it is the result of the fetchAnnotationViews of an AnnotationViewInfoInterface.
The AnnotationResultInterface also contains the application matrix to set for the given annotation view, and of the course the AnnotationViewInterface to be added to the AnnotationRendererInterface for display.
Or with async calls :
Please see Annotations for more explanations about annotations.
See