mirror of
https://github.com/molstar/molstar.git
synced 2026-06-05 05:44:23 +08:00
Compare commits
12 Commits
v2.0.0-dev
...
v2.0.0-dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
24274cc53b | ||
|
|
870cef2fd4 | ||
|
|
bf7b1f5bfd | ||
|
|
9c9a0312db | ||
|
|
724fa2a7cd | ||
|
|
19b36e5942 | ||
|
|
b0dd9ab026 | ||
|
|
b77f1d4dee | ||
|
|
3770fd7706 | ||
|
|
e3175c3ed1 | ||
|
|
7c5dd5b15b | ||
|
|
acf13fa46f |
6222
package-lock.json
generated
6222
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "molstar",
|
||||
"version": "2.0.0-dev.7",
|
||||
"version": "2.0.0-dev.9",
|
||||
"description": "A comprehensive macromolecular library.",
|
||||
"homepage": "https://github.com/molstar/molstar#readme",
|
||||
"repository": {
|
||||
|
||||
@@ -5,31 +5,32 @@
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
*/
|
||||
|
||||
import '../../mol-util/polyfill';
|
||||
import { createPlugin } from '../../mol-plugin';
|
||||
import { DefaultPluginSpec } from '../../mol-plugin/spec';
|
||||
import './index.html';
|
||||
import { PluginContext } from '../../mol-plugin/context';
|
||||
import { PluginCommands } from '../../mol-plugin/commands';
|
||||
import { PluginSpec } from '../../mol-plugin/spec';
|
||||
import { PluginConfig } from '../../mol-plugin/config';
|
||||
import { ObjectKeys } from '../../mol-util/type-helpers';
|
||||
import { PluginLayoutControlsDisplay } from '../../mol-plugin/layout';
|
||||
import { BuiltInTrajectoryFormat } from '../../mol-plugin-state/formats/trajectory';
|
||||
import { Structure } from '../../mol-model/structure';
|
||||
import { PluginStateTransform, PluginStateObject as PSO } from '../../mol-plugin-state/objects';
|
||||
import { ParamDefinition as PD } from '../../mol-util/param-definition';
|
||||
import { Task } from '../../mol-task';
|
||||
import { StateObject } from '../../mol-state';
|
||||
import { ViewportComponent, StructurePreset, ShowButtons } from './viewport';
|
||||
import { BuiltInTrajectoryFormat } from '../../mol-plugin-state/formats/trajectory';
|
||||
import { PluginStateObject as PSO, PluginStateTransform } from '../../mol-plugin-state/objects';
|
||||
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 { PluginBehaviors } from '../../mol-plugin/behavior';
|
||||
import { ColorNames } from '../../mol-util/color/names';
|
||||
import { PluginCommands } from '../../mol-plugin/commands';
|
||||
import { PluginConfig } from '../../mol-plugin/config';
|
||||
import { PluginSpec } from '../../mol-plugin/spec';
|
||||
import { StateObject } from '../../mol-state';
|
||||
import { Task } from '../../mol-task';
|
||||
import { Color } from '../../mol-util/color';
|
||||
import { ColorNames } from '../../mol-util/color/names';
|
||||
import { ParamDefinition as PD } from '../../mol-util/param-definition';
|
||||
import '../../mol-util/polyfill';
|
||||
import { ObjectKeys } from '../../mol-util/type-helpers';
|
||||
import './index.html';
|
||||
import { ShowButtons, StructurePreset, ViewportComponent } from './viewport';
|
||||
|
||||
require('mol-plugin-ui/skin/light.scss');
|
||||
|
||||
export { PLUGIN_VERSION as version } from '../../mol-plugin/version';
|
||||
export { setProductionMode, setDebugMode } from '../../mol-util/debug';
|
||||
export { setDebugMode, setProductionMode } from '../../mol-util/debug';
|
||||
export { Viewer as DockingViewer };
|
||||
|
||||
const DefaultViewerOptions = {
|
||||
extensions: ObjectKeys({}),
|
||||
@@ -53,7 +54,7 @@ const DefaultViewerOptions = {
|
||||
};
|
||||
|
||||
class Viewer {
|
||||
plugin: PluginContext
|
||||
plugin: PluginUIContext
|
||||
|
||||
constructor(elementOrId: string | HTMLElement, colors = [Color(0x992211), Color(0xDDDDDD)], showButtons = true) {
|
||||
const o = { ...DefaultViewerOptions, ...{
|
||||
@@ -70,10 +71,10 @@ class Viewer {
|
||||
viewportShowSelectionMode: false,
|
||||
viewportShowAnimation: false,
|
||||
} };
|
||||
const defaultSpec = DefaultPluginSpec();
|
||||
const defaultSpec = DefaultPluginUISpec();
|
||||
|
||||
const spec: PluginSpec = {
|
||||
actions: [...defaultSpec.actions],
|
||||
const spec: PluginUISpec = {
|
||||
actions: defaultSpec.actions,
|
||||
behaviors: [
|
||||
PluginSpec.Behavior(PluginBehaviors.Representation.HighlightLoci, { mark: false }),
|
||||
PluginSpec.Behavior(PluginBehaviors.Representation.DefaultLociLabelProvider),
|
||||
@@ -83,7 +84,7 @@ class Viewer {
|
||||
PluginSpec.Behavior(PluginBehaviors.CustomProps.Interactions),
|
||||
PluginSpec.Behavior(PluginBehaviors.CustomProps.SecondaryStructure),
|
||||
],
|
||||
animations: [...defaultSpec.animations || []],
|
||||
animations: defaultSpec.animations,
|
||||
customParamEditors: defaultSpec.customParamEditors,
|
||||
layout: {
|
||||
initial: {
|
||||
@@ -91,15 +92,15 @@ class Viewer {
|
||||
showControls: o.layoutShowControls,
|
||||
controlsDisplay: o.layoutControlsDisplay,
|
||||
},
|
||||
controls: {
|
||||
...defaultSpec.layout && defaultSpec.layout.controls,
|
||||
top: o.layoutShowSequence ? undefined : 'none',
|
||||
bottom: o.layoutShowLog ? undefined : 'none',
|
||||
left: o.layoutShowLeftPanel ? undefined : 'none',
|
||||
}
|
||||
},
|
||||
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',
|
||||
viewport: {
|
||||
view: ViewportComponent
|
||||
@@ -210,4 +211,3 @@ const MergeStructures = PluginStateTransform.BuiltIn({
|
||||
});
|
||||
|
||||
(window as any).DockingViewer = Viewer;
|
||||
export { Viewer as DockingViewer };
|
||||
@@ -49,11 +49,13 @@
|
||||
if (debugMode) molstar.setDebugMode(debugMode, debugMode);
|
||||
|
||||
var hideControls = getParam('hide-controls', '[^&]+').trim() === '1';
|
||||
var collapseLeftPanel = getParam('collapse-left-panel', '[^&]+').trim() === '1';
|
||||
var pdbProvider = getParam('pdb-provider', '[^&]+').trim().toLowerCase();
|
||||
var emdbProvider = getParam('emdb-provider', '[^&]+').trim().toLowerCase();
|
||||
var viewer = new molstar.Viewer('app', {
|
||||
layoutShowControls: !hideControls,
|
||||
viewportShowExpand: false,
|
||||
collapseLeftPanel: collapseLeftPanel,
|
||||
pdbProvider: pdbProvider || 'pdbe',
|
||||
emdbProvider: emdbProvider || 'pdbe',
|
||||
});
|
||||
|
||||
@@ -5,43 +5,43 @@
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
*/
|
||||
|
||||
import '../../mol-util/polyfill';
|
||||
import { createPlugin } from '../../mol-plugin';
|
||||
import { DefaultPluginSpec } from '../../mol-plugin/spec';
|
||||
import './index.html';
|
||||
import './embedded.html';
|
||||
import './favicon.ico';
|
||||
import { PluginContext } from '../../mol-plugin/context';
|
||||
import { PluginCommands } from '../../mol-plugin/commands';
|
||||
import { PluginSpec } from '../../mol-plugin/spec';
|
||||
import { DownloadStructure, PdbDownloadProvider } from '../../mol-plugin-state/actions/structure';
|
||||
import { PluginConfig } from '../../mol-plugin/config';
|
||||
import { CellPack } from '../../extensions/cellpack';
|
||||
import { RCSBAssemblySymmetry, RCSBValidationReport } from '../../extensions/rcsb';
|
||||
import { PDBeStructureQualityReport } from '../../extensions/pdbe';
|
||||
import { Asset } from '../../mol-util/assets';
|
||||
import { ObjectKeys } from '../../mol-util/type-helpers';
|
||||
import { PluginState } from '../../mol-plugin/state';
|
||||
import { DownloadDensity } from '../../mol-plugin-state/actions/volume';
|
||||
import { PluginLayoutControlsDisplay } from '../../mol-plugin/layout';
|
||||
import { BuiltInTrajectoryFormat } from '../../mol-plugin-state/formats/trajectory';
|
||||
import { ANVILMembraneOrientation } from '../../extensions/anvil/behavior';
|
||||
import { CellPack } from '../../extensions/cellpack';
|
||||
import { DnatcoConfalPyramids } from '../../extensions/dnatco';
|
||||
import { G3DFormat, G3dProvider } from '../../extensions/g3d/format';
|
||||
import { Mp4Export } from '../../extensions/mp4-export';
|
||||
import { PDBeStructureQualityReport } from '../../extensions/pdbe';
|
||||
import { RCSBAssemblySymmetry, RCSBValidationReport } from '../../extensions/rcsb';
|
||||
import { DownloadStructure, PdbDownloadProvider } from '../../mol-plugin-state/actions/structure';
|
||||
import { DownloadDensity } from '../../mol-plugin-state/actions/volume';
|
||||
import { StructureRepresentationPresetProvider } from '../../mol-plugin-state/builder/structure/representation-preset';
|
||||
import { DataFormatProvider } from '../../mol-plugin-state/formats/provider';
|
||||
import { BuiltInTrajectoryFormat } from '../../mol-plugin-state/formats/trajectory';
|
||||
import { BuildInVolumeFormat } from '../../mol-plugin-state/formats/volume';
|
||||
import { Color } from '../../mol-util/color';
|
||||
import { StateObjectSelector } from '../../mol-state';
|
||||
import { createVolumeRepresentationParams } from '../../mol-plugin-state/helpers/volume-representation-params';
|
||||
import { PluginStateObject } from '../../mol-plugin-state/objects';
|
||||
import { StateTransforms } from '../../mol-plugin-state/transforms';
|
||||
import { createVolumeRepresentationParams } from '../../mol-plugin-state/helpers/volume-representation-params';
|
||||
import { Mp4Export } from '../../extensions/mp4-export';
|
||||
import { StructureRepresentationPresetProvider } from '../../mol-plugin-state/builder/structure/representation-preset';
|
||||
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 { PluginCommands } from '../../mol-plugin/commands';
|
||||
import { PluginConfig } from '../../mol-plugin/config';
|
||||
import { PluginSpec } from '../../mol-plugin/spec';
|
||||
import { PluginState } from '../../mol-plugin/state';
|
||||
import { StateObjectSelector } from '../../mol-state';
|
||||
import { Asset } from '../../mol-util/assets';
|
||||
import { Color } from '../../mol-util/color';
|
||||
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 { setProductionMode, setDebugMode } from '../../mol-util/debug';
|
||||
export { setDebugMode, setProductionMode } from '../../mol-util/debug';
|
||||
|
||||
const CustomFormats = [
|
||||
['g3d', G3dProvider] as const
|
||||
@@ -68,6 +68,7 @@ const DefaultViewerOptions = {
|
||||
layoutShowSequence: true,
|
||||
layoutShowLog: true,
|
||||
layoutShowLeftPanel: true,
|
||||
collapseLeftPanel: false,
|
||||
disableAntialiasing: false,
|
||||
pixelScale: 1,
|
||||
enableWboit: true,
|
||||
@@ -86,14 +87,14 @@ const DefaultViewerOptions = {
|
||||
type ViewerOptions = typeof DefaultViewerOptions;
|
||||
|
||||
export class Viewer {
|
||||
plugin: PluginContext
|
||||
plugin: PluginUIContext
|
||||
|
||||
constructor(elementOrId: string | HTMLElement, options: Partial<ViewerOptions> = {}) {
|
||||
const o = { ...DefaultViewerOptions, ...options };
|
||||
const defaultSpec = DefaultPluginSpec();
|
||||
const defaultSpec = DefaultPluginUISpec();
|
||||
|
||||
const spec: PluginSpec = {
|
||||
actions: [...defaultSpec.actions],
|
||||
const spec: PluginUISpec = {
|
||||
actions: defaultSpec.actions,
|
||||
behaviors: [
|
||||
...defaultSpec.behaviors,
|
||||
...o.extensions.map(e => Extensions[e]),
|
||||
@@ -106,16 +107,22 @@ export class Viewer {
|
||||
isExpanded: o.layoutIsExpanded,
|
||||
showControls: o.layoutShowControls,
|
||||
controlsDisplay: o.layoutControlsDisplay,
|
||||
regionState: {
|
||||
bottom: 'full',
|
||||
left: o.collapseLeftPanel ? 'collapsed' : 'full',
|
||||
right: 'full',
|
||||
top: 'full',
|
||||
}
|
||||
},
|
||||
controls: {
|
||||
...defaultSpec.layout && defaultSpec.layout.controls,
|
||||
top: o.layoutShowSequence ? undefined : 'none',
|
||||
bottom: o.layoutShowLog ? undefined : 'none',
|
||||
left: o.layoutShowLeftPanel ? undefined : 'none',
|
||||
}
|
||||
},
|
||||
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: [
|
||||
|
||||
@@ -18,7 +18,6 @@ _.StateTransforms.Data.Download.id;
|
||||
|
||||
// Empty plugin context
|
||||
const ctx = new PluginContext({
|
||||
actions: [],
|
||||
behaviors: []
|
||||
});
|
||||
|
||||
|
||||
@@ -4,25 +4,25 @@
|
||||
* @author David Sehnal <david.sehnal@gmail.com>
|
||||
*/
|
||||
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { debounceTime, skip } from 'rxjs/operators';
|
||||
import { AlphaOrbital, Basis } from '../../extensions/alpha-orbitals/data-model';
|
||||
import { SphericalBasisOrder } from '../../extensions/alpha-orbitals/spherical-functions';
|
||||
import { BasisAndOrbitals, CreateOrbitalDensityVolume, CreateOrbitalRepresentation3D, CreateOrbitalVolume, StaticBasisAndOrbitals } from '../../extensions/alpha-orbitals/transforms';
|
||||
import { createPluginAsync } from '../../mol-plugin';
|
||||
import { DefaultPluginSpec } from '../../mol-plugin/spec';
|
||||
import { canComputeGrid3dOnGPU } from '../../mol-gl/compute/grid3d';
|
||||
import { PluginStateObject } from '../../mol-plugin-state/objects';
|
||||
import { createPluginAsync } from '../../mol-plugin-ui';
|
||||
import { PluginUIContext } from '../../mol-plugin-ui/context';
|
||||
import { DefaultPluginUISpec } from '../../mol-plugin-ui/spec';
|
||||
import { PluginCommands } from '../../mol-plugin/commands';
|
||||
import { PluginConfig } from '../../mol-plugin/config';
|
||||
import { PluginContext } from '../../mol-plugin/context';
|
||||
import { StateObjectSelector, StateTransformer } from '../../mol-state';
|
||||
import { Color } from '../../mol-util/color';
|
||||
import { ColorNames } from '../../mol-util/color/names';
|
||||
import { ParamDefinition } from '../../mol-util/param-definition';
|
||||
import { mountControls } from './controls';
|
||||
import { DemoMoleculeSDF, DemoOrbitals } from './example-data';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { debounceTime, skip } from 'rxjs/operators';
|
||||
import './index.html';
|
||||
import { Basis, AlphaOrbital } from '../../extensions/alpha-orbitals/data-model';
|
||||
import { PluginCommands } from '../../mol-plugin/commands';
|
||||
import { canComputeGrid3dOnGPU } from '../../mol-gl/compute/grid3d';
|
||||
require('mol-plugin-ui/skin/light.scss');
|
||||
|
||||
interface DemoInput {
|
||||
@@ -50,10 +50,10 @@ type Selectors = {
|
||||
}
|
||||
|
||||
export class AlphaOrbitalsExample {
|
||||
plugin: PluginContext;
|
||||
plugin: PluginUIContext;
|
||||
|
||||
async init(target: string | HTMLElement) {
|
||||
const defaultSpec = DefaultPluginSpec();
|
||||
const defaultSpec = DefaultPluginUISpec();
|
||||
this.plugin = await createPluginAsync(typeof target === 'string' ? document.getElementById(target)! : target, {
|
||||
...defaultSpec,
|
||||
layout: {
|
||||
@@ -61,15 +61,13 @@ export class AlphaOrbitalsExample {
|
||||
isExpanded: false,
|
||||
showControls: false
|
||||
},
|
||||
controls: { left: 'none', right: 'none', top: 'none', bottom: 'none' },
|
||||
},
|
||||
components: {
|
||||
viewport: {
|
||||
canvas3d: {
|
||||
camera: {
|
||||
helper: { axes: { name: 'off', params: { } } }
|
||||
}
|
||||
}
|
||||
controls: { left: 'none', right: 'none', top: 'none', bottom: 'none' },
|
||||
},
|
||||
canvas3d: {
|
||||
camera: {
|
||||
helper: { axes: { name: 'off', params: { } } }
|
||||
}
|
||||
},
|
||||
config: [
|
||||
|
||||
@@ -4,39 +4,36 @@
|
||||
* @author David Sehnal <david.sehnal@gmail.com>
|
||||
*/
|
||||
|
||||
import { PDBeStructureQualityReport } from '../../extensions/pdbe';
|
||||
import { EmptyLoci } from '../../mol-model/loci';
|
||||
import { StructureSelection } from '../../mol-model/structure';
|
||||
import { createPlugin } from '../../mol-plugin';
|
||||
import { DefaultPluginSpec } from '../../mol-plugin/spec';
|
||||
import { AnimateModelIndex } from '../../mol-plugin-state/animation/built-in/model-index';
|
||||
import { BuiltInTrajectoryFormat } from '../../mol-plugin-state/formats/trajectory';
|
||||
import { createPlugin } from '../../mol-plugin-ui';
|
||||
import { PluginUIContext } from '../../mol-plugin-ui/context';
|
||||
import { DefaultPluginUISpec } from '../../mol-plugin-ui/spec';
|
||||
import { PluginCommands } from '../../mol-plugin/commands';
|
||||
import { PluginContext } from '../../mol-plugin/context';
|
||||
import { Script } from '../../mol-script/script';
|
||||
import { Asset } from '../../mol-util/assets';
|
||||
import { Color } from '../../mol-util/color';
|
||||
import { StripedResidues } from './coloring';
|
||||
import { CustomToastMessage } from './controls';
|
||||
import './index.html';
|
||||
import { buildStaticSuperposition, dynamicSuperpositionTest, StaticSuperpositionTestData } from './superposition';
|
||||
import { PDBeStructureQualityReport } from '../../extensions/pdbe';
|
||||
import { Asset } from '../../mol-util/assets';
|
||||
require('mol-plugin-ui/skin/light.scss');
|
||||
|
||||
type LoadParams = { url: string, format?: BuiltInTrajectoryFormat, isBinary?: boolean, assemblyId?: string }
|
||||
|
||||
class BasicWrapper {
|
||||
plugin: PluginContext;
|
||||
plugin: PluginUIContext;
|
||||
|
||||
init(target: string | HTMLElement) {
|
||||
this.plugin = createPlugin(typeof target === 'string' ? document.getElementById(target)! : target, {
|
||||
...DefaultPluginSpec(),
|
||||
...DefaultPluginUISpec(),
|
||||
layout: {
|
||||
initial: {
|
||||
isExpanded: false,
|
||||
showControls: false
|
||||
},
|
||||
controls: {
|
||||
// left: 'none'
|
||||
}
|
||||
},
|
||||
components: {
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
*/
|
||||
|
||||
import { Canvas3DProps } from '../../mol-canvas3d/canvas3d';
|
||||
import { createPlugin } from '../../mol-plugin';
|
||||
import { DefaultPluginSpec } from '../../mol-plugin/spec';
|
||||
import { BuiltInTrajectoryFormat } from '../../mol-plugin-state/formats/trajectory';
|
||||
import { createPlugin } from '../../mol-plugin-ui';
|
||||
import { PluginUIContext } from '../../mol-plugin-ui/context';
|
||||
import { DefaultPluginUISpec } from '../../mol-plugin-ui/spec';
|
||||
import { PluginCommands } from '../../mol-plugin/commands';
|
||||
import { PluginContext } from '../../mol-plugin/context';
|
||||
import './index.html';
|
||||
import { Asset } from '../../mol-util/assets';
|
||||
import './index.html';
|
||||
require('mol-plugin-ui/skin/light.scss');
|
||||
|
||||
type LoadParams = { url: string, format?: BuiltInTrajectoryFormat, isBinary?: boolean, assemblyId?: string }
|
||||
@@ -62,7 +62,7 @@ const Canvas3DPresets = {
|
||||
type Canvas3DPreset = keyof typeof Canvas3DPresets
|
||||
|
||||
class LightingDemo {
|
||||
plugin: PluginContext;
|
||||
plugin: PluginUIContext;
|
||||
|
||||
private radius = 5;
|
||||
private bias = 1.1;
|
||||
@@ -70,12 +70,14 @@ class LightingDemo {
|
||||
|
||||
init(target: string | HTMLElement) {
|
||||
this.plugin = createPlugin(typeof target === 'string' ? document.getElementById(target)! : target, {
|
||||
...DefaultPluginSpec(),
|
||||
...DefaultPluginUISpec(),
|
||||
layout: {
|
||||
initial: {
|
||||
isExpanded: false,
|
||||
showControls: false
|
||||
},
|
||||
},
|
||||
components: {
|
||||
controls: { left: 'none', right: 'none', top: 'none', bottom: 'none' }
|
||||
}
|
||||
});
|
||||
|
||||
@@ -6,15 +6,15 @@
|
||||
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import { Canvas3DProps, DefaultCanvas3DParams } from '../../mol-canvas3d/canvas3d';
|
||||
import { createPlugin } from '../../mol-plugin';
|
||||
import { DefaultPluginSpec } from '../../mol-plugin/spec';
|
||||
import { AnimateModelIndex } from '../../mol-plugin-state/animation/built-in/model-index';
|
||||
import { createStructureRepresentationParams } from '../../mol-plugin-state/helpers/structure-representation-params';
|
||||
import { PluginStateObject, PluginStateObject as PSO } from '../../mol-plugin-state/objects';
|
||||
import { StateTransforms } from '../../mol-plugin-state/transforms';
|
||||
import { createPlugin } from '../../mol-plugin-ui';
|
||||
import { PluginUIContext } from '../../mol-plugin-ui/context';
|
||||
import { DefaultPluginUISpec } from '../../mol-plugin-ui/spec';
|
||||
import { CreateVolumeStreamingInfo, InitVolumeStreaming } from '../../mol-plugin/behavior/dynamic/volume-streaming/transformers';
|
||||
import { PluginCommands } from '../../mol-plugin/commands';
|
||||
import { PluginContext } from '../../mol-plugin/context';
|
||||
import { PluginState } from '../../mol-plugin/state';
|
||||
import { MolScriptBuilder as MS } from '../../mol-script/language/builder';
|
||||
import { StateBuilder, StateObject, StateSelection } from '../../mol-state';
|
||||
@@ -41,13 +41,13 @@ class MolStarProteopediaWrapper {
|
||||
modelInfo: this._ev<ModelInfo>()
|
||||
};
|
||||
|
||||
plugin: PluginContext;
|
||||
plugin: PluginUIContext;
|
||||
|
||||
init(target: string | HTMLElement, options?: {
|
||||
customColorList?: number[]
|
||||
}) {
|
||||
this.plugin = createPlugin(typeof target === 'string' ? document.getElementById(target)! : target, {
|
||||
...DefaultPluginSpec(),
|
||||
...DefaultPluginUISpec(),
|
||||
animations: [
|
||||
AnimateModelIndex
|
||||
],
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
|
||||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import { PluginUIContext } from '../../../mol-plugin-ui/context';
|
||||
import { PluginContextContainer } from '../../../mol-plugin-ui/plugin';
|
||||
import { TransformUpdaterControl } from '../../../mol-plugin-ui/state/update-transform';
|
||||
import { PluginContext } from '../../../mol-plugin/context';
|
||||
import { StateElements } from '../helpers';
|
||||
|
||||
export function volumeStreamingControls(plugin: PluginContext, parent: Element) {
|
||||
export function volumeStreamingControls(plugin: PluginUIContext, parent: Element) {
|
||||
ReactDOM.render(<PluginContextContainer plugin={plugin}>
|
||||
<TransformUpdaterControl nodeRef={StateElements.VolumeStreaming} />
|
||||
</PluginContextContainer>, parent);
|
||||
|
||||
@@ -192,6 +192,15 @@ export function createIsosurfaceBuffers(ctx: WebGLContext, activeVoxelsBase: Tex
|
||||
|
||||
//
|
||||
|
||||
/**
|
||||
* GPU isosurface extraction
|
||||
*
|
||||
* Algorithm from "High‐speed Marching Cubes using HistoPyramids"
|
||||
* by C Dyken, G Ziegler, C Theobalt, HP Seidel
|
||||
* https://doi.org/10.1111/j.1467-8659.2008.01182.x
|
||||
*
|
||||
* Implementation based on http://www.miaumiau.cat/2016/10/stream-compaction-in-webgl/
|
||||
*/
|
||||
export function extractIsosurface(ctx: WebGLContext, volumeData: Texture, gridDim: Vec3, gridTexDim: Vec3, gridTexScale: Vec2, transform: Mat4, isoValue: number, packedGroup: boolean, vertexTexture?: Texture, groupTexture?: Texture, normalTexture?: Texture) {
|
||||
// console.time('calcActiveVoxels');
|
||||
const activeVoxelsTex = calcActiveVoxels(ctx, volumeData, gridDim, gridTexDim, isoValue, gridTexScale);
|
||||
|
||||
@@ -23,7 +23,7 @@ export function checkStructureMaxRadiusDistance(ctx: QueryContext, a: Structure,
|
||||
}
|
||||
|
||||
namespace MinMaxDist {
|
||||
const enum Result {
|
||||
export const enum Result {
|
||||
BelowMin,
|
||||
WithinMax,
|
||||
Miss
|
||||
|
||||
@@ -7,15 +7,15 @@
|
||||
|
||||
import * as React from 'react';
|
||||
import { Observable, Subscription } from 'rxjs';
|
||||
import { PluginContext } from '../mol-plugin/context';
|
||||
import { PluginUIContext } from './context';
|
||||
import { Button, ColorAccent } from './controls/common';
|
||||
import { Icon, ArrowRightSvg, ArrowDropDownSvg } from './controls/icons';
|
||||
|
||||
export const PluginReactContext = React.createContext(void 0 as any as PluginContext);
|
||||
export const PluginReactContext = React.createContext(void 0 as any as PluginUIContext);
|
||||
|
||||
export abstract class PluginUIComponent<P = {}, S = {}, SS = {}> extends React.Component<P, S, SS> {
|
||||
static contextType = PluginReactContext;
|
||||
readonly plugin: PluginContext;
|
||||
readonly plugin: PluginUIContext;
|
||||
|
||||
private subs: Subscription[] | undefined = void 0;
|
||||
|
||||
@@ -33,7 +33,7 @@ export abstract class PluginUIComponent<P = {}, S = {}, SS = {}> extends React.C
|
||||
protected init?(): void;
|
||||
|
||||
constructor(props: P, context?: any) {
|
||||
super(props, context);
|
||||
super(props);
|
||||
this.plugin = context;
|
||||
if (this.init) this.init();
|
||||
}
|
||||
@@ -41,7 +41,7 @@ export abstract class PluginUIComponent<P = {}, S = {}, SS = {}> extends React.C
|
||||
|
||||
export abstract class PurePluginUIComponent<P = {}, S = {}, SS = {}> extends React.PureComponent<P, S, SS> {
|
||||
static contextType = PluginReactContext;
|
||||
readonly plugin: PluginContext;
|
||||
readonly plugin: PluginUIContext;
|
||||
|
||||
private subs: Subscription[] | undefined = void 0;
|
||||
|
||||
|
||||
33
src/mol-plugin-ui/context.ts
Normal file
33
src/mol-plugin-ui/context.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Copyright (c) 2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author David Sehnal <david.sehnal@gmail.com>
|
||||
*/
|
||||
|
||||
|
||||
import { PluginContext } from '../mol-plugin/context';
|
||||
import { PluginUISpec } from './spec';
|
||||
import { StateTransformParameters } from './state/common';
|
||||
|
||||
export class PluginUIContext extends PluginContext {
|
||||
readonly customParamEditors = new Map<string, StateTransformParameters.Class>();
|
||||
|
||||
private initCustomParamEditors() {
|
||||
if (!this.spec.customParamEditors) return;
|
||||
|
||||
for (const [t, e] of this.spec.customParamEditors) {
|
||||
this.customParamEditors.set(t.id, e);
|
||||
}
|
||||
}
|
||||
|
||||
dispose(options?: { doNotForceWebGLContextLoss?: boolean }) {
|
||||
super.dispose(options);
|
||||
this.layout.dispose();
|
||||
}
|
||||
|
||||
constructor(public spec: PluginUISpec) {
|
||||
super(spec);
|
||||
|
||||
this.initCustomParamEditors();
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
import * as React from 'react';
|
||||
import { Mat4, Vec2, Vec3 } from '../../mol-math/linear-algebra';
|
||||
import { PluginContext } from '../../mol-plugin/context';
|
||||
import { Color } from '../../mol-util/color';
|
||||
import { ColorListName, ColorListOptions, ColorListOptionsScale, ColorListOptionsSet, getColorListFromName } from '../../mol-util/color/lists';
|
||||
import { Legend as LegendData } from '../../mol-util/legend';
|
||||
@@ -26,6 +25,7 @@ import { LineGraphComponent } from './line-graph/line-graph-component';
|
||||
import { Slider, Slider2 } from './slider';
|
||||
import { Asset } from '../../mol-util/assets';
|
||||
import { ColorListEntry } from '../../mol-util/color/color';
|
||||
import { PluginUIContext } from '../context';
|
||||
|
||||
export type ParameterControlsCategoryFilter = string | null | (string | null)[]
|
||||
|
||||
@@ -104,7 +104,7 @@ export class ParameterControls<P extends PD.Params> extends React.PureComponent<
|
||||
}
|
||||
}
|
||||
|
||||
export class ParameterMappingControl<S, T> extends PluginUIComponent<{ mapping: ParamMapping<S, T, PluginContext> }> {
|
||||
export class ParameterMappingControl<S, T> extends PluginUIComponent<{ mapping: ParamMapping<S, T, PluginUIContext> }> {
|
||||
setSettings = (p: { param: PD.Base<any>, name: string, value: any }, old: any) => {
|
||||
const values = { ...old, [p.name]: p.value };
|
||||
const t = this.props.mapping.update(values, this.plugin);
|
||||
|
||||
@@ -7,20 +7,20 @@
|
||||
|
||||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import { Plugin } from '../mol-plugin-ui/plugin';
|
||||
import { PluginContext } from './context';
|
||||
import { DefaultPluginSpec, PluginSpec } from './spec';
|
||||
import { Plugin } from './plugin';
|
||||
import { PluginUIContext } from './context';
|
||||
import { DefaultPluginUISpec, PluginUISpec } from './spec';
|
||||
|
||||
export function createPlugin(target: HTMLElement, spec?: PluginSpec): PluginContext {
|
||||
const ctx = new PluginContext(spec || DefaultPluginSpec());
|
||||
export function createPlugin(target: HTMLElement, spec?: PluginUISpec): PluginUIContext {
|
||||
const ctx = new PluginUIContext(spec || DefaultPluginUISpec());
|
||||
ctx.init();
|
||||
ReactDOM.render(React.createElement(Plugin, { plugin: ctx }), target);
|
||||
return ctx;
|
||||
}
|
||||
|
||||
/** Returns the instance of the plugin after all behaviors have been initialized */
|
||||
export async function createPluginAsync(target: HTMLElement, spec?: PluginSpec) {
|
||||
const ctx = new PluginContext(spec || DefaultPluginSpec());
|
||||
export async function createPluginAsync(target: HTMLElement, spec?: PluginUISpec) {
|
||||
const ctx = new PluginUIContext(spec || DefaultPluginUISpec());
|
||||
const init = ctx.init();
|
||||
ReactDOM.render(React.createElement(Plugin, { plugin: ctx }), target);
|
||||
await init;
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
import { List } from 'immutable';
|
||||
import * as React from 'react';
|
||||
import { PluginContext } from '../mol-plugin/context';
|
||||
import { formatTime } from '../mol-util';
|
||||
import { LogEntry } from '../mol-util/log-entry';
|
||||
import { PluginReactContext, PluginUIComponent } from './base';
|
||||
@@ -18,8 +17,9 @@ import { BackgroundTaskProgress, OverlayTaskProgress } from './task';
|
||||
import { Toasts } from './toast';
|
||||
import { Viewport, ViewportControls } from './viewport';
|
||||
import { PluginCommands } from '../mol-plugin/commands';
|
||||
import { PluginUIContext } from './context';
|
||||
|
||||
export class Plugin extends React.Component<{ plugin: PluginContext }, {}> {
|
||||
export class Plugin extends React.Component<{ plugin: PluginUIContext }, {}> {
|
||||
region(kind: 'left' | 'right' | 'bottom' | 'main', element: JSX.Element) {
|
||||
return <div className={`msp-layout-region msp-layout-${kind}`}>
|
||||
<div className='msp-layout-static'>
|
||||
@@ -35,7 +35,7 @@ export class Plugin extends React.Component<{ plugin: PluginContext }, {}> {
|
||||
}
|
||||
}
|
||||
|
||||
export class PluginContextContainer extends React.Component<{ plugin: PluginContext }> {
|
||||
export class PluginContextContainer extends React.Component<{ plugin: PluginUIContext }> {
|
||||
render() {
|
||||
return <PluginReactContext.Provider value={this.props.plugin}>
|
||||
<div className='msp-plugin'>
|
||||
@@ -62,7 +62,7 @@ class Layout extends PluginUIComponent {
|
||||
|
||||
get layoutVisibilityClassName() {
|
||||
const layout = this.plugin.layout.state;
|
||||
const controls = (this.plugin.spec.layout && this.plugin.spec.layout.controls) || {};
|
||||
const controls = this.plugin.spec.components?.controls ?? {};
|
||||
|
||||
const classList: string[] = [];
|
||||
if (controls.top === 'none' || !layout.showControls || layout.regionState.top === 'hidden') {
|
||||
@@ -127,7 +127,7 @@ class Layout extends PluginUIComponent {
|
||||
|
||||
render() {
|
||||
const layout = this.plugin.layout.state;
|
||||
const controls = this.plugin.spec.layout?.controls || {};
|
||||
const controls = this.plugin.spec.components?.controls || {};
|
||||
const viewport = this.plugin.spec.components?.viewport?.view || DefaultViewport;
|
||||
|
||||
return <div className='msp-plugin' onDrop={this.onDrop} onDragOver={this.onDragOver}>
|
||||
@@ -149,7 +149,6 @@ export class ControlsWrapper extends PluginUIComponent {
|
||||
render() {
|
||||
const StructureTools = this.plugin.spec.components?.structureTools || DefaultStructureTools;
|
||||
return <div className='msp-scrollable-container'>
|
||||
{/* <CurrentObject /> */}
|
||||
<StructureTools />
|
||||
</div>;
|
||||
}
|
||||
|
||||
40
src/mol-plugin-ui/spec.ts
Normal file
40
src/mol-plugin-ui/spec.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Copyright (c) 2018-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author David Sehnal <david.sehnal@gmail.com>
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
*/
|
||||
|
||||
|
||||
import { StateTransformParameters } from '../mol-plugin-ui/state/common';
|
||||
import { DefaultPluginSpec, PluginSpec } from '../mol-plugin/spec';
|
||||
import { StateAction, StateTransformer } from '../mol-state';
|
||||
|
||||
export { PluginUISpec };
|
||||
|
||||
interface PluginUISpec extends PluginSpec {
|
||||
customParamEditors?: [StateAction | StateTransformer, StateTransformParameters.Class][],
|
||||
components?: {
|
||||
controls?: PluginUISpec.LayoutControls
|
||||
remoteState?: 'none' | 'default',
|
||||
structureTools?: React.ComponentClass,
|
||||
viewport?: {
|
||||
view?: React.ComponentClass,
|
||||
controls?: React.ComponentClass
|
||||
},
|
||||
hideTaskOverlay?: boolean
|
||||
},
|
||||
}
|
||||
|
||||
namespace PluginUISpec {
|
||||
export interface LayoutControls {
|
||||
top?: React.ComponentClass | 'none',
|
||||
left?: React.ComponentClass | 'none',
|
||||
right?: React.ComponentClass | 'none',
|
||||
bottom?: React.ComponentClass | 'none'
|
||||
}
|
||||
}
|
||||
|
||||
export const DefaultPluginUISpec = (): PluginUISpec => ({
|
||||
...DefaultPluginSpec(),
|
||||
});
|
||||
@@ -9,13 +9,13 @@ import { produce } from 'immer';
|
||||
import * as React from 'react';
|
||||
import { Canvas3DParams, Canvas3DProps } from '../../mol-canvas3d/canvas3d';
|
||||
import { PluginCommands } from '../../mol-plugin/commands';
|
||||
import { PluginContext } from '../../mol-plugin/context';
|
||||
import { StateTransform } from '../../mol-state';
|
||||
import { Color } from '../../mol-util/color';
|
||||
import { ParamDefinition as PD } from '../../mol-util/param-definition';
|
||||
import { ParamMapping } from '../../mol-util/param-mapping';
|
||||
import { Mutable } from '../../mol-util/type-helpers';
|
||||
import { PluginUIComponent } from '../base';
|
||||
import { PluginUIContext } from '../context';
|
||||
import { ParameterMappingControl } from '../controls/parameters';
|
||||
import { ViewportHelpContent } from './help';
|
||||
|
||||
@@ -71,9 +71,9 @@ const SimpleSettingsParams = {
|
||||
|
||||
type SimpleSettingsParams = typeof SimpleSettingsParams
|
||||
const SimpleSettingsMapping = ParamMapping({
|
||||
params: (ctx: PluginContext) => {
|
||||
params: (ctx: PluginUIContext) => {
|
||||
const params = PD.clone(SimpleSettingsParams);
|
||||
const controls = ctx.spec.layout?.controls;
|
||||
const controls = ctx.spec.components?.controls;
|
||||
if (controls) {
|
||||
const options: [LayoutOptions, string][] = [];
|
||||
if (controls.top !== 'none') options.push(['sequence', LayoutOptions.sequence]);
|
||||
@@ -83,8 +83,8 @@ const SimpleSettingsMapping = ParamMapping({
|
||||
}
|
||||
return params;
|
||||
},
|
||||
target(ctx: PluginContext) {
|
||||
const c = ctx.spec.layout?.controls;
|
||||
target(ctx: PluginUIContext) {
|
||||
const c = ctx.spec.components?.controls;
|
||||
const r = ctx.layout.state.regionState;
|
||||
const layout: SimpleSettingsParams['layout']['defaultValue'] = [];
|
||||
if (r.top !== 'hidden' && (!c || c.top !== 'none')) layout.push('sequence');
|
||||
|
||||
@@ -64,8 +64,8 @@ export namespace VolumeStreaming {
|
||||
};
|
||||
}
|
||||
|
||||
export type EntryParamDefinition = typeof createEntryParams extends (...args: any[]) => (infer T) ? T : never
|
||||
export type EntryParams = EntryParamDefinition extends PD.Params ? PD.Values<EntryParamDefinition> : {}
|
||||
export type EntryParamDefinition = ReturnType<typeof createEntryParams>
|
||||
export type EntryParams = PD.Values<EntryParamDefinition>
|
||||
|
||||
export function createEntryParams(options: { entryData?: VolumeServerInfo.EntryData, defaultView?: ViewTypes, structure?: Structure, channelParams?: DefaultChannelParams }) {
|
||||
const { entryData, defaultView, structure, channelParams = { } } = options;
|
||||
@@ -86,7 +86,7 @@ export namespace VolumeStreaming {
|
||||
bottomLeft: PD.Vec3(Vec3.create(0, 0, 0), {}, { isHidden: true }),
|
||||
topRight: PD.Vec3(Vec3.create(0, 0, 0), {}, { isHidden: true }),
|
||||
}, { description: 'Box around focused element.', isFlat: true }),
|
||||
'cell': PD.Group({}),
|
||||
'cell': PD.Group<{}>({}),
|
||||
// Show selection-box if available and cell otherwise.
|
||||
'auto': PD.Group({
|
||||
radius: PD.Numeric(5, { min: 0, max: 50, step: 0.5 }, { description: 'Radius in \u212B within which the volume is shown.' }),
|
||||
@@ -115,8 +115,8 @@ export namespace VolumeStreaming {
|
||||
|
||||
export type ViewTypes = 'off' | 'box' | 'selection-box' | 'cell' | 'auto'
|
||||
|
||||
export type ParamDefinition = typeof createParams extends (...args: any[]) => (infer T) ? T : never
|
||||
export type Params = ParamDefinition extends PD.Params ? PD.Values<ParamDefinition> : {}
|
||||
export type ParamDefinition = ReturnType<typeof createParams>
|
||||
export type Params = PD.Values<ParamDefinition>
|
||||
|
||||
type ChannelsInfo = { [name in ChannelType]?: { isoValue: Volume.IsoValue, color: Color, wireframe: boolean, opacity: number } }
|
||||
type ChannelsData = { [name in 'EM' | '2FO-FC' | 'FO-FC']?: Volume }
|
||||
|
||||
@@ -8,44 +8,51 @@
|
||||
import produce, { setAutoFreeze } from 'immer';
|
||||
import { List } from 'immutable';
|
||||
import { merge, Subscription } from 'rxjs';
|
||||
import { filter, take } from 'rxjs/operators';
|
||||
import { Canvas3D, Canvas3DContext, DefaultCanvas3DParams } from '../mol-canvas3d/canvas3d';
|
||||
import { resizeCanvas } from '../mol-canvas3d/util';
|
||||
import { Vec2 } from '../mol-math/linear-algebra';
|
||||
import { CustomProperty } from '../mol-model-props/common/custom-property';
|
||||
import { Model, Structure } from '../mol-model/structure';
|
||||
import { DataBuilder } from '../mol-plugin-state/builder/data';
|
||||
import { StructureBuilder } from '../mol-plugin-state/builder/structure';
|
||||
import { DataFormatRegistry } from '../mol-plugin-state/formats/registry';
|
||||
import { StructureSelectionQueryRegistry } from '../mol-plugin-state/helpers/structure-selection-query';
|
||||
import { PluginAnimationManager } from '../mol-plugin-state/manager/animation';
|
||||
import { CameraManager } from '../mol-plugin-state/manager/camera';
|
||||
import { InteractivityManager } from '../mol-plugin-state/manager/interactivity';
|
||||
import { LociLabel, LociLabelManager } from '../mol-plugin-state/manager/loci-label';
|
||||
import { PluginStateSnapshotManager } from '../mol-plugin-state/manager/snapshots';
|
||||
import { StructureComponentManager } from '../mol-plugin-state/manager/structure/component';
|
||||
import { StructureFocusManager } from '../mol-plugin-state/manager/structure/focus';
|
||||
import { StructureHierarchyManager } from '../mol-plugin-state/manager/structure/hierarchy';
|
||||
import { StructureHierarchyRef } from '../mol-plugin-state/manager/structure/hierarchy-state';
|
||||
import { StructureMeasurementManager } from '../mol-plugin-state/manager/structure/measurement';
|
||||
import { StructureSelectionManager } from '../mol-plugin-state/manager/structure/selection';
|
||||
import { PluginUIComponent } from '../mol-plugin-ui/base';
|
||||
import { StateTransformParameters } from '../mol-plugin-ui/state/common';
|
||||
import { VolumeHierarchyManager } from '../mol-plugin-state/manager/volume/hierarchy';
|
||||
import { LeftPanelTabName, PluginLayout } from './layout';
|
||||
import { Representation } from '../mol-repr/representation';
|
||||
import { StructureRepresentationRegistry } from '../mol-repr/structure/registry';
|
||||
import { VolumeRepresentationRegistry } from '../mol-repr/volume/registry';
|
||||
import { StateTransform } from '../mol-state';
|
||||
import { Task, RuntimeContext } from '../mol-task';
|
||||
import { RuntimeContext, Task } from '../mol-task';
|
||||
import { ColorTheme } from '../mol-theme/color';
|
||||
import { SizeTheme } from '../mol-theme/size';
|
||||
import { ThemeRegistryContext } from '../mol-theme/theme';
|
||||
import { AssetManager } from '../mol-util/assets';
|
||||
import { Color } from '../mol-util/color';
|
||||
import { ajaxGet } from '../mol-util/data-source';
|
||||
import { isDebugMode, isProductionMode } from '../mol-util/debug';
|
||||
import { ModifiersKeys } from '../mol-util/input/input-observer';
|
||||
import { LogEntry } from '../mol-util/log-entry';
|
||||
import { objectForEach } from '../mol-util/object';
|
||||
import { RxEventHelper } from '../mol-util/rx-event-helper';
|
||||
import { PluginAnimationLoop } from './animation-loop';
|
||||
import { BuiltInPluginBehaviors } from './behavior';
|
||||
import { PluginBehavior } from './behavior/behavior';
|
||||
import { PluginCommandManager } from './command';
|
||||
import { PluginCommands } from './commands';
|
||||
import { PluginConfig, PluginConfigManager } from './config';
|
||||
import { LeftPanelTabName, PluginLayout } from './layout';
|
||||
import { PluginSpec } from './spec';
|
||||
import { PluginState } from './state';
|
||||
import { SubstructureParentHelper } from './util/substructure-parent-helper';
|
||||
@@ -53,15 +60,6 @@ import { TaskManager } from './util/task-manager';
|
||||
import { PluginToastManager } from './util/toast';
|
||||
import { ViewportScreenshotHelper } from './util/viewport-screenshot';
|
||||
import { PLUGIN_VERSION, PLUGIN_VERSION_DATE } from './version';
|
||||
import { AssetManager } from '../mol-util/assets';
|
||||
import { PluginStateSnapshotManager } from '../mol-plugin-state/manager/snapshots';
|
||||
import { PluginAnimationManager } from '../mol-plugin-state/manager/animation';
|
||||
import { objectForEach } from '../mol-util/object';
|
||||
import { VolumeHierarchyManager } from '../mol-plugin-state/manager/volume/hierarchy';
|
||||
import { filter, take } from 'rxjs/operators';
|
||||
import { Vec2 } from '../mol-math/linear-algebra';
|
||||
import { PluginAnimationLoop } from './animation-loop';
|
||||
import { resizeCanvas } from '../mol-canvas3d/util';
|
||||
|
||||
export class PluginContext {
|
||||
runTask = <T>(task: Task<T>, params?: { useOverlay?: boolean }) => this.managers.task.run(task, params);
|
||||
@@ -71,7 +69,7 @@ export class PluginContext {
|
||||
return object;
|
||||
}
|
||||
|
||||
private subs: Subscription[] = [];
|
||||
protected subs: Subscription[] = [];
|
||||
|
||||
private disposed = false;
|
||||
private ev = RxEventHelper.create();
|
||||
@@ -109,8 +107,8 @@ export class PluginContext {
|
||||
|
||||
readonly canvas3dContext: Canvas3DContext | undefined;
|
||||
readonly canvas3d: Canvas3D | undefined;
|
||||
readonly animationLoop = new PluginAnimationLoop(this);
|
||||
readonly layout = new PluginLayout(this);
|
||||
readonly animationLoop = new PluginAnimationLoop(this);
|
||||
|
||||
readonly representation = {
|
||||
structure: {
|
||||
@@ -176,9 +174,8 @@ export class PluginContext {
|
||||
|
||||
readonly customModelProperties = new CustomProperty.Registry<Model>();
|
||||
readonly customStructureProperties = new CustomProperty.Registry<Structure>();
|
||||
readonly customParamEditors = new Map<string, StateTransformParameters.Class>();
|
||||
|
||||
readonly customStructureControls = new Map<string, { new(): PluginUIComponent<any, any, any> }>();
|
||||
readonly customStructureControls = new Map<string, { new(): any /* constructible react components with <action.customControl /> */ }>();
|
||||
readonly genericRepresentationControls = new Map<string, (selection: StructureHierarchyManager['selection']) => [StructureHierarchyRef[], string]>();
|
||||
|
||||
/**
|
||||
@@ -200,7 +197,7 @@ export class PluginContext {
|
||||
(this.canvas3dContext as Canvas3DContext) = Canvas3DContext.fromCanvas(canvas, { antialias, preserveDrawingBuffer, pixelScale, pickScale, enableWboit });
|
||||
(this.canvas3d as Canvas3D) = Canvas3D.create(this.canvas3dContext!);
|
||||
this.canvas3dInit.next(true);
|
||||
let props = this.spec.components?.viewport?.canvas3d;
|
||||
let props = this.spec.canvas3d;
|
||||
|
||||
const backgroundColor = Color(0xFCFBF9);
|
||||
if (!props) {
|
||||
@@ -294,7 +291,6 @@ export class PluginContext {
|
||||
this.ev.dispose();
|
||||
this.state.dispose();
|
||||
this.managers.task.dispose();
|
||||
this.layout.dispose();
|
||||
this.helpers.substructureParent.dispose();
|
||||
|
||||
objectForEach(this.managers, m => (m as any)?.dispose?.());
|
||||
@@ -385,12 +381,6 @@ export class PluginContext {
|
||||
}
|
||||
}
|
||||
|
||||
private initDataActions() {
|
||||
for (const a of this.spec.actions) {
|
||||
this.state.data.actions.add(a.action);
|
||||
}
|
||||
}
|
||||
|
||||
private initAnimations() {
|
||||
if (!this.spec.animations) return;
|
||||
for (const anim of this.spec.animations) {
|
||||
@@ -398,11 +388,10 @@ export class PluginContext {
|
||||
}
|
||||
}
|
||||
|
||||
private initCustomParamEditors() {
|
||||
if (!this.spec.customParamEditors) return;
|
||||
|
||||
for (const [t, e] of this.spec.customParamEditors) {
|
||||
this.customParamEditors.set(t.id, e);
|
||||
private initDataActions() {
|
||||
if (!this.spec.actions) return;
|
||||
for (const a of this.spec.actions) {
|
||||
this.state.data.actions.add(a.action);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -417,9 +406,8 @@ export class PluginContext {
|
||||
(this.managers.lociLabels as LociLabelManager) = new LociLabelManager(this);
|
||||
(this.builders.structure as StructureBuilder) = new StructureBuilder(this);
|
||||
|
||||
this.initDataActions();
|
||||
this.initAnimations();
|
||||
this.initCustomParamEditors();
|
||||
this.initDataActions();
|
||||
|
||||
await this.initBehaviors();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2018-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author David Sehnal <david.sehnal@gmail.com>
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
import { ParamDefinition as PD } from '../mol-util/param-definition';
|
||||
import { StatefulPluginComponent } from '../mol-plugin-state/component';
|
||||
import { PluginContext } from './context';
|
||||
import { PluginCommands } from './commands';
|
||||
import { PluginContext } from './context';
|
||||
|
||||
const regionStateOptions = [
|
||||
['full', 'Full'],
|
||||
|
||||
@@ -1,50 +1,37 @@
|
||||
/**
|
||||
* Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
* Copyright (c) 2018-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
||||
*
|
||||
* @author David Sehnal <david.sehnal@gmail.com>
|
||||
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
||||
*/
|
||||
|
||||
import { StateTransformer, StateAction } from '../mol-state';
|
||||
import { StateTransformParameters } from '../mol-plugin-ui/state/common';
|
||||
import { PluginLayoutStateProps } from './layout';
|
||||
import { PluginStateAnimation } from '../mol-plugin-state/animation/model';
|
||||
import { PluginConfigItem } from './config';
|
||||
import { PartialCanvas3DProps } from '../mol-canvas3d/canvas3d';
|
||||
import { DataFormatProvider } from '../mol-plugin-state/formats/provider';
|
||||
import { StateActions } from '../mol-plugin-state/actions';
|
||||
import { StateTransforms } from '../mol-plugin-state/transforms';
|
||||
import { VolumeStreamingCustomControls } from '../mol-plugin-ui/custom/volume';
|
||||
import { PluginBehaviors } from './behavior';
|
||||
import { StructureFocusRepresentation } from './behavior/dynamic/selection/structure-focus-representation';
|
||||
import { BoxifyVolumeStreaming, CreateVolumeStreamingBehavior, InitVolumeStreaming } from './behavior/dynamic/volume-streaming/transformers';
|
||||
import { AssignColorVolume } from '../mol-plugin-state/actions/volume';
|
||||
import { AnimateModelIndex } from '../mol-plugin-state/animation/built-in/model-index';
|
||||
import { AnimateAssemblyUnwind } from '../mol-plugin-state/animation/built-in/assembly-unwind';
|
||||
import { AnimateCameraSpin } from '../mol-plugin-state/animation/built-in/camera-spin';
|
||||
import { AnimateModelIndex } from '../mol-plugin-state/animation/built-in/model-index';
|
||||
import { AnimateStateSnapshots } from '../mol-plugin-state/animation/built-in/state-snapshots';
|
||||
import { PluginStateAnimation } from '../mol-plugin-state/animation/model';
|
||||
import { DataFormatProvider } from '../mol-plugin-state/formats/provider';
|
||||
import { StateAction, StateTransformer } from '../mol-state';
|
||||
import { PluginBehaviors } from './behavior';
|
||||
import { StructureFocusRepresentation } from './behavior/dynamic/selection/structure-focus-representation';
|
||||
import { PluginConfigItem } from './config';
|
||||
import { PluginLayoutStateProps } from './layout';
|
||||
import { StateActions } from '../mol-plugin-state/actions';
|
||||
import { AssignColorVolume } from '../mol-plugin-state/actions/volume';
|
||||
import { StateTransforms } from '../mol-plugin-state/transforms';
|
||||
import { BoxifyVolumeStreaming, CreateVolumeStreamingBehavior, InitVolumeStreaming } from '../mol-plugin/behavior/dynamic/volume-streaming/transformers';
|
||||
|
||||
export { PluginSpec };
|
||||
|
||||
interface PluginSpec {
|
||||
actions: PluginSpec.Action[],
|
||||
actions?: PluginSpec.Action[],
|
||||
behaviors: PluginSpec.Behavior[],
|
||||
animations?: PluginStateAnimation[],
|
||||
customParamEditors?: [StateAction | StateTransformer, StateTransformParameters.Class][],
|
||||
customFormats?: [string, DataFormatProvider][]
|
||||
customFormats?: [string, DataFormatProvider][],
|
||||
canvas3d?: PartialCanvas3DProps,
|
||||
layout?: {
|
||||
initial?: Partial<PluginLayoutStateProps>,
|
||||
controls?: PluginSpec.LayoutControls
|
||||
},
|
||||
components?: {
|
||||
remoteState?: 'none' | 'default',
|
||||
structureTools?: React.ComponentClass,
|
||||
viewport?: {
|
||||
view?: React.ComponentClass,
|
||||
controls?: React.ComponentClass,
|
||||
canvas3d?: PartialCanvas3DProps
|
||||
},
|
||||
hideTaskOverlay?: boolean
|
||||
},
|
||||
config?: [PluginConfigItem, unknown][]
|
||||
}
|
||||
@@ -52,11 +39,12 @@ interface PluginSpec {
|
||||
namespace PluginSpec {
|
||||
export interface Action {
|
||||
action: StateAction | StateTransformer,
|
||||
customControl?: StateTransformParameters.Class,
|
||||
/* constructible react component with <action.customControl /> */
|
||||
customControl?: any,
|
||||
autoUpdate?: boolean
|
||||
}
|
||||
|
||||
export function Action(action: StateAction | StateTransformer, params?: { customControl?: StateTransformParameters.Class, autoUpdate?: boolean }): Action {
|
||||
export function Action(action: StateAction | StateTransformer, params?: { customControl?: any /* constructible react component with <action.customControl /> */, autoUpdate?: boolean }): Action {
|
||||
return { action, customControl: params && params.customControl, autoUpdate: params && params.autoUpdate };
|
||||
}
|
||||
|
||||
@@ -68,13 +56,6 @@ namespace PluginSpec {
|
||||
export function Behavior<T extends StateTransformer>(transformer: T, defaultParams: Partial<StateTransformer.Params<T>> = {}): Behavior {
|
||||
return { transformer, defaultParams };
|
||||
}
|
||||
|
||||
export interface LayoutControls {
|
||||
top?: React.ComponentClass | 'none',
|
||||
left?: React.ComponentClass | 'none',
|
||||
right?: React.ComponentClass | 'none',
|
||||
bottom?: React.ComponentClass | 'none'
|
||||
}
|
||||
}
|
||||
|
||||
export const DefaultPluginSpec = (): PluginSpec => ({
|
||||
@@ -139,9 +120,6 @@ export const DefaultPluginSpec = (): PluginSpec => ({
|
||||
PluginSpec.Behavior(PluginBehaviors.CustomProps.ValenceModel),
|
||||
PluginSpec.Behavior(PluginBehaviors.CustomProps.CrossLinkRestraint),
|
||||
],
|
||||
customParamEditors: [
|
||||
[CreateVolumeStreamingBehavior, VolumeStreamingCustomControls]
|
||||
],
|
||||
animations: [
|
||||
AnimateModelIndex,
|
||||
AnimateCameraSpin,
|
||||
|
||||
@@ -14,9 +14,9 @@ import { PluginCommands } from '../commands';
|
||||
export interface PluginToast {
|
||||
title: string,
|
||||
/**
|
||||
* The message can be either a string, html string, or an arbitrary React component.
|
||||
* The message can be either a string, html string, or an arbitrary React (Function) component.
|
||||
*/
|
||||
message: string | React.ComponentClass,
|
||||
message: string | Function,
|
||||
/**
|
||||
* Only one message with a given key can be shown.
|
||||
*/
|
||||
@@ -103,7 +103,7 @@ export namespace PluginToastManager {
|
||||
serialNumber: number,
|
||||
key?: string,
|
||||
title: string,
|
||||
message: string | React.ComponentClass,
|
||||
message: string | Function,
|
||||
hide: () => void,
|
||||
timeout?: number
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user