Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function renderAsync(vp: ScreenViewport, numFrames: number, timings: Array>): Promise {
IModelApp.viewManager.addViewport(vp);
const target = vp.target as Target;
const metrics = target.performanceMetrics!;
target.performanceMetrics = undefined;
const numFramesToIgnore = 120;
let ignoreFrameCount = 0;
let frameCount = 0;
vp.continuousRendering = true;
return new Promise((resolve: () => void, _reject) => {
const timer = new StopWatch();
const removeListener = vp.onRender.addListener((_) => {
// Ignore the first N frames - they seem to have more variable frame rate.
++ignoreFrameCount;
if (ignoreFrameCount <= numFramesToIgnore) {
if (ignoreFrameCount === numFramesToIgnore) {
public run(_args: any[]): boolean {
const vp = IModelApp.viewManager.selectedView;
if (undefined !== vp)
emulateVersionComparison(vp); // tslint:disable-line:no-floating-promises
return true;
}
}
}
IModelApp.toolAdmin.markupView = undefined;
this.markup.destroy();
this.markup = undefined;
IModelApp.toolAdmin.defaultToolId = this._saveDefaultToolId;
IModelApp.toolAdmin.defaultToolArgs = this._saveDefaultToolArgs;
this._saveDefaultToolId = "";
this._saveDefaultToolArgs = undefined;
IModelApp.toolAdmin.startDefaultTool();
return;
}
await this.markupNamespace.readFinished; // make sure our localized messages are ready.
const view = IModelApp.toolAdmin.markupView = IModelApp.viewManager.selectedView;
if (view) {
this.markup = new Markup(view);
this._saveDefaultToolId = IModelApp.toolAdmin.defaultToolId;
this._saveDefaultToolArgs = IModelApp.toolAdmin.defaultToolArgs;
IModelApp.toolAdmin.defaultToolId = "Markup.Select";
IModelApp.toolAdmin.defaultToolArgs = undefined;
IModelApp.toolAdmin.startDefaultTool();
}
}
public onExecute(_args: string[]): void {
const selectedView: ScreenViewport | undefined = IModelApp.viewManager.selectedView;
if (undefined === selectedView)
return;
if (undefined === this._graphicsProvider)
this._graphicsProvider = new WMSGraphicsProvider(selectedView.iModel, this);
// Register our provider to supply tiles into the selected viewport (if not already registered)
selectedView.addTiledGraphicsProvider(this._graphicsProvider);
// For demonstration purposes, switch the imagery type each time the plugin is loaded.
this._currentImageryType = (WMSImageryType.Temperature === this._currentImageryType) ? WMSImageryType.Precipitation : WMSImageryType.Temperature;
// Output a message indicating the current imagery type.
const weatherType = (WMSImageryType.Temperature === this._currentImageryType) ? "temperature" : "precipitation";
this._i18NNamespace!.readFinished.then(() => {
const message: string = this.i18n.translate("WmsPlugin:Messages.DisplayType", { weatherType });
private async saveSettings(): Promise {
const view = IModelApp.viewManager.selectedView;
if (!view || !view.iModel)
return;
// store settings to SettingsManager
const geoPhotos: GeoPhotos = (view.iModel as any).geoPhotos;
if (geoPhotos && geoPhotos.photoTree) {
const newSettings: GeoPhotoFullSettings = new GeoPhotoFullSettings();
const fullSettings = Object.assign(newSettings, this.settings);
fullSettings.getPathList(geoPhotos.photoTree);
const requestContext = await AuthorizedFrontendRequestContext.create();
IModelApp.settings.saveUserSetting(requestContext, fullSettings, "GeoPhotoPlugin", "Settings", false, view.iModel.iModelToken.contextId, view.iModel.iModelToken.iModelId).catch((_err) => { });
}
}
private _handleCubeRotationChangeEvent = (args: CubeRotationChangeEventArgs) => {
const viewManager = this.props.viewManagerOverride ? this.props.viewManagerOverride : /* istanbul ignore next */ IModelApp.viewManager;
/* istanbul ignore else */
if (this._vp && viewManager.selectedView === this._vp) {
const rotMatrix = args.rotMatrix;
/* istanbul ignore else */
if (this._vp.rotation !== rotMatrix) {
const inverse = rotMatrix.transpose(); // rotation is from current nav cube state...
const center = this._getRotatePoint(this._vp);
const targetMatrix = inverse.multiplyMatrixMatrix(this._vp.view.getRotation());
const worldTransform = Transform.createFixedPointAndMatrix(center, targetMatrix);
const frustum = this._vp.getWorldFrustum();
frustum.multiply(worldTransform);
this._vp.view.setupFromFrustum(frustum);
this._vp.synchWithView(args.complete ? true : false);
}
public async updateCategoriesState() {
if (!IModelApp.viewManager)
return;
const vp = IModelApp.viewManager.selectedView;
if (vp)
this._updateCategoriesWithViewport(vp); // tslint:disable-line:no-floating-promises
}
`${tPosX}, ${tPosY}, 0, 1)`;
const isAnimating = animation !== 1 && !startMapExtents.isExactEqual(mapExtents);
if (mode === MapMode.Opened || isAnimating) {
rootStyle.position = "fixed";
rootStyle.right = window.innerWidth - this._rootOffset.right;
rootStyle.top = this._rootOffset.top;
}
const halfExtents = extents.scale(.5);
const offset = rotateMinimapWithView || is3D ? Vector3d.createZero() : rotation.multiplyTransposeVector(halfExtents).minus(halfExtents);
const unrotateLabel = UiFramework.translate("drawing.unrotate");
const e = sz.scale(1 / dz);
const halfMapExtents = e.scale(.5);
const mapOffset = rotateMinimapWithView || is3D ? rotation.multiplyTransposeVector(halfMapExtents) : halfMapExtents;
const viewManager = this.props.viewManagerOverride ? this.props.viewManagerOverride : /* istanbul ignore next */ IModelApp.viewManager;
const screenViewport = this.props.screenViewportOverride ? this.props.screenViewportOverride : /* istanbul ignore next */ ScreenViewport;
const nodes = (
<div style="{rootStyle}" data-testid="drawing-navigation-aid">
<div data-testid="drawing-container">
</div></div>
execute: async () => {
const vp = IModelApp.viewManager.selectedView;
if (!vp)
return;
await SelectionContextUtilities.isolateSelectedElementsCategory(vp);
},
});
.then(() => {
if (IModelApp.viewManager)
IModelApp.viewManager.setSelectedView(me.viewport);
});
}