123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- /**
- * Copyright (C) 2022, 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 { TMDETMembraneOrientation } from '../../extensions/tmdet/behavior';
- import { createPlugin } from '../../mol-plugin-ui';
- import { PluginUIContext } from '../../mol-plugin-ui/context';
- import { PluginLayoutControlsDisplay } from '../../mol-plugin/layout';
- import { DefaultPluginUISpec, PluginUISpec } from '../../mol-plugin-ui/spec';
- import { PluginConfig } from '../../mol-plugin/config';
- import { PluginSpec } from '../../mol-plugin/spec';
- import '../../mol-util/polyfill';
- import { ObjectKeys } from '../../mol-util/type-helpers';
- import './embedded.html';
- import './favicon.ico';
- import './index.html';
- require('mol-plugin-ui/skin/light.scss');
- export { PLUGIN_VERSION as version } from '../../mol-plugin/version';
- export { setDebugMode, setProductionMode } from '../../mol-util/debug';
- export { loadWithUNITMPMembraneRepresentation } from '../../extensions/tmdet/behavior';
- export { loadInitialSnapshot } from '../../extensions/tmdet/camera';
- export { DebugUtil } from '../../extensions/tmdet/debug-utils';
- const Extensions = {
- 'tmdet-membrane-orientation': PluginSpec.Behavior(TMDETMembraneOrientation)
- };
- const DefaultViewerOptions = {
- extensions: ObjectKeys(Extensions),
- layoutIsExpanded: true,
- layoutShowControls: true,
- layoutShowRemoteState: true,
- layoutControlsDisplay: 'reactive' as PluginLayoutControlsDisplay,
- layoutShowSequence: true,
- layoutShowLog: true,
- layoutShowLeftPanel: true,
- collapseLeftPanel: false,
- disableAntialiasing: false,
- pixelScale: 1,
- enableWboit: true,
- viewportShowExpand: PluginConfig.Viewport.ShowExpand.defaultValue,
- viewportShowControls: PluginConfig.Viewport.ShowControls.defaultValue,
- viewportShowSettings: PluginConfig.Viewport.ShowSettings.defaultValue,
- viewportShowSelectionMode: PluginConfig.Viewport.ShowSelectionMode.defaultValue,
- viewportShowAnimation: PluginConfig.Viewport.ShowAnimation.defaultValue,
- pluginStateServer: PluginConfig.State.DefaultServer.defaultValue,
- volumeStreamingServer: PluginConfig.VolumeStreaming.DefaultServer.defaultValue,
- volumeStreamingDisabled: !PluginConfig.VolumeStreaming.Enabled.defaultValue,
- pdbProvider: PluginConfig.Download.DefaultPdbProvider.defaultValue,
- emdbProvider: PluginConfig.Download.DefaultEmdbProvider.defaultValue,
- };
- type ViewerOptions = typeof DefaultViewerOptions;
- export class Viewer {
- plugin: PluginUIContext
- constructor(elementOrId: string | HTMLElement, options: Partial<ViewerOptions> = {}) {
- const o = { ...DefaultViewerOptions, ...options };
- const defaultSpec = DefaultPluginUISpec();
- const spec: PluginUISpec = {
- actions: defaultSpec.actions,
- behaviors: [
- ...defaultSpec.behaviors,
- ...o.extensions.map(e => Extensions[e]),
- ],
- animations: [...defaultSpec.animations || []],
- customParamEditors: defaultSpec.customParamEditors,
- layout: {
- initial: {
- isExpanded: o.layoutIsExpanded,
- showControls: o.layoutShowControls,
- controlsDisplay: o.layoutControlsDisplay,
- regionState: {
- bottom: 'full',
- left: o.collapseLeftPanel ? 'collapsed' : 'full',
- right: 'full',
- top: 'full',
- }
- },
- },
- components: {
- ...defaultSpec.components,
- controls: {
- ...defaultSpec.components?.controls,
- top: o.layoutShowSequence ? undefined : 'none',
- bottom: o.layoutShowLog ? undefined : 'none',
- left: o.layoutShowLeftPanel ? undefined : 'none',
- },
- remoteState: o.layoutShowRemoteState ? 'default' : 'none',
- },
- config: [
- [PluginConfig.General.DisableAntialiasing, o.disableAntialiasing],
- [PluginConfig.General.PixelScale, o.pixelScale],
- [PluginConfig.General.EnableWboit, o.enableWboit],
- [PluginConfig.Viewport.ShowExpand, o.viewportShowExpand],
- [PluginConfig.Viewport.ShowControls, o.viewportShowControls],
- [PluginConfig.Viewport.ShowSettings, o.viewportShowSettings],
- [PluginConfig.Viewport.ShowSelectionMode, o.viewportShowSelectionMode],
- [PluginConfig.Viewport.ShowAnimation, o.viewportShowAnimation],
- [PluginConfig.State.DefaultServer, o.pluginStateServer],
- [PluginConfig.State.CurrentServer, o.pluginStateServer],
- [PluginConfig.VolumeStreaming.DefaultServer, o.volumeStreamingServer],
- [PluginConfig.VolumeStreaming.Enabled, !o.volumeStreamingDisabled],
- [PluginConfig.Download.DefaultPdbProvider, o.pdbProvider],
- [PluginConfig.Download.DefaultEmdbProvider, o.emdbProvider]
- ]
- };
- const element = typeof elementOrId === 'string'
- ? document.getElementById(elementOrId)
- : elementOrId;
- if (!element) throw new Error(`Could not get element with id '${elementOrId}'`);
- this.plugin = createPlugin(element, spec);
- }
- handleResize() {
- this.plugin.layout.events.updated.next();
- }
- }
|