1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- /**
- * Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
- *
- * @author Alexander Rose <alexander.rose@weirdbyte.de>
- * @author Joan Segura <joan.segura@rcsb.org>
- * @author Yana Rose <yana.rose@rcsb.org>
- * @author Sebastian Bittrich <sebastian.bittrich@rcsb.org>
- */
- /**
- * Copyright (C) 2023, Protein Bioinformatics Research Group, RCNS
- *
- * Licensed under CC BY-NC 4.0, see LICENSE file for more info.
- *
- * @author Gabor Tusnady <tusnady.gabor@ttk.hu>
- * @author Csongor Gerdan <gerdan.csongor@ttk.hu>
- */
- 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<ViewerProps> = {}) {
- 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<P, S>(url: string, format: BuiltInTrajectoryFormat, isBinary: boolean, config?: {
- props?: PresetProps & {
- dataLabel?: string;
- };
- matrix?: Mat4;
- reprProvider?: TrajectoryHierarchyPresetProvider<P, S>;
- params?: P;
- }): Promise<any> {
- 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;
- }
- }
|