/** * Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose * @author Joan Segura * @author Yana Rose * @author Sebastian Bittrich */ /** * Copyright (C) 2023, Protein Bioinformatics Research Group, RCNS * * Licensed under CC BY-NC 4.0, see LICENSE file for more info. * * @author Gabor Tusnady * @author Csongor Gerdan */ import { Viewer, ViewerProps } from '@rcsb/rcsb-molstar/build/src/viewer'; import { TmDetColorThemeProvider } from '../tmdet-extension/tmdet-color-theme'; import { MembraneOrientationPreset } from '../tmdet-extension/behavior'; import { TmDetLabelProvider } from '../tmdet-extension/labeling'; import { loadInitialSnapshot, rotateCamera, storeCameraSnapshot } from '../tmdet-extension/camera'; import { BuiltInTrajectoryFormat } from 'molstar/lib/mol-plugin-state/formats/trajectory'; import { PresetProps } from '@rcsb/rcsb-molstar/build/src/viewer/helpers/preset'; import { Mat4 } from 'molstar/lib/commonjs/mol-math/linear-algebra'; import { TrajectoryHierarchyPresetProvider } from 'molstar/lib/mol-plugin-state/builder/structure/hierarchy-preset'; export class TmViewer extends Viewer { constructor(elementOrId: string | HTMLElement, props: Partial = {}) { console.log("TmViewer constructor"); super(elementOrId, props); this.initBehavior(); } public async initBehavior() { let tree = this.plugin.state.behaviors.build(); this.plugin.builders.structure.representation.registerPreset(MembraneOrientationPreset); this.plugin.representation.structure.themes.colorThemeRegistry.add(TmDetColorThemeProvider); this.plugin.managers.lociLabels.addProvider(TmDetLabelProvider); await this.plugin.runTask(this.plugin.state.behaviors.updateTree(tree, { doNotUpdateCurrent: true, doNotLogTiming: true })); } loadStructureFromUrl(url: string, format: BuiltInTrajectoryFormat, isBinary: boolean, config?: { props?: PresetProps & { dataLabel?: string; }; matrix?: Mat4; reprProvider?: TrajectoryHierarchyPresetProvider; params?: P; }): Promise { this.plugin.canvas3dInitialized.then(() => { console.log('Camera initialization started', this.plugin.canvas3d?.camera) storeCameraSnapshot(this.plugin); // store if it is not stored yet loadInitialSnapshot(this.plugin); // load if there is a stored one // INVALID DATA CELL: setTimeout(() => { this.plugin.clear(); }, 100); // clear scene after some delay setTimeout(() => { (async () => { await rotateCamera(this.plugin); })(); }, 500); }); const result = super.loadStructureFromUrl(url, format, isBinary, config); return result; } }