From 0e5ed275134a9bd9a0de8c4b621461866bc4154d Mon Sep 17 00:00:00 2001 From: David Sehnal <david.sehnal@gmail.com> Date: Mon, 29 Oct 2018 15:42:02 +0100 Subject: [PATCH] Renamed mol-view mol-canvas3d, moved parameters.ts to mol-util, added mol-plugin --- README.md | 8 +- package.json | 3 +- src/apps/canvas/app.ts | 2 +- src/apps/canvas/assembly-symmetry.ts | 2 +- src/apps/canvas/component/representation.tsx | 6 +- src/apps/canvas/component/viewport.tsx | 2 +- src/apps/canvas/structure-view.ts | 2 +- src/apps/canvas/volume-view.ts | 2 +- src/mol-app/component/color-theme.tsx | 2 +- src/mol-app/component/parameter/boolean.tsx | 2 +- .../component/parameter/multi-select.tsx | 2 +- src/mol-app/component/parameter/number.tsx | 2 +- src/mol-app/component/parameter/range.tsx | 2 +- src/mol-app/component/parameter/select.tsx | 2 +- src/mol-app/component/parameter/text.tsx | 2 +- src/mol-app/component/parameters.tsx | 2 +- src/{mol-view => mol-canvas3d}/camera/base.ts | 0 .../camera/orthographic.ts | 0 .../camera/perspective.ts | 0 src/{mol-view => mol-canvas3d}/camera/util.ts | 0 .../controls/trackball.ts | 0 src/{mol-view => mol-canvas3d}/label.ts | 0 src/{mol-view => mol-canvas3d}/theme/color.ts | 0 .../theme/color/carbohydrate-symbol.ts | 0 .../theme/color/chain-id.ts | 0 .../theme/color/cross-link.ts | 0 .../theme/color/custom.ts | 0 .../theme/color/element-index.ts | 0 .../theme/color/element-symbol.ts | 0 .../theme/color/molecule-type.ts | 0 .../theme/color/residue-name.ts | 0 .../theme/color/secondary-structure.ts | 0 .../theme/color/sequence-id.ts | 0 .../theme/color/shape-group.ts | 0 .../theme/color/uniform.ts | 0 .../theme/color/unit-index.ts | 0 src/{mol-view => mol-canvas3d}/theme/size.ts | 0 .../theme/size/physical.ts | 0 .../theme/size/uniform.ts | 0 src/mol-canvas3d/util.ts | 18 ++ src/{mol-view => mol-canvas3d}/viewer.ts | 0 src/mol-geo/geometry/color-data.ts | 2 +- .../geometry/direct-volume/direct-volume.ts | 2 +- .../direct-volume/transfer-function.ts | 2 +- src/mol-geo/geometry/geometry.ts | 4 +- src/mol-geo/geometry/lines/lines.ts | 4 +- src/mol-geo/geometry/mesh/mesh.ts | 2 +- src/mol-geo/geometry/points/points.ts | 4 +- src/mol-geo/geometry/size-data.ts | 2 +- src/mol-geo/representation/index.ts | 2 +- src/mol-geo/representation/shape/index.ts | 4 +- .../structure/complex-visual.ts | 2 +- src/mol-geo/representation/structure/index.ts | 6 +- .../structure/representation/backbone.ts | 2 +- .../representation/ball-and-stick.ts | 4 +- .../structure/representation/carbohydrate.ts | 4 +- .../structure/representation/cartoon.ts | 4 +- .../representation/distance-restraint.ts | 4 +- .../representation/molecular-surface.ts | 4 +- .../structure/representation/point.ts | 2 +- .../structure/representation/spacefill.ts | 2 +- .../representation/structure/units-visual.ts | 2 +- .../visual/carbohydrate-link-cylinder.ts | 4 +- .../visual/carbohydrate-symbol-mesh.ts | 4 +- .../visual/cross-link-restraint-cylinder.ts | 4 +- .../structure/visual/element-point.ts | 4 +- .../structure/visual/element-sphere.ts | 4 +- .../visual/gaussian-density-point.ts | 4 +- .../visual/gaussian-density-volume.ts | 2 +- .../structure/visual/gaussian-surface-mesh.ts | 2 +- .../visual/gaussian-surface-wireframe.ts | 4 +- .../visual/inter-unit-link-cylinder.ts | 4 +- .../visual/intra-unit-link-cylinder.ts | 4 +- .../structure/visual/nucleotide-block-mesh.ts | 2 +- .../visual/polymer-backbone-cylinder.ts | 4 +- .../visual/polymer-direction-wedge.ts | 4 +- .../structure/visual/polymer-gap-cylinder.ts | 4 +- .../structure/visual/polymer-trace-mesh.ts | 4 +- .../structure/visual/util/element.ts | 2 +- .../structure/visual/util/link.ts | 4 +- .../representation/volume/direct-volume.ts | 2 +- src/mol-geo/representation/volume/index.ts | 2 +- .../representation/volume/isosurface-mesh.ts | 2 +- src/mol-gl/_spec/renderer.spec.ts | 2 +- src/mol-gl/renderer.ts | 4 +- .../structure/unit/gaussian-density.ts | 4 +- src/mol-plugin/index.ts | 7 + src/mol-util/color/scale.ts | 2 +- src/{mol-view => mol-util}/parameter.ts | 0 src/mol-view/state/context.ts | 28 -- src/mol-view/state/entity.ts | 162 ----------- src/mol-view/state/transform.ts | 274 ------------------ src/mol-view/util.ts | 43 --- tsconfig.json | 3 +- 94 files changed, 123 insertions(+), 601 deletions(-) rename src/{mol-view => mol-canvas3d}/camera/base.ts (100%) rename src/{mol-view => mol-canvas3d}/camera/orthographic.ts (100%) rename src/{mol-view => mol-canvas3d}/camera/perspective.ts (100%) rename src/{mol-view => mol-canvas3d}/camera/util.ts (100%) rename src/{mol-view => mol-canvas3d}/controls/trackball.ts (100%) rename src/{mol-view => mol-canvas3d}/label.ts (100%) rename src/{mol-view => mol-canvas3d}/theme/color.ts (100%) rename src/{mol-view => mol-canvas3d}/theme/color/carbohydrate-symbol.ts (100%) rename src/{mol-view => mol-canvas3d}/theme/color/chain-id.ts (100%) rename src/{mol-view => mol-canvas3d}/theme/color/cross-link.ts (100%) rename src/{mol-view => mol-canvas3d}/theme/color/custom.ts (100%) rename src/{mol-view => mol-canvas3d}/theme/color/element-index.ts (100%) rename src/{mol-view => mol-canvas3d}/theme/color/element-symbol.ts (100%) rename src/{mol-view => mol-canvas3d}/theme/color/molecule-type.ts (100%) rename src/{mol-view => mol-canvas3d}/theme/color/residue-name.ts (100%) rename src/{mol-view => mol-canvas3d}/theme/color/secondary-structure.ts (100%) rename src/{mol-view => mol-canvas3d}/theme/color/sequence-id.ts (100%) rename src/{mol-view => mol-canvas3d}/theme/color/shape-group.ts (100%) rename src/{mol-view => mol-canvas3d}/theme/color/uniform.ts (100%) rename src/{mol-view => mol-canvas3d}/theme/color/unit-index.ts (100%) rename src/{mol-view => mol-canvas3d}/theme/size.ts (100%) rename src/{mol-view => mol-canvas3d}/theme/size/physical.ts (100%) rename src/{mol-view => mol-canvas3d}/theme/size/uniform.ts (100%) create mode 100644 src/mol-canvas3d/util.ts rename src/{mol-view => mol-canvas3d}/viewer.ts (100%) create mode 100644 src/mol-plugin/index.ts rename src/{mol-view => mol-util}/parameter.ts (100%) delete mode 100644 src/mol-view/state/context.ts delete mode 100644 src/mol-view/state/entity.ts delete mode 100644 src/mol-view/state/transform.ts delete mode 100644 src/mol-view/util.ts diff --git a/README.md b/README.md index 56b4a5658..0bdff19ce 100644 --- a/README.md +++ b/README.md @@ -17,12 +17,14 @@ The core of Mol* currently consists of these modules: - `mol-math` Math related (loosely) algorithms and data structures. - `mol-io` Parsing library. Each format is parsed into an interface that corresponds to the data stored by it. Support for common coordinate, experimental/map, and annotation data formats. - `mol-model` Data structures and algorithms (such as querying) for representing molecular data (including coordinate, experimental/map, and annotation data). -- `mol-model-props` Common "custom properties" +- `mol-model-props` Common "custom properties". - `mol-script` A scriting language for creating representations/scenes and querying (includes the [MolQL query language](https://molql.github.io)). - `mol-geo` Creating molecular geometries. -- `mol-gl` A wrapper around WebGL. Uses `mol-geo` to generate geometries. +- `mol-gl` A lightweight wrapper around WebGL. +- `mol-canvas3d` A low level 3d view component. Uses `mol-geo` to generate geometries. +- `mol-state` State representation tree with state saving and automatic updates. - `mol-app` Components for builduing UIs. -- `mol-view` A reference viewer implementation. +- `mol-plugin` Allow to define modular Mol* plugin instances utilizing `mol-state` and `mol-view3d`. - `mol-util` Useful things that do not fit elsewhere. Moreover, the project contains the imlementation of `servers`, including diff --git a/package.json b/package.json index 6a807c3a0..9cb1cdafb 100644 --- a/package.json +++ b/package.json @@ -61,8 +61,9 @@ "mol-script($|/.*)": "<rootDir>/src/mol-script$1", "mol-task($|/.*)": "<rootDir>/src/mol-task$1", "mol-state($|/.*)": "<rootDir>/src/mol-state$1", + "mol-plugin($|/.*)": "<rootDir>/src/mol-plugin$1", "mol-util($|/.*)": "<rootDir>/src/mol-util$1", - "mol-view($|/.*)": "<rootDir>/src/mol-view$1" + "mol-canvas3d($|/.*)": "<rootDir>/src/mol-canvas3d$1" }, "testRegex": "\\.spec\\.ts$" }, diff --git a/src/apps/canvas/app.ts b/src/apps/canvas/app.ts index f72add32b..0abfc41d4 100644 --- a/src/apps/canvas/app.ts +++ b/src/apps/canvas/app.ts @@ -4,7 +4,7 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -import Viewer from 'mol-view/viewer'; +import Viewer from 'mol-canvas3d/viewer'; import { getCifFromUrl, getModelsFromMmcif, getCifFromFile, getCcp4FromUrl, getVolumeFromCcp4, getCcp4FromFile, getVolumeFromVolcif } from './util'; import { StructureView } from './structure-view'; import { BehaviorSubject } from 'rxjs'; diff --git a/src/apps/canvas/assembly-symmetry.ts b/src/apps/canvas/assembly-symmetry.ts index ee4d68327..6929fb091 100644 --- a/src/apps/canvas/assembly-symmetry.ts +++ b/src/apps/canvas/assembly-symmetry.ts @@ -12,7 +12,7 @@ import { Tensor } from 'mol-math/linear-algebra'; import { addSphere } from 'mol-geo/geometry/mesh/builder/sphere'; import { addCylinder } from 'mol-geo/geometry/mesh/builder/cylinder'; import { Shape } from 'mol-model/shape'; -import { ColorTheme } from 'mol-view/theme/color'; +import { ColorTheme } from 'mol-canvas3d/theme/color'; import { Location } from 'mol-model/location'; import { StructureElement, Unit, StructureProperties } from 'mol-model/structure'; diff --git a/src/apps/canvas/component/representation.tsx b/src/apps/canvas/component/representation.tsx index 56928666f..c5284562e 100644 --- a/src/apps/canvas/component/representation.tsx +++ b/src/apps/canvas/component/representation.tsx @@ -5,13 +5,13 @@ */ import * as React from 'react' -import Viewer from 'mol-view/viewer'; +import Viewer from 'mol-canvas3d/viewer'; import { App } from '../app'; -import { Params } from 'mol-view/parameter'; +import { Params } from 'mol-util/parameter'; import { Representation } from 'mol-geo/representation'; import { ParametersComponent } from 'mol-app/component/parameters'; import { Progress } from 'mol-task'; -import { ColorTheme } from 'mol-view/theme/color'; +import { ColorTheme } from 'mol-canvas3d/theme/color'; import { getColorThemeProps } from 'mol-geo/geometry/color-data'; import { ColorThemeComponent } from 'mol-app/component/color-theme'; diff --git a/src/apps/canvas/component/viewport.tsx b/src/apps/canvas/component/viewport.tsx index 0085461d7..7814b2647 100644 --- a/src/apps/canvas/component/viewport.tsx +++ b/src/apps/canvas/component/viewport.tsx @@ -8,7 +8,7 @@ import * as React from 'react' import { App } from '../app'; import { MarkerAction } from 'mol-geo/geometry/marker-data'; import { EmptyLoci, Loci, areLociEqual } from 'mol-model/loci'; -import { labelFirst } from 'mol-view/label'; +import { labelFirst } from 'mol-canvas3d/label'; interface ViewportProps { app: App diff --git a/src/apps/canvas/structure-view.ts b/src/apps/canvas/structure-view.ts index bd35a273e..afdad4d60 100644 --- a/src/apps/canvas/structure-view.ts +++ b/src/apps/canvas/structure-view.ts @@ -11,7 +11,7 @@ import { getStructureFromModel } from './util'; import { AssemblySymmetry } from 'mol-model-props/rcsb/symmetry'; import { ShapeRepresentation, ShapeProps } from 'mol-geo/representation/shape'; import { getAxesShape } from './assembly-symmetry'; -import Viewer from 'mol-view/viewer'; +import Viewer from 'mol-canvas3d/viewer'; import { CarbohydrateRepresentation } from 'mol-geo/representation/structure/representation/carbohydrate'; // import { MeshBuilder } from 'mol-geo/mesh/mesh-builder'; // import { addSphere } from 'mol-geo/mesh/builder/sphere'; diff --git a/src/apps/canvas/volume-view.ts b/src/apps/canvas/volume-view.ts index 1ef40f6dd..a68038391 100644 --- a/src/apps/canvas/volume-view.ts +++ b/src/apps/canvas/volume-view.ts @@ -4,7 +4,7 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -import Viewer from 'mol-view/viewer'; +import Viewer from 'mol-canvas3d/viewer'; import { BehaviorSubject } from 'rxjs'; import { App } from './app'; import { Progress } from 'mol-task'; diff --git a/src/mol-app/component/color-theme.tsx b/src/mol-app/component/color-theme.tsx index 4b4c78311..3c8b414de 100644 --- a/src/mol-app/component/color-theme.tsx +++ b/src/mol-app/component/color-theme.tsx @@ -5,7 +5,7 @@ */ import * as React from 'react' -import { ColorTheme } from 'mol-view/theme/color'; +import { ColorTheme } from 'mol-canvas3d/theme/color'; import { Color } from 'mol-util/color'; export interface ColorThemeComponentProps { diff --git a/src/mol-app/component/parameter/boolean.tsx b/src/mol-app/component/parameter/boolean.tsx index 997b2ca5c..5862efc1d 100644 --- a/src/mol-app/component/parameter/boolean.tsx +++ b/src/mol-app/component/parameter/boolean.tsx @@ -5,7 +5,7 @@ */ import * as React from 'react' -import { BooleanParam } from 'mol-view/parameter'; +import { BooleanParam } from 'mol-util/parameter'; export interface BooleanParamComponentProps { param: BooleanParam diff --git a/src/mol-app/component/parameter/multi-select.tsx b/src/mol-app/component/parameter/multi-select.tsx index d23e31fee..79e66af6b 100644 --- a/src/mol-app/component/parameter/multi-select.tsx +++ b/src/mol-app/component/parameter/multi-select.tsx @@ -5,7 +5,7 @@ */ import * as React from 'react' -import { MultiSelectParam } from 'mol-view/parameter'; +import { MultiSelectParam } from 'mol-util/parameter'; export interface MultiSelectParamComponentProps<T extends string> { param: MultiSelectParam<T> diff --git a/src/mol-app/component/parameter/number.tsx b/src/mol-app/component/parameter/number.tsx index be97aee26..c693b7d91 100644 --- a/src/mol-app/component/parameter/number.tsx +++ b/src/mol-app/component/parameter/number.tsx @@ -5,7 +5,7 @@ */ import * as React from 'react' -import { NumberParam } from 'mol-view/parameter'; +import { NumberParam } from 'mol-util/parameter'; export interface NumberParamComponentProps { param: NumberParam diff --git a/src/mol-app/component/parameter/range.tsx b/src/mol-app/component/parameter/range.tsx index dd9c82fa2..42d5450a1 100644 --- a/src/mol-app/component/parameter/range.tsx +++ b/src/mol-app/component/parameter/range.tsx @@ -5,7 +5,7 @@ */ import * as React from 'react' -import { RangeParam } from 'mol-view/parameter'; +import { RangeParam } from 'mol-util/parameter'; export interface RangeParamComponentProps { param: RangeParam diff --git a/src/mol-app/component/parameter/select.tsx b/src/mol-app/component/parameter/select.tsx index e403bbb79..c0034953f 100644 --- a/src/mol-app/component/parameter/select.tsx +++ b/src/mol-app/component/parameter/select.tsx @@ -5,7 +5,7 @@ */ import * as React from 'react' -import { SelectParam } from 'mol-view/parameter'; +import { SelectParam } from 'mol-util/parameter'; export interface SelectParamComponentProps<T extends string> { param: SelectParam<T> diff --git a/src/mol-app/component/parameter/text.tsx b/src/mol-app/component/parameter/text.tsx index cd6ad76f7..507754f5f 100644 --- a/src/mol-app/component/parameter/text.tsx +++ b/src/mol-app/component/parameter/text.tsx @@ -5,7 +5,7 @@ */ import * as React from 'react' -import { TextParam } from 'mol-view/parameter'; +import { TextParam } from 'mol-util/parameter'; export interface TextParamComponentProps { param: TextParam diff --git a/src/mol-app/component/parameters.tsx b/src/mol-app/component/parameters.tsx index 70e2aee37..0fc247b25 100644 --- a/src/mol-app/component/parameters.tsx +++ b/src/mol-app/component/parameters.tsx @@ -5,7 +5,7 @@ */ import * as React from 'react' -import { Param, Params } from 'mol-view/parameter'; +import { Param, Params } from 'mol-util/parameter'; import { BooleanParamComponent } from './parameter/boolean'; import { NumberParamComponent } from './parameter/number'; import { RangeParamComponent } from './parameter/range'; diff --git a/src/mol-view/camera/base.ts b/src/mol-canvas3d/camera/base.ts similarity index 100% rename from src/mol-view/camera/base.ts rename to src/mol-canvas3d/camera/base.ts diff --git a/src/mol-view/camera/orthographic.ts b/src/mol-canvas3d/camera/orthographic.ts similarity index 100% rename from src/mol-view/camera/orthographic.ts rename to src/mol-canvas3d/camera/orthographic.ts diff --git a/src/mol-view/camera/perspective.ts b/src/mol-canvas3d/camera/perspective.ts similarity index 100% rename from src/mol-view/camera/perspective.ts rename to src/mol-canvas3d/camera/perspective.ts diff --git a/src/mol-view/camera/util.ts b/src/mol-canvas3d/camera/util.ts similarity index 100% rename from src/mol-view/camera/util.ts rename to src/mol-canvas3d/camera/util.ts diff --git a/src/mol-view/controls/trackball.ts b/src/mol-canvas3d/controls/trackball.ts similarity index 100% rename from src/mol-view/controls/trackball.ts rename to src/mol-canvas3d/controls/trackball.ts diff --git a/src/mol-view/label.ts b/src/mol-canvas3d/label.ts similarity index 100% rename from src/mol-view/label.ts rename to src/mol-canvas3d/label.ts diff --git a/src/mol-view/theme/color.ts b/src/mol-canvas3d/theme/color.ts similarity index 100% rename from src/mol-view/theme/color.ts rename to src/mol-canvas3d/theme/color.ts diff --git a/src/mol-view/theme/color/carbohydrate-symbol.ts b/src/mol-canvas3d/theme/color/carbohydrate-symbol.ts similarity index 100% rename from src/mol-view/theme/color/carbohydrate-symbol.ts rename to src/mol-canvas3d/theme/color/carbohydrate-symbol.ts diff --git a/src/mol-view/theme/color/chain-id.ts b/src/mol-canvas3d/theme/color/chain-id.ts similarity index 100% rename from src/mol-view/theme/color/chain-id.ts rename to src/mol-canvas3d/theme/color/chain-id.ts diff --git a/src/mol-view/theme/color/cross-link.ts b/src/mol-canvas3d/theme/color/cross-link.ts similarity index 100% rename from src/mol-view/theme/color/cross-link.ts rename to src/mol-canvas3d/theme/color/cross-link.ts diff --git a/src/mol-view/theme/color/custom.ts b/src/mol-canvas3d/theme/color/custom.ts similarity index 100% rename from src/mol-view/theme/color/custom.ts rename to src/mol-canvas3d/theme/color/custom.ts diff --git a/src/mol-view/theme/color/element-index.ts b/src/mol-canvas3d/theme/color/element-index.ts similarity index 100% rename from src/mol-view/theme/color/element-index.ts rename to src/mol-canvas3d/theme/color/element-index.ts diff --git a/src/mol-view/theme/color/element-symbol.ts b/src/mol-canvas3d/theme/color/element-symbol.ts similarity index 100% rename from src/mol-view/theme/color/element-symbol.ts rename to src/mol-canvas3d/theme/color/element-symbol.ts diff --git a/src/mol-view/theme/color/molecule-type.ts b/src/mol-canvas3d/theme/color/molecule-type.ts similarity index 100% rename from src/mol-view/theme/color/molecule-type.ts rename to src/mol-canvas3d/theme/color/molecule-type.ts diff --git a/src/mol-view/theme/color/residue-name.ts b/src/mol-canvas3d/theme/color/residue-name.ts similarity index 100% rename from src/mol-view/theme/color/residue-name.ts rename to src/mol-canvas3d/theme/color/residue-name.ts diff --git a/src/mol-view/theme/color/secondary-structure.ts b/src/mol-canvas3d/theme/color/secondary-structure.ts similarity index 100% rename from src/mol-view/theme/color/secondary-structure.ts rename to src/mol-canvas3d/theme/color/secondary-structure.ts diff --git a/src/mol-view/theme/color/sequence-id.ts b/src/mol-canvas3d/theme/color/sequence-id.ts similarity index 100% rename from src/mol-view/theme/color/sequence-id.ts rename to src/mol-canvas3d/theme/color/sequence-id.ts diff --git a/src/mol-view/theme/color/shape-group.ts b/src/mol-canvas3d/theme/color/shape-group.ts similarity index 100% rename from src/mol-view/theme/color/shape-group.ts rename to src/mol-canvas3d/theme/color/shape-group.ts diff --git a/src/mol-view/theme/color/uniform.ts b/src/mol-canvas3d/theme/color/uniform.ts similarity index 100% rename from src/mol-view/theme/color/uniform.ts rename to src/mol-canvas3d/theme/color/uniform.ts diff --git a/src/mol-view/theme/color/unit-index.ts b/src/mol-canvas3d/theme/color/unit-index.ts similarity index 100% rename from src/mol-view/theme/color/unit-index.ts rename to src/mol-canvas3d/theme/color/unit-index.ts diff --git a/src/mol-view/theme/size.ts b/src/mol-canvas3d/theme/size.ts similarity index 100% rename from src/mol-view/theme/size.ts rename to src/mol-canvas3d/theme/size.ts diff --git a/src/mol-view/theme/size/physical.ts b/src/mol-canvas3d/theme/size/physical.ts similarity index 100% rename from src/mol-view/theme/size/physical.ts rename to src/mol-canvas3d/theme/size/physical.ts diff --git a/src/mol-view/theme/size/uniform.ts b/src/mol-canvas3d/theme/size/uniform.ts similarity index 100% rename from src/mol-view/theme/size/uniform.ts rename to src/mol-canvas3d/theme/size/uniform.ts diff --git a/src/mol-canvas3d/util.ts b/src/mol-canvas3d/util.ts new file mode 100644 index 000000000..294907ad3 --- /dev/null +++ b/src/mol-canvas3d/util.ts @@ -0,0 +1,18 @@ +/** + * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. + * + * @author Alexander Rose <alexander.rose@weirdbyte.de> + */ + +export function resizeCanvas (canvas: HTMLCanvasElement, container: Element) { + let w = window.innerWidth + let h = window.innerHeight + if (container !== document.body) { + let bounds = container.getBoundingClientRect() + w = bounds.right - bounds.left + h = bounds.bottom - bounds.top + } + canvas.width = window.devicePixelRatio * w + canvas.height = window.devicePixelRatio * h + Object.assign(canvas.style, { width: `${w}px`, height: `${h}px` }) +} \ No newline at end of file diff --git a/src/mol-view/viewer.ts b/src/mol-canvas3d/viewer.ts similarity index 100% rename from src/mol-view/viewer.ts rename to src/mol-canvas3d/viewer.ts diff --git a/src/mol-geo/geometry/color-data.ts b/src/mol-geo/geometry/color-data.ts index b02d20440..fe1dfae7b 100644 --- a/src/mol-geo/geometry/color-data.ts +++ b/src/mol-geo/geometry/color-data.ts @@ -10,7 +10,7 @@ import { Color } from 'mol-util/color'; import { Vec2, Vec3 } from 'mol-math/linear-algebra'; import { LocationIterator } from '../util/location-iterator'; import { NullLocation } from 'mol-model/location'; -import { LocationColor, ColorThemeProps, ColorTheme, ColorThemeName } from 'mol-view/theme/color'; +import { LocationColor, ColorThemeProps, ColorTheme, ColorThemeName } from 'mol-canvas3d/theme/color'; import { RuntimeContext } from 'mol-task'; import { getGranularity } from './geometry'; import { Structure } from 'mol-model/structure'; diff --git a/src/mol-geo/geometry/direct-volume/direct-volume.ts b/src/mol-geo/geometry/direct-volume/direct-volume.ts index 76458adaa..d0057084b 100644 --- a/src/mol-geo/geometry/direct-volume/direct-volume.ts +++ b/src/mol-geo/geometry/direct-volume/direct-volume.ts @@ -7,7 +7,7 @@ import { RuntimeContext } from 'mol-task' import { ValueCell } from 'mol-util' import { Sphere3D, Box3D } from 'mol-math/geometry' -import { paramDefaultValues, RangeParam, SelectParam, TextParam } from 'mol-view/parameter'; +import { paramDefaultValues, RangeParam, SelectParam, TextParam } from 'mol-util/parameter'; import { DirectVolumeValues } from 'mol-gl/renderable/direct-volume'; import { Vec3, Mat4 } from 'mol-math/linear-algebra'; import { Box } from '../../primitive/box'; diff --git a/src/mol-geo/geometry/direct-volume/transfer-function.ts b/src/mol-geo/geometry/direct-volume/transfer-function.ts index 9c6cd1424..98f496f14 100644 --- a/src/mol-geo/geometry/direct-volume/transfer-function.ts +++ b/src/mol-geo/geometry/direct-volume/transfer-function.ts @@ -18,7 +18,7 @@ export function getControlPointsFromString(s: string): ControlPoint[] { return { x: parseFloat(ps[0]), alpha: parseFloat(ps[1]) } }) } -// TODO move core function to mol-view/color +// TODO move core function to mol-canvas3d/color export function createTransferFunctionTexture(controlPoints: ControlPoint[], texture?: ValueCell<TextureImage<Uint8Array>>): ValueCell<TextureImage<Uint8Array>> { const cp = [ { x: 0, alpha: 0 }, diff --git a/src/mol-geo/geometry/geometry.ts b/src/mol-geo/geometry/geometry.ts index d9e7e2f0d..86f4ba51b 100644 --- a/src/mol-geo/geometry/geometry.ts +++ b/src/mol-geo/geometry/geometry.ts @@ -10,12 +10,12 @@ import { RenderableState } from 'mol-gl/renderable'; import { ValueCell } from 'mol-util'; import { BaseValues } from 'mol-gl/renderable/schema'; import { Color } from 'mol-util/color'; -import { ColorThemeOptions, ColorThemeName } from 'mol-view/theme/color'; +import { ColorThemeOptions, ColorThemeName } from 'mol-canvas3d/theme/color'; import { LocationIterator } from '../util/location-iterator'; import { ColorType } from './color-data'; import { SizeType } from './size-data'; import { Lines } from './lines/lines'; -import { paramDefaultValues, RangeParam, BooleanParam, SelectParam, ColorParam, StructureParam, ValueParam } from 'mol-view/parameter' +import { paramDefaultValues, RangeParam, BooleanParam, SelectParam, ColorParam, StructureParam, ValueParam } from 'mol-util/parameter' import { Structure } from 'mol-model/structure'; import { DirectVolume } from './direct-volume/direct-volume'; import { Context } from 'mol-gl/webgl/context'; diff --git a/src/mol-geo/geometry/lines/lines.ts b/src/mol-geo/geometry/lines/lines.ts index 84b565d1d..c4e80b3f3 100644 --- a/src/mol-geo/geometry/lines/lines.ts +++ b/src/mol-geo/geometry/lines/lines.ts @@ -14,11 +14,11 @@ import { createMarkers } from '../marker-data'; import { createSizes } from '../size-data'; import { TransformData } from '../transform-data'; import { LocationIterator } from '../../util/location-iterator'; -import { SizeThemeName, SizeThemeOptions } from 'mol-view/theme/size'; +import { SizeThemeName, SizeThemeOptions } from 'mol-canvas3d/theme/size'; import { LinesValues } from 'mol-gl/renderable/lines'; import { Mesh } from '../mesh/mesh'; import { LinesBuilder } from './lines-builder'; -import { BooleanParam, SelectParam, NumberParam, paramDefaultValues } from 'mol-view/parameter'; +import { BooleanParam, SelectParam, NumberParam, paramDefaultValues } from 'mol-util/parameter'; /** Wide line */ export interface Lines { diff --git a/src/mol-geo/geometry/mesh/mesh.ts b/src/mol-geo/geometry/mesh/mesh.ts index ad4cec0ba..14a204f9c 100644 --- a/src/mol-geo/geometry/mesh/mesh.ts +++ b/src/mol-geo/geometry/mesh/mesh.ts @@ -16,7 +16,7 @@ import { TransformData } from '../transform-data'; import { LocationIterator } from '../../util/location-iterator'; import { createColors } from '../color-data'; import { ChunkedArray } from 'mol-data/util'; -import { BooleanParam, paramDefaultValues } from 'mol-view/parameter'; +import { BooleanParam, paramDefaultValues } from 'mol-util/parameter'; export interface Mesh { readonly kind: 'mesh', diff --git a/src/mol-geo/geometry/points/points.ts b/src/mol-geo/geometry/points/points.ts index 3181353cf..3a4799600 100644 --- a/src/mol-geo/geometry/points/points.ts +++ b/src/mol-geo/geometry/points/points.ts @@ -15,8 +15,8 @@ import { createMarkers } from '../marker-data'; import { createSizes } from '../size-data'; import { TransformData } from '../transform-data'; import { LocationIterator } from '../../util/location-iterator'; -import { SizeThemeName, SizeThemeOptions } from 'mol-view/theme/size'; -import { BooleanParam, NumberParam, SelectParam, paramDefaultValues } from 'mol-view/parameter'; +import { SizeThemeName, SizeThemeOptions } from 'mol-canvas3d/theme/size'; +import { BooleanParam, NumberParam, SelectParam, paramDefaultValues } from 'mol-util/parameter'; /** Point cloud */ export interface Points { diff --git a/src/mol-geo/geometry/size-data.ts b/src/mol-geo/geometry/size-data.ts index 81373ef58..8a5d574b3 100644 --- a/src/mol-geo/geometry/size-data.ts +++ b/src/mol-geo/geometry/size-data.ts @@ -10,7 +10,7 @@ import { TextureImage, createTextureImage } from 'mol-gl/renderable/util'; import { LocationIterator } from '../util/location-iterator'; import { Location, NullLocation } from 'mol-model/location'; import { RuntimeContext } from 'mol-task'; -import { SizeThemeProps, SizeTheme, SizeThemeName } from 'mol-view/theme/size'; +import { SizeThemeProps, SizeTheme, SizeThemeName } from 'mol-canvas3d/theme/size'; import { getGranularity } from './geometry'; import { Structure } from 'mol-model/structure'; diff --git a/src/mol-geo/representation/index.ts b/src/mol-geo/representation/index.ts index 0a35e6e89..e9ca9e4c2 100644 --- a/src/mol-geo/representation/index.ts +++ b/src/mol-geo/representation/index.ts @@ -9,7 +9,7 @@ import { RenderObject } from 'mol-gl/render-object' import { PickingId } from '../geometry/picking'; import { Loci } from 'mol-model/loci'; import { MarkerAction } from '../geometry/marker-data'; -import { Params } from 'mol-view/parameter'; +import { Params } from 'mol-util/parameter'; export interface RepresentationProps {} diff --git a/src/mol-geo/representation/shape/index.ts b/src/mol-geo/representation/shape/index.ts index 6c1f7b1ff..43b4d06f6 100644 --- a/src/mol-geo/representation/shape/index.ts +++ b/src/mol-geo/representation/shape/index.ts @@ -11,14 +11,14 @@ import { PickingId } from '../../geometry/picking'; import { Loci, EmptyLoci, isEveryLoci } from 'mol-model/loci'; import { MarkerAction, applyMarkerAction } from '../../geometry/marker-data'; import { ValueCell } from 'mol-util'; -import { ColorThemeName, ColorThemeOptions } from 'mol-view/theme/color'; +import { ColorThemeName, ColorThemeOptions } from 'mol-canvas3d/theme/color'; import { Shape } from 'mol-model/shape'; import { LocationIterator } from '../../util/location-iterator'; import { OrderedSet, Interval } from 'mol-data/int'; import { createIdentityTransform } from '../../geometry/transform-data'; import { createRenderableState } from '../../geometry/geometry'; import { Mesh } from '../../geometry/mesh/mesh'; -import { paramDefaultValues, SelectParam } from 'mol-view/parameter'; +import { paramDefaultValues, SelectParam } from 'mol-util/parameter'; export interface ShapeRepresentation<P extends RepresentationProps = {}> extends Representation<Shape, P> { } diff --git a/src/mol-geo/representation/structure/complex-visual.ts b/src/mol-geo/representation/structure/complex-visual.ts index 02bfb7958..aac01779c 100644 --- a/src/mol-geo/representation/structure/complex-visual.ts +++ b/src/mol-geo/representation/structure/complex-visual.ts @@ -19,7 +19,7 @@ import { MarkerAction, applyMarkerAction } from '../../geometry/marker-data'; import { Interval } from 'mol-data/int'; import { updateRenderableState, Geometry } from '../../geometry/geometry'; import { createColors } from '../../geometry/color-data'; -import { MultiSelectParam, paramDefaultValues } from 'mol-view/parameter'; +import { MultiSelectParam, paramDefaultValues } from 'mol-util/parameter'; import { RenderableValues } from 'mol-gl/renderable/schema'; import { createSizes } from 'mol-geo/geometry/size-data'; diff --git a/src/mol-geo/representation/structure/index.ts b/src/mol-geo/representation/structure/index.ts index b5c094fc2..01769aeab 100644 --- a/src/mol-geo/representation/structure/index.ts +++ b/src/mol-geo/representation/structure/index.ts @@ -6,14 +6,14 @@ */ import { Structure } from 'mol-model/structure'; -import { ColorThemeName, ColorThemeOptions } from 'mol-view/theme/color'; -import { SizeThemeName, SizeThemeOptions } from 'mol-view/theme/size'; +import { ColorThemeName, ColorThemeOptions } from 'mol-canvas3d/theme/color'; +import { SizeThemeName, SizeThemeOptions } from 'mol-canvas3d/theme/size'; import { Representation, RepresentationProps } from '..'; import { Geometry } from '../../geometry/geometry'; import { Mesh } from '../../geometry/mesh/mesh'; import { Points } from '../../geometry/points/points'; import { Lines } from '../../geometry/lines/lines'; -import { SelectParam, paramDefaultValues } from 'mol-view/parameter'; +import { SelectParam, paramDefaultValues } from 'mol-util/parameter'; import { DirectVolume } from '../../geometry/direct-volume/direct-volume'; export interface StructureRepresentation<P extends RepresentationProps = {}> extends Representation<Structure, P> { } diff --git a/src/mol-geo/representation/structure/representation/backbone.ts b/src/mol-geo/representation/structure/representation/backbone.ts index ad6e7e641..ecfa4da04 100644 --- a/src/mol-geo/representation/structure/representation/backbone.ts +++ b/src/mol-geo/representation/structure/representation/backbone.ts @@ -12,7 +12,7 @@ import { Loci } from 'mol-model/loci'; import { MarkerAction } from '../../../geometry/marker-data'; import { PolymerBackboneVisual, PolymerBackboneParams } from '../visual/polymer-backbone-cylinder'; import { getQualityProps } from '../../util'; -import { paramDefaultValues } from 'mol-view/parameter'; +import { paramDefaultValues } from 'mol-util/parameter'; export const BackboneParams = { ...PolymerBackboneParams diff --git a/src/mol-geo/representation/structure/representation/ball-and-stick.ts b/src/mol-geo/representation/structure/representation/ball-and-stick.ts index 90eec78fe..c4f50b145 100644 --- a/src/mol-geo/representation/structure/representation/ball-and-stick.ts +++ b/src/mol-geo/representation/structure/representation/ball-and-stick.ts @@ -13,9 +13,9 @@ import { Task } from 'mol-task'; import { Loci, isEmptyLoci } from 'mol-model/loci'; import { MarkerAction } from '../../../geometry/marker-data'; import { InterUnitLinkVisual } from '../visual/inter-unit-link-cylinder'; -import { SizeThemeName, SizeThemeOptions } from 'mol-view/theme/size'; +import { SizeThemeName, SizeThemeOptions } from 'mol-canvas3d/theme/size'; import { getQualityProps } from '../../util'; -import { paramDefaultValues, SelectParam, NumberParam, MultiSelectParam } from 'mol-view/parameter'; +import { paramDefaultValues, SelectParam, NumberParam, MultiSelectParam } from 'mol-util/parameter'; import { UnitKind, UnitKindOptions } from '../visual/util/common'; export const BallAndStickParams = { diff --git a/src/mol-geo/representation/structure/representation/carbohydrate.ts b/src/mol-geo/representation/structure/representation/carbohydrate.ts index 89b348ba7..17373bbce 100644 --- a/src/mol-geo/representation/structure/representation/carbohydrate.ts +++ b/src/mol-geo/representation/structure/representation/carbohydrate.ts @@ -12,9 +12,9 @@ import { Loci, isEmptyLoci } from 'mol-model/loci'; import { MarkerAction } from '../../../geometry/marker-data'; import { CarbohydrateSymbolVisual, CarbohydrateSymbolParams } from '../visual/carbohydrate-symbol-mesh'; import { CarbohydrateLinkVisual, CarbohydrateLinkParams } from '../visual/carbohydrate-link-cylinder'; -import { SizeThemeName, SizeThemeOptions } from 'mol-view/theme/size'; +import { SizeThemeName, SizeThemeOptions } from 'mol-canvas3d/theme/size'; import { getQualityProps } from '../../util'; -import { paramDefaultValues, SelectParam, NumberParam } from 'mol-view/parameter'; +import { paramDefaultValues, SelectParam, NumberParam } from 'mol-util/parameter'; export const CarbohydrateParams = { ...CarbohydrateSymbolParams, diff --git a/src/mol-geo/representation/structure/representation/cartoon.ts b/src/mol-geo/representation/structure/representation/cartoon.ts index e9934ed66..3f5e915cd 100644 --- a/src/mol-geo/representation/structure/representation/cartoon.ts +++ b/src/mol-geo/representation/structure/representation/cartoon.ts @@ -13,9 +13,9 @@ import { MarkerAction } from '../../../geometry/marker-data'; import { PolymerTraceVisual, PolymerTraceParams } from '../visual/polymer-trace-mesh'; import { PolymerGapVisual, PolymerGapParams } from '../visual/polymer-gap-cylinder'; import { NucleotideBlockVisual, NucleotideBlockParams } from '../visual/nucleotide-block-mesh'; -import { SizeThemeName, SizeThemeOptions } from 'mol-view/theme/size'; +import { SizeThemeName, SizeThemeOptions } from 'mol-canvas3d/theme/size'; import { getQualityProps } from '../../util'; -import { paramDefaultValues, SelectParam, NumberParam } from 'mol-view/parameter'; +import { paramDefaultValues, SelectParam, NumberParam } from 'mol-util/parameter'; // import { PolymerDirectionVisual, DefaultPolymerDirectionProps } from '../visual/polymer-direction-wedge'; export const CartoonParams = { diff --git a/src/mol-geo/representation/structure/representation/distance-restraint.ts b/src/mol-geo/representation/structure/representation/distance-restraint.ts index 5d460bb59..7e6838651 100644 --- a/src/mol-geo/representation/structure/representation/distance-restraint.ts +++ b/src/mol-geo/representation/structure/representation/distance-restraint.ts @@ -11,9 +11,9 @@ import { Task } from 'mol-task'; import { Loci } from 'mol-model/loci'; import { MarkerAction } from '../../../geometry/marker-data'; import { CrossLinkRestraintVisual, CrossLinkRestraintParams } from '../visual/cross-link-restraint-cylinder'; -import { SizeThemeName, SizeThemeOptions } from 'mol-view/theme/size'; +import { SizeThemeName, SizeThemeOptions } from 'mol-canvas3d/theme/size'; import { getQualityProps } from '../../util'; -import { paramDefaultValues, SelectParam, NumberParam } from 'mol-view/parameter'; +import { paramDefaultValues, SelectParam, NumberParam } from 'mol-util/parameter'; export const DistanceRestraintParams = { ...CrossLinkRestraintParams, diff --git a/src/mol-geo/representation/structure/representation/molecular-surface.ts b/src/mol-geo/representation/structure/representation/molecular-surface.ts index be412fc1e..9a4fd1378 100644 --- a/src/mol-geo/representation/structure/representation/molecular-surface.ts +++ b/src/mol-geo/representation/structure/representation/molecular-surface.ts @@ -14,9 +14,9 @@ import { PickingId } from '../../../geometry/picking'; import { Task } from 'mol-task'; import { GaussianWireframeVisual, GaussianWireframeParams } from '../visual/gaussian-surface-wireframe'; import { getQualityProps } from '../../util'; -import { paramDefaultValues, MultiSelectParam, SelectParam } from 'mol-view/parameter'; +import { paramDefaultValues, MultiSelectParam, SelectParam } from 'mol-util/parameter'; import { GaussianDensityVolumeParams, GaussianDensityVolumeVisual } from '../visual/gaussian-density-volume'; -import { SizeThemeName, SizeThemeOptions } from 'mol-view/theme/size'; +import { SizeThemeName, SizeThemeOptions } from 'mol-canvas3d/theme/size'; const VisualOptions = [['surface', 'Surface'], ['wireframe', 'Wireframe'], ['volume', 'Volume']] as [string, string][] diff --git a/src/mol-geo/representation/structure/representation/point.ts b/src/mol-geo/representation/structure/representation/point.ts index 09049bf3b..2992e7503 100644 --- a/src/mol-geo/representation/structure/representation/point.ts +++ b/src/mol-geo/representation/structure/representation/point.ts @@ -11,7 +11,7 @@ import { Structure } from 'mol-model/structure'; import { MarkerAction } from '../../../geometry/marker-data'; import { Loci } from 'mol-model/loci'; import { PickingId } from '../../../geometry/picking'; -import { paramDefaultValues } from 'mol-view/parameter'; +import { paramDefaultValues } from 'mol-util/parameter'; export const PointParams = { ...ElementPointParams, diff --git a/src/mol-geo/representation/structure/representation/spacefill.ts b/src/mol-geo/representation/structure/representation/spacefill.ts index 740c240c7..c79ece3e0 100644 --- a/src/mol-geo/representation/structure/representation/spacefill.ts +++ b/src/mol-geo/representation/structure/representation/spacefill.ts @@ -12,7 +12,7 @@ import { PickingId } from '../../../geometry/picking'; import { MarkerAction } from '../../../geometry/marker-data'; import { Loci } from 'mol-model/loci'; import { getQualityProps } from '../../util'; -import { paramDefaultValues } from 'mol-view/parameter'; +import { paramDefaultValues } from 'mol-util/parameter'; export const SpacefillParams = { ...ElementSphereParams diff --git a/src/mol-geo/representation/structure/units-visual.ts b/src/mol-geo/representation/structure/units-visual.ts index 5e674479a..bef61d533 100644 --- a/src/mol-geo/representation/structure/units-visual.ts +++ b/src/mol-geo/representation/structure/units-visual.ts @@ -22,7 +22,7 @@ import { updateRenderableState, Geometry } from '../../geometry/geometry'; import { createColors } from '../../geometry/color-data'; import { createSizes } from '../../geometry/size-data'; import { Lines } from '../../geometry/lines/lines'; -import { MultiSelectParam, paramDefaultValues } from 'mol-view/parameter'; +import { MultiSelectParam, paramDefaultValues } from 'mol-util/parameter'; import { DirectVolume } from '../../geometry/direct-volume/direct-volume'; import { RenderableValues } from 'mol-gl/renderable/schema'; diff --git a/src/mol-geo/representation/structure/visual/carbohydrate-link-cylinder.ts b/src/mol-geo/representation/structure/visual/carbohydrate-link-cylinder.ts index a475a2889..bfc6af645 100644 --- a/src/mol-geo/representation/structure/visual/carbohydrate-link-cylinder.ts +++ b/src/mol-geo/representation/structure/visual/carbohydrate-link-cylinder.ts @@ -15,11 +15,11 @@ import { LocationIterator } from '../../../util/location-iterator'; import { createLinkCylinderMesh, LinkCylinderProps, LinkCylinderParams } from './util/link'; import { OrderedSet, Interval } from 'mol-data/int'; import { ComplexMeshVisual } from '../complex-visual'; -import { SizeTheme, SizeThemeName, SizeThemeOptions } from 'mol-view/theme/size'; +import { SizeTheme, SizeThemeName, SizeThemeOptions } from 'mol-canvas3d/theme/size'; import { LinkType } from 'mol-model/structure/model/types'; import { BitFlags } from 'mol-util'; import { UnitsMeshParams } from '../units-visual'; -import { SelectParam, NumberParam, paramDefaultValues } from 'mol-view/parameter'; +import { SelectParam, NumberParam, paramDefaultValues } from 'mol-util/parameter'; // TODO create seperate visual // for (let i = 0, il = carbohydrates.terminalLinks.length; i < il; ++i) { diff --git a/src/mol-geo/representation/structure/visual/carbohydrate-symbol-mesh.ts b/src/mol-geo/representation/structure/visual/carbohydrate-symbol-mesh.ts index 15d4f0b76..14e275795 100644 --- a/src/mol-geo/representation/structure/visual/carbohydrate-symbol-mesh.ts +++ b/src/mol-geo/representation/structure/visual/carbohydrate-symbol-mesh.ts @@ -16,14 +16,14 @@ import { getSaccharideShape, SaccharideShapes } from 'mol-model/structure/struct import { LocationIterator } from '../../../util/location-iterator'; import { OrderedSet, Interval } from 'mol-data/int'; import { ComplexMeshVisual, ComplexMeshParams } from '../complex-visual'; -import { SizeTheme, SizeThemeName, SizeThemeOptions } from 'mol-view/theme/size'; +import { SizeTheme, SizeThemeName, SizeThemeOptions } from 'mol-canvas3d/theme/size'; import { addSphere } from '../../../geometry/mesh/builder/sphere'; import { Box, PerforatedBox } from '../../../primitive/box'; import { OctagonalPyramid, PerforatedOctagonalPyramid } from '../../../primitive/pyramid'; import { Star } from '../../../primitive/star'; import { Octahedron, PerforatedOctahedron } from '../../../primitive/octahedron'; import { DiamondPrism, PentagonalPrism, HexagonalPrism } from '../../../primitive/prism'; -import { SelectParam, NumberParam, paramDefaultValues } from 'mol-view/parameter'; +import { SelectParam, NumberParam, paramDefaultValues } from 'mol-util/parameter'; const t = Mat4.identity() const sVec = Vec3.zero() diff --git a/src/mol-geo/representation/structure/visual/cross-link-restraint-cylinder.ts b/src/mol-geo/representation/structure/visual/cross-link-restraint-cylinder.ts index 43764073b..703feccb4 100644 --- a/src/mol-geo/representation/structure/visual/cross-link-restraint-cylinder.ts +++ b/src/mol-geo/representation/structure/visual/cross-link-restraint-cylinder.ts @@ -15,10 +15,10 @@ import { Loci, EmptyLoci } from 'mol-model/loci'; import { ComplexMeshVisual, ComplexMeshParams } from '../complex-visual'; import { LocationIterator } from '../../../util/location-iterator'; import { Interval } from 'mol-data/int'; -import { SizeTheme, SizeThemeOptions, SizeThemeName } from 'mol-view/theme/size'; +import { SizeTheme, SizeThemeOptions, SizeThemeName } from 'mol-canvas3d/theme/size'; import { BitFlags } from 'mol-util'; import { LinkType } from 'mol-model/structure/model/types'; -import { SelectParam, NumberParam, paramDefaultValues } from 'mol-view/parameter'; +import { SelectParam, NumberParam, paramDefaultValues } from 'mol-util/parameter'; async function createCrossLinkRestraintCylinderMesh(ctx: RuntimeContext, structure: Structure, props: LinkCylinderProps, mesh?: Mesh) { diff --git a/src/mol-geo/representation/structure/visual/element-point.ts b/src/mol-geo/representation/structure/visual/element-point.ts index e6fd79701..6b25c8608 100644 --- a/src/mol-geo/representation/structure/visual/element-point.ts +++ b/src/mol-geo/representation/structure/visual/element-point.ts @@ -9,11 +9,11 @@ import { RuntimeContext } from 'mol-task' import { UnitsVisual, VisualUpdateState } from '..'; import { getElementLoci, StructureElementIterator, markElement } from './util/element'; import { Vec3 } from 'mol-math/linear-algebra'; -import { SizeThemeOptions, SizeThemeName } from 'mol-view/theme/size'; +import { SizeThemeOptions, SizeThemeName } from 'mol-canvas3d/theme/size'; import { UnitsPointsVisual, UnitsPointsParams } from '../units-visual'; import { Points } from '../../../geometry/points/points'; import { PointsBuilder } from '../../../geometry/points/points-builder'; -import { SelectParam, NumberParam, BooleanParam, paramDefaultValues } from 'mol-view/parameter'; +import { SelectParam, NumberParam, BooleanParam, paramDefaultValues } from 'mol-util/parameter'; export const ElementPointParams = { ...UnitsPointsParams, diff --git a/src/mol-geo/representation/structure/visual/element-sphere.ts b/src/mol-geo/representation/structure/visual/element-sphere.ts index 5913a0e4a..baa542429 100644 --- a/src/mol-geo/representation/structure/visual/element-sphere.ts +++ b/src/mol-geo/representation/structure/visual/element-sphere.ts @@ -8,8 +8,8 @@ import { UnitsVisual, VisualUpdateState } from '..'; import { createElementSphereMesh, markElement, getElementLoci, StructureElementIterator } from './util/element'; import { UnitsMeshVisual, UnitsMeshParams } from '../units-visual'; -import { NumberParam, paramDefaultValues, SelectParam } from 'mol-view/parameter'; -import { SizeThemeName, SizeThemeOptions } from 'mol-view/theme/size'; +import { NumberParam, paramDefaultValues, SelectParam } from 'mol-util/parameter'; +import { SizeThemeName, SizeThemeOptions } from 'mol-canvas3d/theme/size'; export const ElementSphereParams = { ...UnitsMeshParams, diff --git a/src/mol-geo/representation/structure/visual/gaussian-density-point.ts b/src/mol-geo/representation/structure/visual/gaussian-density-point.ts index 9a26d9601..7ff641e91 100644 --- a/src/mol-geo/representation/structure/visual/gaussian-density-point.ts +++ b/src/mol-geo/representation/structure/visual/gaussian-density-point.ts @@ -13,9 +13,9 @@ import { Vec3 } from 'mol-math/linear-algebra'; import { UnitsPointsVisual, UnitsPointsParams } from '../units-visual'; import { Points } from '../../../geometry/points/points'; import { PointsBuilder } from '../../../geometry/points/points-builder'; -import { SizeThemeOptions, SizeThemeName } from 'mol-view/theme/size'; +import { SizeThemeOptions, SizeThemeName } from 'mol-canvas3d/theme/size'; import { GaussianDensityProps, GaussianDensityParams } from 'mol-model/structure/structure/unit/gaussian-density'; -import { paramDefaultValues, SelectParam, NumberParam, BooleanParam } from 'mol-view/parameter'; +import { paramDefaultValues, SelectParam, NumberParam, BooleanParam } from 'mol-util/parameter'; export const GaussianDensityPointParams = { ...UnitsPointsParams, diff --git a/src/mol-geo/representation/structure/visual/gaussian-density-volume.ts b/src/mol-geo/representation/structure/visual/gaussian-density-volume.ts index 94bcd294a..912c07dff 100644 --- a/src/mol-geo/representation/structure/visual/gaussian-density-volume.ts +++ b/src/mol-geo/representation/structure/visual/gaussian-density-volume.ts @@ -10,7 +10,7 @@ import { RuntimeContext } from 'mol-task' import { UnitsDirectVolumeVisual, UnitsDirectVolumeParams } from '../units-visual'; import { StructureElementIterator, getElementLoci, markElement } from './util/element'; import { GaussianDensityProps, GaussianDensityParams, computeUnitGaussianDensityTexture } from 'mol-model/structure/structure/unit/gaussian-density'; -import { paramDefaultValues } from 'mol-view/parameter'; +import { paramDefaultValues } from 'mol-util/parameter'; import { DirectVolume } from '../../../geometry/direct-volume/direct-volume'; async function createGaussianDensityVolume(ctx: RuntimeContext, unit: Unit, structure: Structure, props: GaussianDensityProps, directVolume?: DirectVolume): Promise<DirectVolume> { diff --git a/src/mol-geo/representation/structure/visual/gaussian-surface-mesh.ts b/src/mol-geo/representation/structure/visual/gaussian-surface-mesh.ts index 043f8dc93..8faf356ab 100644 --- a/src/mol-geo/representation/structure/visual/gaussian-surface-mesh.ts +++ b/src/mol-geo/representation/structure/visual/gaussian-surface-mesh.ts @@ -12,7 +12,7 @@ import { UnitsMeshVisual, UnitsMeshParams } from '../units-visual'; import { StructureElementIterator, getElementLoci, markElement } from './util/element'; import { computeMarchingCubesMesh } from '../../../util/marching-cubes/algorithm'; import { GaussianDensityProps, GaussianDensityParams } from 'mol-model/structure/structure/unit/gaussian-density'; -import { paramDefaultValues } from 'mol-view/parameter'; +import { paramDefaultValues } from 'mol-util/parameter'; async function createGaussianSurfaceMesh(ctx: RuntimeContext, unit: Unit, structure: Structure, props: GaussianDensityProps, mesh?: Mesh): Promise<Mesh> { const { smoothness } = props diff --git a/src/mol-geo/representation/structure/visual/gaussian-surface-wireframe.ts b/src/mol-geo/representation/structure/visual/gaussian-surface-wireframe.ts index 3d1da6e79..0bb363663 100644 --- a/src/mol-geo/representation/structure/visual/gaussian-surface-wireframe.ts +++ b/src/mol-geo/representation/structure/visual/gaussian-surface-wireframe.ts @@ -12,8 +12,8 @@ import { StructureElementIterator, getElementLoci, markElement } from './util/el import { computeMarchingCubesLines } from '../../../util/marching-cubes/algorithm'; import { Lines } from '../../../geometry/lines/lines'; import { GaussianDensityProps, GaussianDensityParams } from 'mol-model/structure/structure/unit/gaussian-density'; -import { paramDefaultValues, SelectParam, NumberParam, BooleanParam } from 'mol-view/parameter'; -import { SizeThemeName, SizeThemeOptions } from 'mol-view/theme/size'; +import { paramDefaultValues, SelectParam, NumberParam, BooleanParam } from 'mol-util/parameter'; +import { SizeThemeName, SizeThemeOptions } from 'mol-canvas3d/theme/size'; async function createGaussianWireframe(ctx: RuntimeContext, unit: Unit, structure: Structure, props: GaussianDensityProps, lines?: Lines): Promise<Lines> { const { smoothness } = props diff --git a/src/mol-geo/representation/structure/visual/inter-unit-link-cylinder.ts b/src/mol-geo/representation/structure/visual/inter-unit-link-cylinder.ts index 5503cae06..796adcb04 100644 --- a/src/mol-geo/representation/structure/visual/inter-unit-link-cylinder.ts +++ b/src/mol-geo/representation/structure/visual/inter-unit-link-cylinder.ts @@ -14,9 +14,9 @@ import { Vec3 } from 'mol-math/linear-algebra'; import { Loci, EmptyLoci } from 'mol-model/loci'; import { ComplexMeshVisual, ComplexMeshParams } from '../complex-visual'; import { Interval } from 'mol-data/int'; -import { SizeTheme, SizeThemeName, SizeThemeOptions } from 'mol-view/theme/size'; +import { SizeTheme, SizeThemeName, SizeThemeOptions } from 'mol-canvas3d/theme/size'; import { BitFlags } from 'mol-util'; -import { SelectParam, NumberParam, paramDefaultValues } from 'mol-view/parameter'; +import { SelectParam, NumberParam, paramDefaultValues } from 'mol-util/parameter'; async function createInterUnitLinkCylinderMesh(ctx: RuntimeContext, structure: Structure, props: LinkCylinderProps, mesh?: Mesh) { const links = structure.links diff --git a/src/mol-geo/representation/structure/visual/intra-unit-link-cylinder.ts b/src/mol-geo/representation/structure/visual/intra-unit-link-cylinder.ts index 005799c81..c3569027b 100644 --- a/src/mol-geo/representation/structure/visual/intra-unit-link-cylinder.ts +++ b/src/mol-geo/representation/structure/visual/intra-unit-link-cylinder.ts @@ -15,9 +15,9 @@ import { Vec3 } from 'mol-math/linear-algebra'; import { Loci, EmptyLoci } from 'mol-model/loci'; import { UnitsMeshVisual, UnitsMeshParams } from '../units-visual'; import { Interval } from 'mol-data/int'; -import { SizeTheme, SizeThemeName, SizeThemeOptions } from 'mol-view/theme/size'; +import { SizeTheme, SizeThemeName, SizeThemeOptions } from 'mol-canvas3d/theme/size'; import { BitFlags } from 'mol-util'; -import { SelectParam, NumberParam, paramDefaultValues } from 'mol-view/parameter'; +import { SelectParam, NumberParam, paramDefaultValues } from 'mol-util/parameter'; async function createIntraUnitLinkCylinderMesh(ctx: RuntimeContext, unit: Unit, structure: Structure, props: LinkCylinderProps, mesh?: Mesh) { if (!Unit.isAtomic(unit)) return Mesh.createEmpty(mesh) diff --git a/src/mol-geo/representation/structure/visual/nucleotide-block-mesh.ts b/src/mol-geo/representation/structure/visual/nucleotide-block-mesh.ts index 5e778b020..1dd4bc8b3 100644 --- a/src/mol-geo/representation/structure/visual/nucleotide-block-mesh.ts +++ b/src/mol-geo/representation/structure/visual/nucleotide-block-mesh.ts @@ -17,7 +17,7 @@ import { UnitsMeshVisual, UnitsMeshParams } from '../units-visual'; import { addCylinder } from '../../../geometry/mesh/builder/cylinder'; import { Box } from '../../../primitive/box'; import { NucleotideLocationIterator, markNucleotideElement, getNucleotideElementLoci } from './util/nucleotide'; -import { paramDefaultValues } from 'mol-view/parameter'; +import { paramDefaultValues } from 'mol-util/parameter'; const p1 = Vec3.zero() const p2 = Vec3.zero() diff --git a/src/mol-geo/representation/structure/visual/polymer-backbone-cylinder.ts b/src/mol-geo/representation/structure/visual/polymer-backbone-cylinder.ts index 50aea2a8b..62860a718 100644 --- a/src/mol-geo/representation/structure/visual/polymer-backbone-cylinder.ts +++ b/src/mol-geo/representation/structure/visual/polymer-backbone-cylinder.ts @@ -13,11 +13,11 @@ import { PolymerBackboneIterator } from './util/polymer'; import { getElementLoci, markElement, StructureElementIterator } from './util/element'; import { Vec3 } from 'mol-math/linear-algebra'; import { UnitsMeshVisual, UnitsMeshParams } from '../units-visual'; -import { SizeTheme, SizeThemeOptions, SizeThemeName } from 'mol-view/theme/size'; +import { SizeTheme, SizeThemeOptions, SizeThemeName } from 'mol-canvas3d/theme/size'; import { CylinderProps } from '../../../primitive/cylinder'; import { OrderedSet } from 'mol-data/int'; import { addCylinder } from '../../../geometry/mesh/builder/cylinder'; -import { paramDefaultValues, NumberParam, SelectParam } from 'mol-view/parameter'; +import { paramDefaultValues, NumberParam, SelectParam } from 'mol-util/parameter'; export const PolymerBackboneCylinderParams = { sizeTheme: SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), diff --git a/src/mol-geo/representation/structure/visual/polymer-direction-wedge.ts b/src/mol-geo/representation/structure/visual/polymer-direction-wedge.ts index cce1eb9b6..1601fca4b 100644 --- a/src/mol-geo/representation/structure/visual/polymer-direction-wedge.ts +++ b/src/mol-geo/representation/structure/visual/polymer-direction-wedge.ts @@ -13,9 +13,9 @@ import { PolymerTraceIterator, createCurveSegmentState, interpolateCurveSegment, import { Vec3, Mat4 } from 'mol-math/linear-algebra'; import { SecondaryStructureType, isNucleic } from 'mol-model/structure/model/types'; import { UnitsMeshVisual, UnitsMeshParams } from '../units-visual'; -import { SizeTheme, SizeThemeName, SizeThemeOptions } from 'mol-view/theme/size'; +import { SizeTheme, SizeThemeName, SizeThemeOptions } from 'mol-canvas3d/theme/size'; import { Wedge } from '../../../primitive/wedge'; -import { SelectParam, NumberParam, paramDefaultValues } from 'mol-view/parameter'; +import { SelectParam, NumberParam, paramDefaultValues } from 'mol-util/parameter'; const t = Mat4.identity() const sVec = Vec3.zero() diff --git a/src/mol-geo/representation/structure/visual/polymer-gap-cylinder.ts b/src/mol-geo/representation/structure/visual/polymer-gap-cylinder.ts index e8b3a62b6..98ace9ba4 100644 --- a/src/mol-geo/representation/structure/visual/polymer-gap-cylinder.ts +++ b/src/mol-geo/representation/structure/visual/polymer-gap-cylinder.ts @@ -12,11 +12,11 @@ import { MeshBuilder } from '../../../geometry/mesh/mesh-builder'; import { PolymerGapIterator, PolymerGapLocationIterator, markPolymerGapElement, getPolymerGapElementLoci } from './util/polymer'; import { Vec3 } from 'mol-math/linear-algebra'; import { UnitsMeshVisual, UnitsMeshParams } from '../units-visual'; -import { SizeTheme, SizeThemeOptions, SizeThemeName } from 'mol-view/theme/size'; +import { SizeTheme, SizeThemeOptions, SizeThemeName } from 'mol-canvas3d/theme/size'; import { CylinderProps } from '../../../primitive/cylinder'; import { addSphere } from '../../../geometry/mesh/builder/sphere'; import { addFixedCountDashedCylinder } from '../../../geometry/mesh/builder/cylinder'; -import { SelectParam, NumberParam, paramDefaultValues } from 'mol-view/parameter'; +import { SelectParam, NumberParam, paramDefaultValues } from 'mol-util/parameter'; import { LinkCylinderParams } from './util/link'; const segmentCount = 10 diff --git a/src/mol-geo/representation/structure/visual/polymer-trace-mesh.ts b/src/mol-geo/representation/structure/visual/polymer-trace-mesh.ts index e5380b1bf..4a7bc8dde 100644 --- a/src/mol-geo/representation/structure/visual/polymer-trace-mesh.ts +++ b/src/mol-geo/representation/structure/visual/polymer-trace-mesh.ts @@ -12,10 +12,10 @@ import { MeshBuilder } from '../../../geometry/mesh/mesh-builder'; import { PolymerTraceIterator, createCurveSegmentState, interpolateCurveSegment, PolymerLocationIterator, getPolymerElementLoci, markPolymerElement } from './util/polymer'; import { SecondaryStructureType, isNucleic } from 'mol-model/structure/model/types'; import { UnitsMeshVisual, UnitsMeshParams } from '../units-visual'; -import { SizeTheme, SizeThemeName, SizeThemeOptions } from 'mol-view/theme/size'; +import { SizeTheme, SizeThemeName, SizeThemeOptions } from 'mol-canvas3d/theme/size'; import { addSheet } from '../../../geometry/mesh/builder/sheet'; import { addTube } from '../../../geometry/mesh/builder/tube'; -import { SelectParam, NumberParam, paramDefaultValues } from 'mol-view/parameter'; +import { SelectParam, NumberParam, paramDefaultValues } from 'mol-util/parameter'; export const PolymerTraceMeshParams = { sizeTheme: SelectParam<SizeThemeName>('Size Theme', '', 'physical', SizeThemeOptions), diff --git a/src/mol-geo/representation/structure/visual/util/element.ts b/src/mol-geo/representation/structure/visual/util/element.ts index 76dfc4a50..b2205660c 100644 --- a/src/mol-geo/representation/structure/visual/util/element.ts +++ b/src/mol-geo/representation/structure/visual/util/element.ts @@ -13,7 +13,7 @@ import { MeshBuilder } from '../../../../geometry/mesh/mesh-builder'; import { Loci, EmptyLoci } from 'mol-model/loci'; import { Interval, OrderedSet } from 'mol-data/int'; import { PickingId } from '../../../../geometry/picking'; -import { SizeTheme, SizeThemeName } from 'mol-view/theme/size'; +import { SizeTheme, SizeThemeName } from 'mol-canvas3d/theme/size'; import { LocationIterator } from '../../../../util/location-iterator'; import { addSphere } from '../../../../geometry/mesh/builder/sphere'; diff --git a/src/mol-geo/representation/structure/visual/util/link.ts b/src/mol-geo/representation/structure/visual/util/link.ts index 6cdbae8ab..0c2eede02 100644 --- a/src/mol-geo/representation/structure/visual/util/link.ts +++ b/src/mol-geo/representation/structure/visual/util/link.ts @@ -9,12 +9,12 @@ import { RuntimeContext } from 'mol-task'; import { Mesh } from '../../../../geometry/mesh/mesh'; import { MeshBuilder } from '../../../../geometry/mesh/mesh-builder'; import { LinkType } from 'mol-model/structure/model/types'; -import { SizeThemeName, SizeThemeOptions } from 'mol-view/theme/size'; +import { SizeThemeName, SizeThemeOptions } from 'mol-canvas3d/theme/size'; import { CylinderProps } from '../../../../primitive/cylinder'; import { LocationIterator } from '../../../../util/location-iterator'; import { Unit, StructureElement, Structure, Link } from 'mol-model/structure'; import { addFixedCountDashedCylinder, addCylinder, addDoubleCylinder } from '../../../../geometry/mesh/builder/cylinder'; -import { SelectParam, RangeParam, NumberParam, paramDefaultValues } from 'mol-view/parameter'; +import { SelectParam, RangeParam, NumberParam, paramDefaultValues } from 'mol-util/parameter'; export const LinkCylinderParams = { sizeTheme: SelectParam<SizeThemeName>('Size Theme', '', 'uniform', SizeThemeOptions), diff --git a/src/mol-geo/representation/volume/direct-volume.ts b/src/mol-geo/representation/volume/direct-volume.ts index 5819bfa9b..49d12ef2a 100644 --- a/src/mol-geo/representation/volume/direct-volume.ts +++ b/src/mol-geo/representation/volume/direct-volume.ts @@ -12,7 +12,7 @@ import { PickingId } from '../../geometry/picking'; import { MarkerAction } from '../../geometry/marker-data'; import { Loci, EmptyLoci } from 'mol-model/loci'; import { createRenderableState, updateRenderableState, Geometry } from '../../geometry/geometry'; -import { paramDefaultValues } from 'mol-view/parameter'; +import { paramDefaultValues } from 'mol-util/parameter'; import { DirectVolume } from '../../geometry/direct-volume/direct-volume'; import { Vec3, Mat4 } from 'mol-math/linear-algebra'; import { Box3D } from 'mol-math/geometry'; diff --git a/src/mol-geo/representation/volume/index.ts b/src/mol-geo/representation/volume/index.ts index 2bbceed74..dcb95d81a 100644 --- a/src/mol-geo/representation/volume/index.ts +++ b/src/mol-geo/representation/volume/index.ts @@ -11,7 +11,7 @@ import { PickingId } from '../../geometry/picking'; import { Loci, EmptyLoci } from 'mol-model/loci'; import { MarkerAction } from '../../geometry/marker-data'; import { Geometry } from '../../geometry/geometry'; -import { paramDefaultValues } from 'mol-view/parameter'; +import { paramDefaultValues } from 'mol-util/parameter'; export interface VolumeVisual<P extends RepresentationProps = {}> extends Visual<VolumeData, P> { } diff --git a/src/mol-geo/representation/volume/isosurface-mesh.ts b/src/mol-geo/representation/volume/isosurface-mesh.ts index e6c951840..acff269e6 100644 --- a/src/mol-geo/representation/volume/isosurface-mesh.ts +++ b/src/mol-geo/representation/volume/isosurface-mesh.ts @@ -18,7 +18,7 @@ import { LocationIterator } from '../../util/location-iterator'; import { NullLocation } from 'mol-model/location'; import { createIdentityTransform } from '../../geometry/transform-data'; import { createRenderableState, updateRenderableState } from '../../geometry/geometry'; -import { paramDefaultValues, RangeParam } from 'mol-view/parameter'; +import { paramDefaultValues, RangeParam } from 'mol-util/parameter'; import { ValueCell } from 'mol-util'; export async function createVolumeSurface(ctx: RuntimeContext, volume: VolumeData, isoValueAbsolute: number, mesh?: Mesh) { diff --git a/src/mol-gl/_spec/renderer.spec.ts b/src/mol-gl/_spec/renderer.spec.ts index ab7feffcc..6ede20f99 100644 --- a/src/mol-gl/_spec/renderer.spec.ts +++ b/src/mol-gl/_spec/renderer.spec.ts @@ -6,7 +6,7 @@ import { createGl } from './gl.shim'; -import { PerspectiveCamera } from 'mol-view/camera/perspective'; +import { PerspectiveCamera } from 'mol-canvas3d/camera/perspective'; import { Vec3, Mat4 } from 'mol-math/linear-algebra'; import { ValueCell } from 'mol-util'; diff --git a/src/mol-gl/renderer.ts b/src/mol-gl/renderer.ts index 35a940f89..3437f75c1 100644 --- a/src/mol-gl/renderer.ts +++ b/src/mol-gl/renderer.ts @@ -5,8 +5,8 @@ */ // import { Vec3, Mat4 } from 'mol-math/linear-algebra' -import { Viewport } from 'mol-view/camera/util'; -import { Camera } from 'mol-view/camera/base'; +import { Viewport } from 'mol-canvas3d/camera/util'; +import { Camera } from 'mol-canvas3d/camera/base'; import Scene from './scene'; import { Context, createImageData } from './webgl/context'; diff --git a/src/mol-model/structure/structure/unit/gaussian-density.ts b/src/mol-model/structure/structure/unit/gaussian-density.ts index a5d4d0681..e79797d22 100644 --- a/src/mol-model/structure/structure/unit/gaussian-density.ts +++ b/src/mol-model/structure/structure/unit/gaussian-density.ts @@ -5,11 +5,11 @@ */ import { Unit, StructureElement, ElementIndex } from 'mol-model/structure'; -import { SizeTheme } from 'mol-view/theme/size'; +import { SizeTheme } from 'mol-canvas3d/theme/size'; import { GaussianDensity } from 'mol-math/geometry/gaussian-density'; import { Task, RuntimeContext } from 'mol-task'; import { DensityData } from 'mol-math/geometry'; -import { NumberParam, paramDefaultValues, BooleanParam, ValueParam } from 'mol-view/parameter'; +import { NumberParam, paramDefaultValues, BooleanParam, ValueParam } from 'mol-util/parameter'; import { Context } from 'mol-gl/webgl/context'; import { GaussianDensityTexture } from 'mol-math/geometry/gaussian-density/gpu'; import { Texture } from 'mol-gl/webgl/texture'; diff --git a/src/mol-plugin/index.ts b/src/mol-plugin/index.ts new file mode 100644 index 000000000..7c7fe8338 --- /dev/null +++ b/src/mol-plugin/index.ts @@ -0,0 +1,7 @@ +/** + * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. + * + * @author David Sehnal <david.sehnal@gmail.com> + */ + +// TODO \ No newline at end of file diff --git a/src/mol-util/color/scale.ts b/src/mol-util/color/scale.ts index 403bf485b..08f3a2c05 100644 --- a/src/mol-util/color/scale.ts +++ b/src/mol-util/color/scale.ts @@ -6,7 +6,7 @@ import { Color } from './color' import { ColorBrewer } from './tables' -import { ScaleLegend } from 'mol-view/theme/color'; +import { ScaleLegend } from 'mol-canvas3d/theme/color'; import { defaults } from 'mol-util'; export interface ColorScale { diff --git a/src/mol-view/parameter.ts b/src/mol-util/parameter.ts similarity index 100% rename from src/mol-view/parameter.ts rename to src/mol-util/parameter.ts diff --git a/src/mol-view/state/context.ts b/src/mol-view/state/context.ts deleted file mode 100644 index 2893a5e37..000000000 --- a/src/mol-view/state/context.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. - * - * @author Alexander Rose <alexander.rose@weirdbyte.de> - */ - -import { BehaviorSubject } from 'rxjs'; -import { UUID } from 'mol-util' -import { AnyEntity } from './entity'; -import Viewer from '../viewer'; -import { Progress } from 'mol-task'; - -// TODO -export type StateTree = {} - -export class StateContext { - id = UUID.create() - change = new BehaviorSubject(0) - - tree: StateTree = {} - entities: Set<AnyEntity> = new Set() - - viewer: Viewer - - constructor(readonly log: (p: Progress) => void) { - - } -} diff --git a/src/mol-view/state/entity.ts b/src/mol-view/state/entity.ts deleted file mode 100644 index 7c16728cb..000000000 --- a/src/mol-view/state/entity.ts +++ /dev/null @@ -1,162 +0,0 @@ -/** - * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. - * - * @author Alexander Rose <alexander.rose@weirdbyte.de> - */ - -import { readFile, readUrl } from 'mol-util/read' -import { idFactory } from 'mol-util/id-factory' -import { StateContext } from './context'; -import { getFileInfo } from 'mol-util/file-info'; -import { CifFile, CifFrame } from 'mol-io/reader/cif'; -import { mmCIF_Database } from 'mol-io/reader/cif/schema/mmcif'; -import { Model, Structure } from 'mol-model/structure'; -import { StructureRepresentation } from 'mol-geo/representation/structure'; -import { SpacefillProps } from 'mol-geo/representation/structure/representation/spacefill'; -import { BallAndStickProps } from 'mol-geo/representation/structure/representation/ball-and-stick'; -import { DistanceRestraintProps } from 'mol-geo/representation/structure/representation/distance-restraint'; -import { CartoonProps } from 'mol-geo/representation/structure/representation/cartoon'; -import { BackboneProps } from 'mol-geo/representation/structure/representation/backbone'; -import { CarbohydrateProps } from 'mol-geo/representation/structure/representation/carbohydrate'; - -const getNextId = idFactory(1) - -export interface StateEntity<T, K extends string> { - id: number - kind: K - value: T -} -export namespace StateEntity { - export function create<T, K extends string>(ctx: StateContext, kind: K, value: T): StateEntity<T, K> { - const entity = { id: getNextId(), kind, value } - ctx.entities.add(entity) - ctx.change.next(ctx.change.getValue() + 1) - return entity - } -} - -export type AnyEntity = StateEntity<any, any> -export type NullEntity = StateEntity<null, 'null'> - -export const NullEntity: NullEntity = { id: -1, kind: 'null', value: null } -export const RootEntity: StateEntity<null, 'root'> = { id: 0, kind: 'root', value: null } - -export interface UrlProps { - url: string - name: string - type: string - getData: () => Promise<string | Uint8Array> -} - -export type UrlEntity = StateEntity<UrlProps, 'url'> -export namespace UrlEntity { - export function ofUrl(ctx: StateContext, url: string, isBinary?: boolean): UrlEntity { - const { name, ext: type, compressed, binary } = getFileInfo(url) - return StateEntity.create(ctx, 'url', { - url, name, type, - getData: () => readUrl(url, isBinary || !!compressed || binary) - }) - } -} - -export interface FileProps { - name: string - type: string - getData: () => Promise<string | Uint8Array> -} - -export type FileEntity = StateEntity<FileProps, 'file'> -export namespace FileEntity { - export function ofFile(ctx: StateContext, file: File, isBinary?: boolean): FileEntity { - const { name, ext: type, compressed, binary } = getFileInfo(file) - return StateEntity.create(ctx, 'file', { - name, type, - getData: () => readFile(file, isBinary || !!compressed || binary) - }) - } -} - -export interface DataProps { - type: string - data: string | Uint8Array -} - -export type DataEntity = StateEntity<DataProps, 'data'> -export namespace DataEntity { - export function ofData<T>(ctx: StateContext, data: string | Uint8Array, type: string): DataEntity { - return StateEntity.create(ctx, 'data', { - type, - data - }) - } -} - -export type CifEntity = StateEntity<CifFile, 'cif'> -export namespace CifEntity { - export function ofCifFile(ctx: StateContext, file: CifFile): CifEntity { - return StateEntity.create(ctx, 'cif', file) - } -} - -export type MmcifEntity = StateEntity<{ db: mmCIF_Database, frame: CifFrame }, 'mmcif'> -export namespace MmcifEntity { - export function ofMmcifDb(ctx: StateContext, mmCif: { db: mmCIF_Database, frame: CifFrame }): MmcifEntity { - return StateEntity.create(ctx, 'mmcif', mmCif) - } -} - -export type ModelEntity = StateEntity<ReadonlyArray<Model>, 'model'> -export namespace ModelEntity { - export function ofModels(ctx: StateContext, models: ReadonlyArray<Model>): ModelEntity { - return StateEntity.create(ctx, 'model', models) - } -} - -export type StructureEntity = StateEntity<Structure, 'structure'> -export namespace StructureEntity { - export function ofStructure(ctx: StateContext, structure: Structure): StructureEntity { - return StateEntity.create(ctx, 'structure', structure) - } -} - -export type SpacefillEntity = StateEntity<StructureRepresentation<SpacefillProps>, 'spacefill'> -export namespace SpacefillEntity { - export function ofRepr(ctx: StateContext, repr: StructureRepresentation<SpacefillProps>): SpacefillEntity { - return StateEntity.create(ctx, 'spacefill', repr) - } -} - -export type BallAndStickEntity = StateEntity<StructureRepresentation<BallAndStickProps>, 'ballandstick'> -export namespace BallAndStickEntity { - export function ofRepr(ctx: StateContext, repr: StructureRepresentation<BallAndStickProps>): BallAndStickEntity { - return StateEntity.create(ctx, 'ballandstick', repr) - } -} - -export type DistanceRestraintEntity = StateEntity<StructureRepresentation<DistanceRestraintProps>, 'distancerestraint'> -export namespace DistanceRestraintEntity { - export function ofRepr(ctx: StateContext, repr: StructureRepresentation<DistanceRestraintProps>): DistanceRestraintEntity { - return StateEntity.create(ctx, 'distancerestraint', repr) - } -} - -export type BackboneEntity = StateEntity<StructureRepresentation<BackboneProps>, 'backbone'> -export namespace BackboneEntity { - export function ofRepr(ctx: StateContext, repr: StructureRepresentation<BackboneProps>): BackboneEntity { - return StateEntity.create(ctx, 'backbone', repr) - } -} - -export type CartoonEntity = StateEntity<StructureRepresentation<CartoonProps>, 'cartoon'> -export namespace CartoonEntity { - export function ofRepr(ctx: StateContext, repr: StructureRepresentation<CartoonProps>): CartoonEntity { - return StateEntity.create(ctx, 'cartoon', repr) - } -} - -export type CarbohydrateEntity = StateEntity<StructureRepresentation<CarbohydrateProps>, 'carbohydrate'> -export namespace CarbohydrateEntity { - export function ofRepr(ctx: StateContext, repr: StructureRepresentation<CarbohydrateProps>): CarbohydrateEntity { - return StateEntity.create(ctx, 'carbohydrate', repr) - } -} \ No newline at end of file diff --git a/src/mol-view/state/transform.ts b/src/mol-view/state/transform.ts deleted file mode 100644 index bb454c3c5..000000000 --- a/src/mol-view/state/transform.ts +++ /dev/null @@ -1,274 +0,0 @@ -/** - * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. - * - * @author Alexander Rose <alexander.rose@weirdbyte.de> - */ - -import CIF from 'mol-io/reader/cif' -import { FileEntity, DataEntity, UrlEntity, CifEntity, MmcifEntity, ModelEntity, StructureEntity, SpacefillEntity, AnyEntity, NullEntity, BallAndStickEntity, DistanceRestraintEntity, CartoonEntity, BackboneEntity, CarbohydrateEntity } from './entity'; -import { Model, Structure, Format } from 'mol-model/structure'; - -import { StateContext } from './context'; -import StructureSymmetry from 'mol-model/structure/structure/symmetry'; -import { SpacefillProps, SpacefillRepresentation } from 'mol-geo/representation/structure/representation/spacefill'; -import { BallAndStickProps, BallAndStickRepresentation } from 'mol-geo/representation/structure/representation/ball-and-stick'; -import { DistanceRestraintRepresentation, DistanceRestraintProps } from 'mol-geo/representation/structure/representation/distance-restraint'; -import { CartoonRepresentation, CartoonProps } from 'mol-geo/representation/structure/representation/cartoon'; -import { BackboneProps, BackboneRepresentation } from 'mol-geo/representation/structure/representation/backbone'; -import { CarbohydrateProps, CarbohydrateRepresentation } from 'mol-geo/representation/structure/representation/carbohydrate'; - -type transformer<I extends AnyEntity, O extends AnyEntity, P extends {}> = (ctx: StateContext, inputEntity: I, props?: P) => Promise<O> - -export interface StateTransform<I extends AnyEntity, O extends AnyEntity, P extends {}> { - inputKind: I['kind'] - outputKind: O['kind'] - kind: string - apply: transformer<I, O, P> -} - -export namespace StateTransform { - export function create<I extends AnyEntity, O extends AnyEntity, P extends {}>(inputKind: I['kind'], outputKind: O['kind'], kind: string, transformer: transformer<I, O, P>) { - return { inputKind, outputKind, kind, apply: transformer } - } -} - -export type AnyTransform = StateTransform<AnyEntity, AnyEntity, {}> - -export type UrlToData = StateTransform<UrlEntity, DataEntity, {}> -export const UrlToData: UrlToData = StateTransform.create('url', 'data', 'url-to-data', - async function (ctx: StateContext, urlEntity: UrlEntity) { - return DataEntity.ofData(ctx, await urlEntity.value.getData(), urlEntity.value.type) - }) - -export type FileToData = StateTransform<FileEntity, DataEntity, {}> -export const FileToData: FileToData = StateTransform.create('file', 'data', 'file-to-data', - async function (ctx: StateContext, fileEntity: FileEntity) { - return DataEntity.ofData(ctx, await fileEntity.value.getData(), fileEntity.value.type) - }) - -export type DataToCif = StateTransform<DataEntity, CifEntity, {}> -export const DataToCif: DataToCif = StateTransform.create('data', 'cif', 'data-to-cif', - async function (ctx: StateContext, dataEntity: DataEntity) { - const comp = CIF.parse(dataEntity.value.data) - const parsed = await comp.run(ctx.log) - if (parsed.isError) throw parsed - return CifEntity.ofCifFile(ctx, parsed.result) - }) - -export type CifToMmcif = StateTransform<CifEntity, MmcifEntity, {}> -export const CifToMmcif: CifToMmcif = StateTransform.create('cif', 'mmcif', 'cif-to-mmcif', - async function (ctx: StateContext, cifEntity: CifEntity) { - const frame = cifEntity.value.blocks[0]; - return MmcifEntity.ofMmcifDb(ctx, { frame, db: CIF.schema.mmCIF(frame) }) - }) - -export type MmcifToModel = StateTransform<MmcifEntity, ModelEntity, {}> -export const MmcifToModel: MmcifToModel = StateTransform.create('mmcif', 'model', 'mmcif-to-model', - async function (ctx: StateContext, mmcifEntity: MmcifEntity) { - const models = await Model.create(Format.mmCIF(mmcifEntity.value.frame, mmcifEntity.value.db)).run(ctx.log) - return ModelEntity.ofModels(ctx, models) - }) - -export interface StructureProps { - assembly?: string -} - -export type ModelToStructure = StateTransform<ModelEntity, StructureEntity, StructureProps> -export const ModelToStructure: ModelToStructure = StateTransform.create('model', 'structure', 'model-to-structure', - async function (ctx: StateContext, modelEntity: ModelEntity, props: StructureProps = {}) { - const model = modelEntity.value[0] - const assembly = props.assembly - let structure: Structure - const assemblies = model.symmetry.assemblies - if (assemblies.length) { - structure = await StructureSymmetry.buildAssembly(Structure.ofModel(model), assembly || '1').run(ctx.log) - } else { - structure = Structure.ofModel(model) - } - return StructureEntity.ofStructure(ctx, structure) - }) - -export type StructureCenter = StateTransform<StructureEntity, NullEntity, {}> -export const StructureCenter: StructureCenter = StateTransform.create('structure', 'null', 'structure-center', - async function (ctx: StateContext, structureEntity: StructureEntity) { - ctx.viewer.center(structureEntity.value.boundary.sphere.center) - return NullEntity - }) - -export type StructureToSpacefill = StateTransform<StructureEntity, SpacefillEntity, Partial<SpacefillProps>> -export const StructureToSpacefill: StructureToSpacefill = StateTransform.create('structure', 'spacefill', 'structure-to-spacefill', - async function (ctx: StateContext, structureEntity: StructureEntity, props: Partial<SpacefillProps> = {}) { - const spacefillRepr = SpacefillRepresentation() - await spacefillRepr.createOrUpdate(props, structureEntity.value).run(ctx.log) - ctx.viewer.add(spacefillRepr) - ctx.viewer.requestDraw() - console.log('stats', ctx.viewer.stats) - return SpacefillEntity.ofRepr(ctx, spacefillRepr) - }) - -export type StructureToBallAndStick = StateTransform<StructureEntity, BallAndStickEntity, Partial<BallAndStickProps>> -export const StructureToBallAndStick: StructureToBallAndStick = StateTransform.create('structure', 'ballandstick', 'structure-to-ballandstick', - async function (ctx: StateContext, structureEntity: StructureEntity, props: Partial<BallAndStickProps> = {}) { - const ballAndStickRepr = BallAndStickRepresentation() - await ballAndStickRepr.createOrUpdate(props, structureEntity.value).run(ctx.log) - ctx.viewer.add(ballAndStickRepr) - ctx.viewer.requestDraw() - console.log('stats', ctx.viewer.stats) - return BallAndStickEntity.ofRepr(ctx, ballAndStickRepr) - }) - -export type StructureToDistanceRestraint = StateTransform<StructureEntity, DistanceRestraintEntity, Partial<DistanceRestraintProps>> -export const StructureToDistanceRestraint: StructureToDistanceRestraint = StateTransform.create('structure', 'distancerestraint', 'structure-to-distancerestraint', - async function (ctx: StateContext, structureEntity: StructureEntity, props: Partial<DistanceRestraintProps> = {}) { - const distanceRestraintRepr = DistanceRestraintRepresentation() - await distanceRestraintRepr.createOrUpdate(props, structureEntity.value).run(ctx.log) - ctx.viewer.add(distanceRestraintRepr) - ctx.viewer.requestDraw() - console.log('stats', ctx.viewer.stats) - return DistanceRestraintEntity.ofRepr(ctx, distanceRestraintRepr) - }) - -export type StructureToBackbone = StateTransform<StructureEntity, BackboneEntity, Partial<BackboneProps>> -export const StructureToBackbone: StructureToBackbone = StateTransform.create('structure', 'backbone', 'structure-to-backbone', - async function (ctx: StateContext, structureEntity: StructureEntity, props: Partial<BackboneProps> = {}) { - const backboneRepr = BackboneRepresentation() - await backboneRepr.createOrUpdate(props, structureEntity.value).run(ctx.log) - ctx.viewer.add(backboneRepr) - ctx.viewer.requestDraw() - console.log('stats', ctx.viewer.stats) - return BackboneEntity.ofRepr(ctx, backboneRepr) - }) - -export type StructureToCartoon = StateTransform<StructureEntity, CartoonEntity, Partial<CartoonProps>> -export const StructureToCartoon: StructureToCartoon = StateTransform.create('structure', 'cartoon', 'structure-to-cartoon', - async function (ctx: StateContext, structureEntity: StructureEntity, props: Partial<CartoonProps> = {}) { - const cartoonRepr = CartoonRepresentation() - await cartoonRepr.createOrUpdate(props, structureEntity.value).run(ctx.log) - ctx.viewer.add(cartoonRepr) - ctx.viewer.requestDraw() - console.log('stats', ctx.viewer.stats) - return CartoonEntity.ofRepr(ctx, cartoonRepr) - }) - -export type StructureToCarbohydrate = StateTransform<StructureEntity, CarbohydrateEntity, Partial<CarbohydrateProps>> -export const StructureToCarbohydrate: StructureToCarbohydrate = StateTransform.create('structure', 'carbohydrate', 'structure-to-cartoon', - async function (ctx: StateContext, structureEntity: StructureEntity, props: Partial<CarbohydrateProps> = {}) { - const carbohydrateRepr = CarbohydrateRepresentation() - await carbohydrateRepr.createOrUpdate(props, structureEntity.value).run(ctx.log) - ctx.viewer.add(carbohydrateRepr) - ctx.viewer.requestDraw() - console.log('stats', ctx.viewer.stats) - return CarbohydrateEntity.ofRepr(ctx, carbohydrateRepr) - }) - -export type SpacefillUpdate = StateTransform<SpacefillEntity, NullEntity, Partial<SpacefillProps>> -export const SpacefillUpdate: SpacefillUpdate = StateTransform.create('spacefill', 'null', 'spacefill-update', - async function (ctx: StateContext, spacefillEntity: SpacefillEntity, props: Partial<SpacefillProps> = {}) { - const spacefillRepr = spacefillEntity.value - await spacefillRepr.createOrUpdate(props).run(ctx.log) - ctx.viewer.add(spacefillRepr) - ctx.viewer.requestDraw() - console.log('stats', ctx.viewer.stats) - return NullEntity - }) - -export type BallAndStickUpdate = StateTransform<BallAndStickEntity, NullEntity, Partial<BallAndStickProps>> -export const BallAndStickUpdate: BallAndStickUpdate = StateTransform.create('ballandstick', 'null', 'ballandstick-update', - async function (ctx: StateContext, ballAndStickEntity: BallAndStickEntity, props: Partial<BallAndStickProps> = {}) { - const ballAndStickRepr = ballAndStickEntity.value - await ballAndStickRepr.createOrUpdate(props).run(ctx.log) - ctx.viewer.add(ballAndStickRepr) - ctx.viewer.requestDraw() - console.log('stats', ctx.viewer.stats) - return NullEntity - }) - -export type DistanceRestraintUpdate = StateTransform<DistanceRestraintEntity, NullEntity, Partial<DistanceRestraintProps>> -export const DistanceRestraintUpdate: DistanceRestraintUpdate = StateTransform.create('distancerestraint', 'null', 'distancerestraint-update', - async function (ctx: StateContext, distanceRestraintEntity: DistanceRestraintEntity, props: Partial<DistanceRestraintProps> = {}) { - const distanceRestraintRepr = distanceRestraintEntity.value - await distanceRestraintRepr.createOrUpdate(props).run(ctx.log) - ctx.viewer.add(distanceRestraintRepr) - ctx.viewer.requestDraw() - console.log('stats', ctx.viewer.stats) - return NullEntity - }) - -export type BackboneUpdate = StateTransform<BackboneEntity, NullEntity, Partial<BackboneProps>> -export const BackboneUpdate: BackboneUpdate = StateTransform.create('backbone', 'null', 'backbone-update', - async function (ctx: StateContext, backboneEntity: BackboneEntity, props: Partial<BackboneProps> = {}) { - const backboneRepr = backboneEntity.value - await backboneRepr.createOrUpdate(props).run(ctx.log) - ctx.viewer.add(backboneRepr) - ctx.viewer.requestDraw() - console.log('stats', ctx.viewer.stats) - return NullEntity - }) - -export type CartoonUpdate = StateTransform<CartoonEntity, NullEntity, Partial<CartoonProps>> -export const CartoonUpdate: CartoonUpdate = StateTransform.create('cartoon', 'null', 'cartoon-update', - async function (ctx: StateContext, cartoonEntity: CartoonEntity, props: Partial<CartoonProps> = {}) { - const cartoonRepr = cartoonEntity.value - await cartoonRepr.createOrUpdate(props).run(ctx.log) - ctx.viewer.add(cartoonRepr) - ctx.viewer.requestDraw() - console.log('stats', ctx.viewer.stats) - return NullEntity - }) - -export type CarbohydrateUpdate = StateTransform<CarbohydrateEntity, NullEntity, Partial<CarbohydrateProps>> -export const CarbohydrateUpdate: CarbohydrateUpdate = StateTransform.create('carbohydrate', 'null', 'carbohydrate-update', - async function (ctx: StateContext, carbohydrateEntity: CarbohydrateEntity, props: Partial<CarbohydrateProps> = {}) { - const carbohydrateRepr = carbohydrateEntity.value - await carbohydrateRepr.createOrUpdate(props).run(ctx.log) - ctx.viewer.add(carbohydrateRepr) - ctx.viewer.requestDraw() - console.log('stats', ctx.viewer.stats) - return NullEntity - }) - -// composed - -export type MmcifUrlToModel = StateTransform<UrlEntity, ModelEntity, {}> -export const MmcifUrlToModel: MmcifUrlToModel = StateTransform.create('url', 'model', 'url-to-model', - async function (ctx: StateContext, urlEntity: UrlEntity) { - const dataEntity = await UrlToData.apply(ctx, urlEntity) - return DataToModel.apply(ctx, dataEntity) - }) - -export type MmcifFileToModel = StateTransform<FileEntity, ModelEntity, {}> -export const MmcifFileToModel: MmcifFileToModel = StateTransform.create('file', 'model', 'file-to-model', - async function (ctx: StateContext, fileEntity: FileEntity) { - const dataEntity = await FileToData.apply(ctx, fileEntity) - return DataToModel.apply(ctx, dataEntity) - }) - -export type DataToModel = StateTransform<DataEntity, ModelEntity, {}> -export const DataToModel: DataToModel = StateTransform.create('data', 'model', 'data-to-model', - async function getModelFromData(ctx: StateContext, dataEntity: DataEntity) { - const cifEntity = await DataToCif.apply(ctx, dataEntity) - const mmcifEntity = await CifToMmcif.apply(ctx, cifEntity) - return MmcifToModel.apply(ctx, mmcifEntity) - }) - -export type ModelToSpacefill = StateTransform<ModelEntity, SpacefillEntity, Partial<SpacefillProps>> -export const ModelToSpacefill: ModelToSpacefill = StateTransform.create('model', 'spacefill', 'model-to-spacefill', - async function (ctx: StateContext, modelEntity: ModelEntity, props: Partial<SpacefillProps> = {}) { - const structureEntity = await ModelToStructure.apply(ctx, modelEntity) - // StructureToBond.apply(ctx, structureEntity, props) - return StructureToSpacefill.apply(ctx, structureEntity, props) - }) - -export type MmcifUrlToSpacefill = StateTransform<UrlEntity, SpacefillEntity, Partial<SpacefillProps>> -export const MmcifUrlToSpacefill: MmcifUrlToSpacefill = StateTransform.create('url', 'spacefill', 'url-to-spacefill', - async function (ctx: StateContext, urlEntity: UrlEntity, props: Partial<SpacefillProps> = {}) { - const modelEntity = await MmcifUrlToModel.apply(ctx, urlEntity) - return ModelToSpacefill.apply(ctx, modelEntity, props) - }) - -export type MmcifFileToSpacefill = StateTransform<FileEntity, SpacefillEntity, Partial<SpacefillProps>> -export const MmcifFileToSpacefill: MmcifFileToSpacefill = StateTransform.create('file', 'spacefill', 'file-to-spacefill', - async function (ctx: StateContext, fileEntity: FileEntity, props: Partial<SpacefillProps> = {}) { - const modelEntity = await MmcifFileToModel.apply(ctx, fileEntity) - return ModelToSpacefill.apply(ctx, modelEntity, props) - }) \ No newline at end of file diff --git a/src/mol-view/util.ts b/src/mol-view/util.ts deleted file mode 100644 index 0fa3e82b4..000000000 --- a/src/mol-view/util.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. - * - * @author Alexander Rose <alexander.rose@weirdbyte.de> - */ - -import CIF from 'mol-io/reader/cif' -import { Progress } from 'mol-task' -import { VolumeData, parseDensityServerData } from 'mol-model/volume' -import { DensityServer_Data_Database } from 'mol-io/reader/cif/schema/density-server'; - -export async function downloadCif(url: string, isBinary: boolean) { - const data = await fetch(url); - return parseCif(isBinary ? new Uint8Array(await data.arrayBuffer()) : await data.text()); -} - -export async function parseCif(data: string|Uint8Array) { - const comp = CIF.parse(data) - const parsed = await comp.run(Progress.format); - if (parsed.isError) throw parsed; - return parsed.result -} - -export type Volume = { source: DensityServer_Data_Database, volume: VolumeData } - -export async function getVolumeFromEmdId(emdid: string): Promise<Volume> { - const cif = await downloadCif(`https://webchem.ncbr.muni.cz/DensityServer/em/emd-${emdid}/cell?detail=4`, true) - const data = CIF.schema.densityServer(cif.blocks[1]) - return { source: data, volume: await parseDensityServerData(data).run() } -} - -export function resizeCanvas (canvas: HTMLCanvasElement, container: Element) { - let w = window.innerWidth - let h = window.innerHeight - if (container !== document.body) { - let bounds = container.getBoundingClientRect() - w = bounds.right - bounds.left - h = bounds.bottom - bounds.top - } - canvas.width = window.devicePixelRatio * w - canvas.height = window.devicePixelRatio * h - Object.assign(canvas.style, { width: `${w}px`, height: `${h}px` }) -} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index aa0ec9bcc..7b896a74e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -25,9 +25,10 @@ "mol-ql": ["./mol-ql"], "mol-script": ["./mol-script"], "mol-state": ["./mol-state", "./mol-state/index.ts"], + "mol-plugin": ["./mol-plugin", "./mol-plugin/index.ts"], "mol-task": ["./mol-task", "./mol-task/index.ts"], "mol-util": ["./mol-util", "./mol-util/index.ts"], - "mol-view": ["./mol-view"] + "mol-canvas3d": ["./mol-view"] } }, "include": [ "**/*" ], -- GitLab