react-cheminfo 0.63.1 → 0.64.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/molecule3d/core/highlight.d.ts +53 -0
- package/lib/molecule3d/core/highlight.d.ts.map +1 -0
- package/lib/molecule3d/core/highlight.js +96 -0
- package/lib/molecule3d/core/highlight.js.map +1 -0
- package/lib/molecule3d/core/index.d.ts +3 -1
- package/lib/molecule3d/core/index.d.ts.map +1 -1
- package/lib/molecule3d/core/index.js +2 -1
- package/lib/molecule3d/core/index.js.map +1 -1
- package/lib/molecule3d/core/measurement.d.ts +17 -0
- package/lib/molecule3d/core/measurement.d.ts.map +1 -1
- package/lib/molecule3d/core/measurement.js +43 -0
- package/lib/molecule3d/core/measurement.js.map +1 -1
- package/lib/molecule3d/ui/MoleculeCanvas3D.d.ts.map +1 -1
- package/lib/molecule3d/ui/MoleculeCanvas3D.js +7 -1
- package/lib/molecule3d/ui/MoleculeCanvas3D.js.map +1 -1
- package/lib/molecule3d/ui/drawScene.d.ts +4 -2
- package/lib/molecule3d/ui/drawScene.d.ts.map +1 -1
- package/lib/molecule3d/ui/drawScene.js +1 -1
- package/lib/molecule3d/ui/drawScene.js.map +1 -1
- package/lib/molecule3d/ui/highlightColor.d.ts +18 -0
- package/lib/molecule3d/ui/highlightColor.d.ts.map +1 -0
- package/lib/molecule3d/ui/highlightColor.js +31 -0
- package/lib/molecule3d/ui/highlightColor.js.map +1 -0
- package/lib/molecule3d/ui/moleculeViewer3DProps.d.ts +16 -1
- package/lib/molecule3d/ui/moleculeViewer3DProps.d.ts.map +1 -1
- package/lib/molecule3d/ui/renderMolecule.d.ts +2 -0
- package/lib/molecule3d/ui/renderMolecule.d.ts.map +1 -1
- package/lib/molecule3d/ui/renderMolecule.js +1 -1
- package/lib/molecule3d/ui/renderMolecule.js.map +1 -1
- package/lib/molecule3d/ui/sceneDrawer.d.ts +47 -0
- package/lib/molecule3d/ui/sceneDrawer.d.ts.map +1 -0
- package/lib/molecule3d/ui/sceneDrawer.js +103 -0
- package/lib/molecule3d/ui/sceneDrawer.js.map +1 -0
- package/lib/molecule3d/ui/useMoleculeScene.d.ts +2 -1
- package/lib/molecule3d/ui/useMoleculeScene.d.ts.map +1 -1
- package/lib/molecule3d/ui/useMoleculeScene.js +13 -22
- package/lib/molecule3d/ui/useMoleculeScene.js.map +1 -1
- package/lib/molecule3d/ui/useSharedCamera.d.ts +1 -3
- package/lib/molecule3d/ui/useSharedCamera.d.ts.map +1 -1
- package/lib/molecule3d/ui/useSharedCamera.js.map +1 -1
- package/lib/molecule3d/ui/viewer.d.ts +9 -0
- package/lib/molecule3d/ui/viewer.d.ts.map +1 -1
- package/lib/molecule3d/ui/viewer.js +18 -2
- package/lib/molecule3d/ui/viewer.js.map +1 -1
- package/lib/molstar/core/highlights.d.ts +57 -0
- package/lib/molstar/core/highlights.d.ts.map +1 -0
- package/lib/molstar/core/highlights.js +178 -0
- package/lib/molstar/core/highlights.js.map +1 -0
- package/lib/molstar/core/index.d.ts +2 -1
- package/lib/molstar/core/index.d.ts.map +1 -1
- package/lib/molstar/core/index.js +2 -1
- package/lib/molstar/core/index.js.map +1 -1
- package/package.json +1 -1
- package/src/molecule3d/core/highlight.ts +127 -0
- package/src/molecule3d/core/index.ts +7 -0
- package/src/molecule3d/core/measurement.ts +47 -0
- package/src/molecule3d/ui/MoleculeCanvas3D.tsx +13 -0
- package/src/molecule3d/ui/drawScene.ts +13 -2
- package/src/molecule3d/ui/highlightColor.ts +34 -0
- package/src/molecule3d/ui/moleculeViewer3DProps.ts +16 -1
- package/src/molecule3d/ui/renderMolecule.ts +1 -1
- package/src/molecule3d/ui/sceneDrawer.ts +132 -0
- package/src/molecule3d/ui/useMoleculeScene.ts +16 -26
- package/src/molecule3d/ui/useSharedCamera.ts +1 -3
- package/src/molecule3d/ui/viewer.ts +23 -0
- package/src/molstar/core/highlights.ts +236 -0
- package/src/molstar/core/index.ts +2 -1
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What one canvas shows, what it is asked to show next, and the least work
|
|
3
|
+
* between the two.
|
|
4
|
+
*
|
|
5
|
+
* The measurements are drawn over the model, not into it: a change of them
|
|
6
|
+
* alone replaces their own representations and leaves the model, its surface,
|
|
7
|
+
* its highlights and the camera as they are. Only another molecule, or another
|
|
8
|
+
* style for it, draws the scene again, and only another molecule frames the
|
|
9
|
+
* camera. Draws run one after another, so a measurement never lands on a model
|
|
10
|
+
* that is half built, and the last request asked is the one drawn.
|
|
11
|
+
*/
|
|
12
|
+
import { sameMeasurements } from "../core/measurement.js";
|
|
13
|
+
import { sameMolecule3DSettings } from "../core/settings.js";
|
|
14
|
+
import { drawScene } from "./drawScene.js";
|
|
15
|
+
/** Keeps one viewer showing the last scene it was asked for. */
|
|
16
|
+
export class SceneDrawer {
|
|
17
|
+
/** The viewer drawn on. */
|
|
18
|
+
viewer;
|
|
19
|
+
#takeLinkedCamera;
|
|
20
|
+
#asked = null;
|
|
21
|
+
// The model on screen, or `null` when the next request must draw it again.
|
|
22
|
+
#drawn = null;
|
|
23
|
+
// The measurements on screen, or `null` when the next request must draw them.
|
|
24
|
+
#measured = [];
|
|
25
|
+
// The molecule the camera was last framed on, so another one is told apart.
|
|
26
|
+
#framed = null;
|
|
27
|
+
#queue = Promise.resolve();
|
|
28
|
+
/**
|
|
29
|
+
* Start drawing on `viewer`, whose scene is empty.
|
|
30
|
+
* @param viewer - The viewer to draw on.
|
|
31
|
+
* @param takeLinkedCamera - Asked when a molecule is new: a camera to stand
|
|
32
|
+
* at instead of framing it, or `null`.
|
|
33
|
+
*/
|
|
34
|
+
constructor(viewer, takeLinkedCamera) {
|
|
35
|
+
this.viewer = viewer;
|
|
36
|
+
this.#takeLinkedCamera = takeLinkedCamera;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Bring the canvas to `request`, once whatever was asked before is drawn.
|
|
40
|
+
* @param request - The scene to show; replaces any request still waiting.
|
|
41
|
+
* @returns Nothing; resolves once the canvas shows the last request asked,
|
|
42
|
+
* and rejects with what stopped it from being drawn.
|
|
43
|
+
*/
|
|
44
|
+
draw(request) {
|
|
45
|
+
this.#asked = request;
|
|
46
|
+
const drawn = this.#queue.then(() => this.#catchUp());
|
|
47
|
+
this.#queue = drawn.catch(ignore);
|
|
48
|
+
return drawn;
|
|
49
|
+
}
|
|
50
|
+
async #catchUp() {
|
|
51
|
+
const request = this.#asked;
|
|
52
|
+
if (request === null)
|
|
53
|
+
return;
|
|
54
|
+
const drawn = this.#drawn;
|
|
55
|
+
if (drawn !== null &&
|
|
56
|
+
sameFile(drawn.molfile, request.molfile) &&
|
|
57
|
+
sameMolecule3DSettings(drawn.settings, request.settings)) {
|
|
58
|
+
await this.#measure(request);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
await this.#redraw(request);
|
|
62
|
+
}
|
|
63
|
+
// The model stays: only the measurements over it can have changed.
|
|
64
|
+
async #measure(request) {
|
|
65
|
+
const { molfile, measurements } = request;
|
|
66
|
+
const measured = this.#measured;
|
|
67
|
+
if (measured !== null && sameMeasurements(measured, measurements))
|
|
68
|
+
return;
|
|
69
|
+
// As for the model: a list that fails partway is drawn again next time.
|
|
70
|
+
this.#measured = null;
|
|
71
|
+
// An empty scene has nothing to measure; the list waits for a molecule.
|
|
72
|
+
if (molfile !== null)
|
|
73
|
+
await this.viewer.showMeasurements(measurements);
|
|
74
|
+
this.#measured = measurements;
|
|
75
|
+
}
|
|
76
|
+
async #redraw(request) {
|
|
77
|
+
const { molfile, settings, measurements, frameNewMolecule } = request;
|
|
78
|
+
const isNew = molfile !== null &&
|
|
79
|
+
(this.#framed === null || !sameFile(this.#framed, molfile));
|
|
80
|
+
this.#framed = molfile;
|
|
81
|
+
// A link's camera is spent on the first molecule framed; afterwards the
|
|
82
|
+
// camera is the reader's and a new molecule is framed as usual.
|
|
83
|
+
const linked = isNew ? this.#takeLinkedCamera() : null;
|
|
84
|
+
const frameCamera = isNew && linked === null ? frameNewMolecule : 'none';
|
|
85
|
+
// Kept only once drawn: a draw that fails is drawn again by the next
|
|
86
|
+
// request, whatever that one changes.
|
|
87
|
+
this.#drawn = null;
|
|
88
|
+
await drawScene(this.viewer, molfile, settings, measurements, frameCamera);
|
|
89
|
+
this.#drawn = { molfile, settings };
|
|
90
|
+
this.#measured = measurements;
|
|
91
|
+
if (linked !== null)
|
|
92
|
+
await this.viewer.setCamera(linked);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function sameFile(first, second) {
|
|
96
|
+
if (first === null || second === null)
|
|
97
|
+
return first === second;
|
|
98
|
+
return first.format === second.format && first.data === second.data;
|
|
99
|
+
}
|
|
100
|
+
function ignore() {
|
|
101
|
+
// A failure reached the caller of `draw`; the next draw still runs.
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=sceneDrawer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sceneDrawer.js","sourceRoot":"","sources":["../../../src/molecule3d/ui/sceneDrawer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAG7D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAc3C,gEAAgE;AAChE,MAAM,OAAO,WAAW;IACtB,2BAA2B;IAClB,MAAM,CAAc;IACpB,iBAAiB,CAAgC;IAC1D,MAAM,GAAwB,IAAI,CAAC;IACnC,2EAA2E;IAC3E,MAAM,GAAsD,IAAI,CAAC;IACjE,8EAA8E;IAC9E,SAAS,GAAkC,EAAE,CAAC;IAC9C,4EAA4E;IAC5E,OAAO,GAA0B,IAAI,CAAC;IACtC,MAAM,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAC;IAE1C;;;;;OAKG;IACH,YACE,MAAmB,EACnB,gBAA+C;QAE/C,IAAI,CAAC,MA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AAO,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,CAAC;AACtE,CAAC;AAED,SAAS,MAAM;IACb,oEAAoE;AACtE,CAAC"}
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* The draw is coalesced into one animation frame, so dragging a slider costs
|
|
6
6
|
* one rebuild rather than one per pixel, and the camera is framed only when the
|
|
7
7
|
* molecule is new — a restyle that snapped the view back would undo the
|
|
8
|
-
* reader's orientation.
|
|
8
|
+
* reader's orientation. What each draw rebuilds is the scene drawer's call: a
|
|
9
|
+
* change of the measurements alone redraws them and nothing else.
|
|
9
10
|
*/
|
|
10
11
|
import type { RefObject } from 'react';
|
|
11
12
|
import type { Measurement } from '../core/measurement.ts';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMoleculeScene.d.ts","sourceRoot":"","sources":["../../../src/molecule3d/ui/useMoleculeScene.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"useMoleculeScene.d.ts","sourceRoot":"","sources":["../../../src/molecule3d/ui/useMoleculeScene.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAMxE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,8CAA8C;AAC9C,MAAM,WAAW,oBAAoB;IACnC,gEAAgE;IAChE,SAAS,EAAE,WAAW,GAAG,IAAI,CAAC;IAC9B,gCAAgC;IAChC,SAAS,EAAE,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IAC9C,kDAAkD;IAClD,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IAC/B,8DAA8D;IAC9D,gBAAgB,EAAE,OAAO,GAAG,MAAM,CAAC;IACnC,8BAA8B;IAC9B,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,6BAA6B;IAC7B,YAAY,EAAE,SAAS,WAAW,EAAE,CAAC;IACrC,+CAA+C;IAC/C,QAAQ,EAAE,OAAO,CAAC;IAClB,2EAA2E;IAC3E,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAClD,kFAAkF;IAClF,MAAM,EAAE,IAAI,CACV,qBAAqB,EACrB,mBAAmB,GAAG,eAAe,GAAG,gBAAgB,CACzD,CAAC;CACH;AAED,6CAA6C;AAC7C,MAAM,WAAW,aAAa;IAC5B,4EAA4E;IAC5E,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CAqE7E"}
|
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
* The draw is coalesced into one animation frame, so dragging a slider costs
|
|
6
6
|
* one rebuild rather than one per pixel, and the camera is framed only when the
|
|
7
7
|
* molecule is new — a restyle that snapped the view back would undo the
|
|
8
|
-
* reader's orientation.
|
|
8
|
+
* reader's orientation. What each draw rebuilds is the scene drawer's call: a
|
|
9
|
+
* change of the measurements alone redraws them and nothing else.
|
|
9
10
|
*/
|
|
10
11
|
import { useCallback, useEffect, useRef } from 'react';
|
|
11
|
-
import {
|
|
12
|
+
import { SceneDrawer } from "./sceneDrawer.js";
|
|
12
13
|
import { DEFAULT_CAMERA_SETTLE_DELAY, useSharedCamera, } from "./useSharedCamera.js";
|
|
13
14
|
/**
|
|
14
15
|
* Draw the scene the options describe, and keep it drawn.
|
|
@@ -17,7 +18,7 @@ import { DEFAULT_CAMERA_SETTLE_DELAY, useSharedCamera, } from "./useSharedCamera
|
|
|
17
18
|
*/
|
|
18
19
|
export function useMoleculeScene(options) {
|
|
19
20
|
const { container, viewerRef, molfile, frameNewMolecule, settings, measurements, spinning, onFailureChange, camera: cameraProps, } = options;
|
|
20
|
-
const
|
|
21
|
+
const drawerRef = useRef(null);
|
|
21
22
|
const reportFailure = useRef(onFailureChange);
|
|
22
23
|
useEffect(() => {
|
|
23
24
|
reportFailure.current = onFailureChange;
|
|
@@ -34,27 +35,17 @@ export function useMoleculeScene(options) {
|
|
|
34
35
|
const viewer = viewerRef.current;
|
|
35
36
|
if (container === null || viewer === null)
|
|
36
37
|
return;
|
|
38
|
+
// A new viewer starts from an empty scene, so it gets a drawer of its own.
|
|
39
|
+
if (drawerRef.current?.viewer !== viewer) {
|
|
40
|
+
drawerRef.current = new SceneDrawer(viewer, camera.takeLinkedCamera);
|
|
41
|
+
}
|
|
42
|
+
const drawer = drawerRef.current;
|
|
37
43
|
let cancelled = false;
|
|
38
44
|
const frame = requestAnimationFrame(() => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
// The link's camera is spent on the first molecule framed; afterwards the
|
|
44
|
-
// camera is the reader's and a new molecule is framed as usual.
|
|
45
|
-
const linked = isNew
|
|
46
|
-
? camera.takeLinkedCamera()
|
|
47
|
-
: null;
|
|
48
|
-
const frameCamera = isNew && linked === null ? frameNewMolecule : 'none';
|
|
49
|
-
void drawScene(viewer, molfile, settings, measurements, frameCamera)
|
|
50
|
-
.then(() => {
|
|
51
|
-
if (cancelled)
|
|
52
|
-
return;
|
|
53
|
-
if (linked !== null)
|
|
54
|
-
void viewer.setCamera(linked);
|
|
55
|
-
reportFailure.current(null);
|
|
56
|
-
})
|
|
57
|
-
.catch((error) => {
|
|
45
|
+
drawer.draw({ molfile, settings, measurements, frameNewMolecule }).then(() => {
|
|
46
|
+
if (!cancelled)
|
|
47
|
+
reportFailure.current(null);
|
|
48
|
+
}, (error) => {
|
|
58
49
|
if (cancelled)
|
|
59
50
|
return;
|
|
60
51
|
reportFailure.current(error instanceof Error ? error.message : String(error));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMoleculeScene.js","sourceRoot":"","sources":["../../../src/molecule3d/ui/useMoleculeScene.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"useMoleculeScene.js","sourceRoot":"","sources":["../../../src/molecule3d/ui/useMoleculeScene.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAMvD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EACL,2BAA2B,EAC3B,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAkC9B;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAA6B;IAC5D,MAAM,EACJ,SAAS,EACT,SAAS,EACT,OAAO,EACP,gBAAgB,EAChB,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,eAAe,EACf,MAAM,EAAE,WAAW,GACpB,GAAG,OAAO,CAAC;IACZ,MAAM,SAAS,GAAG,MAAM,CAAqB,IAAI,CAAC,CAAC;IACnD,MAAM,aAAa,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;IAC9C,SAAS,CAAC,GAAG,EAAE;QACb,aAAa,CAAC,OAAO,GAAG,eAAe,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,eAAe,CAAC;QAC7B,SAAS;QACT,SAAS;QACT,QAAQ;QACR,aAAa,EAAE,WAAW,CAAC,aAAa,IAAI,IAAI;QAChD,cAAc,EAAE,WAAW,CAAC,cAAc;QAC1C,WAAW,EAAE,WAAW,CAAC,iBAAiB,IAAI,2BAA2B;KAC1E,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC;QACjC,IAAI,SAAS,KAAK,IAAI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AC,CAAC;IAExB,OAAO,EAAE,SAAS,EAAE,CAAC;AACvB,CAAC"}
|
|
@@ -29,9 +29,7 @@ export interface SharedCameraOptions {
|
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* What {@link useSharedCamera} answers. The same object on every render: the
|
|
32
|
-
* draw effect keys on it, and a fresh one would
|
|
33
|
-
* it again — which makes molstar frame the model afresh and loses the camera a
|
|
34
|
-
* link had just restored.
|
|
32
|
+
* draw effect keys on it, and a fresh one would run it again for nothing.
|
|
35
33
|
*/
|
|
36
34
|
export interface SharedCamera {
|
|
37
35
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSharedCamera.d.ts","sourceRoot":"","sources":["../../../src/molecule3d/ui/useSharedCamera.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,iFAAiF;AACjF,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAE/C,6CAA6C;AAC7C,MAAM,WAAW,mBAAmB;IAClC,gEAAgE;IAChE,SAAS,EAAE,WAAW,GAAG,IAAI,CAAC;IAC9B,gCAAgC;IAChC,SAAS,EAAE,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IAC9C,iEAAiE;IACjE,aAAa,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACvC,2DAA2D;IAC3D,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACpD,8DAA8D;IAC9D,QAAQ,EAAE,OAAO,CAAC;IAClB,mEAAmE;IACnE,WAAW,EAAE,MAAM,CAAC;CACrB;AAED
|
|
1
|
+
{"version":3,"file":"useSharedCamera.d.ts","sourceRoot":"","sources":["../../../src/molecule3d/ui/useSharedCamera.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,iFAAiF;AACjF,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAE/C,6CAA6C;AAC7C,MAAM,WAAW,mBAAmB;IAClC,gEAAgE;IAChE,SAAS,EAAE,WAAW,GAAG,IAAI,CAAC;IAC9B,gCAAgC;IAChC,SAAS,EAAE,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IAC9C,iEAAiE;IACjE,aAAa,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACvC,2DAA2D;IAC3D,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACpD,8DAA8D;IAC9D,QAAQ,EAAE,OAAO,CAAC;IAClB,mEAAmE;IACnE,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,gBAAgB,EAAE,MAAM,gBAAgB,GAAG,IAAI,CAAC;IAChD,mEAAmE;IACnE,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY,CA6D1E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSharedCamera.js","sourceRoot":"","sources":["../../../src/molecule3d/ui/useSharedCamera.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAGhE,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAI3D,iF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YACV,IAAI,KAAK,KAAK,IAAI;gBAAE,YAAY,CAAC,KAAK,CAAC,CAAC;YACxC,SAAS,CAAC,mBAAmB,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;YACvD,SAAS,CAAC,mBAAmB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YACjD,YAAY,EAAE,CAAC;QACjB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;IAElD,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC,EAAE,gBAAgB,EAAE,QAAQ,EAAE,CAAC,EACtC,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAC7B,CAAC;AACJ,CAAC"}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import type { Molecule3DCamera } from '../core/camera.ts';
|
|
11
11
|
import type { ImageSize } from '../core/exportImage.ts';
|
|
12
|
+
import type { Molecule3DHighlight } from '../core/highlight.ts';
|
|
12
13
|
import type { Measurement, MeasurementKind } from '../core/measurement.ts';
|
|
13
14
|
import type { Molecule3DFile } from '../core/settings.ts';
|
|
14
15
|
import type { Molecule3DViewerOptions, MoleculeStyle, SurfaceStyle } from './viewerTypes.ts';
|
|
@@ -56,6 +57,14 @@ export declare class Molecule3DViewer {
|
|
|
56
57
|
* @returns Nothing; resolves once the labels are on screen.
|
|
57
58
|
*/
|
|
58
59
|
showMeasurements(measurements: readonly Measurement[]): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Emphasise exactly these paths of atoms on the model — this one and every
|
|
62
|
+
* one drawn after it — without redrawing the scene or moving the camera.
|
|
63
|
+
* @param highlights - Replaces what is emphasised; empty restores the model.
|
|
64
|
+
* @param color - What they are painted in, as `#rrggbb`.
|
|
65
|
+
* @returns Nothing; resolves once the model is repainted.
|
|
66
|
+
*/
|
|
67
|
+
setHighlights(highlights: readonly Molecule3DHighlight[], color: string): Promise<void>;
|
|
59
68
|
/**
|
|
60
69
|
* Make clicks on atoms build a measurement, or give them back to the camera.
|
|
61
70
|
* @param kind - The measurement to build, or `null`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewer.d.ts","sourceRoot":"","sources":["../../../src/molecule3d/ui/viewer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"viewer.d.ts","sourceRoot":"","sources":["../../../src/molecule3d/ui/viewer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAgBH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAU1D,OAAO,KAAK,EACV,uBAAuB,EACvB,aAAa,EACb,YAAY,EACb,MAAM,kBAAkB,CAAC;AAE1B;;;GAGG;AACH,qBAAa,gBAAgB;;IAK3B,0EAA0E;IAC1E,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9B;;;;OAIG;gBACS,SAAS,EAAE,WAAW,EAAE,OAAO,GAAE,uBAA4B;IAiBzE;;;;;;OAMG;IACH,YAAY,CAAC,OAAO,EAAE,cAAc,EAAE,KAAK,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAO3E;;;OAGG;IACH,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAO7B;;;;OAIG;IACH,WAAW,CAAC,KAAK,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhD;;;OAGG;IACH,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B;;;;OAIG;IACH,gBAAgB,CAAC,YAAY,EAAE,SAAS,WAAW,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAMrE;;;;;;OAMG;IACH,aAAa,CACX,UAAU,EAAE,SAAS,mBAAmB,EAAE,EAC1C,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC;IAMhB;;;;OAIG;IACH,cAAc,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAM3D;;;;;;OAMG;IACH,YAAY,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAI1D;;;;;OAKG;IACH,WAAW,CACT,oBAAoB,SAA0B,EAC9C,SAAS,UAAQ,GAChB,OAAO,CAAC,IAAI,CAAC;IAMhB;;;;;OAKG;IACH,SAAS,CAAC,MAAM,EAAE,gBAAgB,EAAE,oBAAoB,SAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAM5E;;;;;OAKG;IACH,WAAW,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,KAAK,IAAI,GAAG,MAAM,IAAI;IAI5E;;;;;OAKG;IACH,OAAO,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,SAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAMrE,kEAAkE;IAClE,YAAY,IAAI,IAAI;IAIpB,sEAAsE;IACtE,OAAO,IAAI,IAAI;CAWhB"}
|
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
* the viewer has been disposed. molstar's own UI is not mounted: every control
|
|
8
8
|
* is the component's.
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
10
|
+
import { Color } from 'molstar/lib/mol-util/color/color.js';
|
|
11
|
+
import { DEFAULT_CAMERA_DURATION, DEFAULT_SPIN_SPEED, HighlightPainter, MeasurementPicker, MolstarPlugin, captureScene, clearMeasurements, renderMeasurements, setSpin, } from "../../molstar/core/index.js";
|
|
11
12
|
import { applyCamera, resetCamera, watchCamera } from "./camera.js";
|
|
12
|
-
import { clearMolecule, moleculeStructure, renderMolecule, } from "./renderMolecule.js";
|
|
13
|
+
import { MODEL_REPRESENTATION_REF, clearMolecule, moleculeStructure, renderMolecule, } from "./renderMolecule.js";
|
|
13
14
|
import { clearSurface, renderSurface } from "./renderSurface.js";
|
|
14
15
|
/**
|
|
15
16
|
* One molstar canvas, and every operation the component performs on it. Every
|
|
@@ -18,6 +19,7 @@ import { clearSurface, renderSurface } from "./renderSurface.js";
|
|
|
18
19
|
export class Molecule3DViewer {
|
|
19
20
|
#plugin;
|
|
20
21
|
#picker;
|
|
22
|
+
#painter;
|
|
21
23
|
/** Resolves once the canvas exists; every method awaits it internally. */
|
|
22
24
|
ready;
|
|
23
25
|
/**
|
|
@@ -33,6 +35,7 @@ export class Molecule3DViewer {
|
|
|
33
35
|
void this.#plugin
|
|
34
36
|
.run((plugin) => {
|
|
35
37
|
this.#picker = new MeasurementPicker(plugin, onMeasure, moleculeStructure);
|
|
38
|
+
this.#painter = new HighlightPainter(plugin, MODEL_REPRESENTATION_REF);
|
|
36
39
|
})
|
|
37
40
|
.catch(ignore);
|
|
38
41
|
}
|
|
@@ -82,6 +85,18 @@ export class Molecule3DViewer {
|
|
|
82
85
|
showMeasurements(measurements) {
|
|
83
86
|
return this.#run((plugin) => renderMeasurements(plugin, measurements, moleculeStructure));
|
|
84
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Emphasise exactly these paths of atoms on the model — this one and every
|
|
90
|
+
* one drawn after it — without redrawing the scene or moving the camera.
|
|
91
|
+
* @param highlights - Replaces what is emphasised; empty restores the model.
|
|
92
|
+
* @param color - What they are painted in, as `#rrggbb`.
|
|
93
|
+
* @returns Nothing; resolves once the model is repainted.
|
|
94
|
+
*/
|
|
95
|
+
setHighlights(highlights, color) {
|
|
96
|
+
return this.#run(() => {
|
|
97
|
+
this.#painter?.set(highlights, Color.fromHexStyle(color));
|
|
98
|
+
});
|
|
99
|
+
}
|
|
85
100
|
/**
|
|
86
101
|
* Make clicks on atoms build a measurement, or give them back to the camera.
|
|
87
102
|
* @param kind - The measurement to build, or `null`.
|
|
@@ -151,6 +166,7 @@ export class Molecule3DViewer {
|
|
|
151
166
|
/** Tear the viewer down and release its WebGL context. Idempotent. */
|
|
152
167
|
dispose() {
|
|
153
168
|
this.#picker?.dispose();
|
|
169
|
+
this.#painter?.dispose();
|
|
154
170
|
this.#plugin.dispose();
|
|
155
171
|
}
|
|
156
172
|
#run(action) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewer.js","sourceRoot":"","sources":["../../../src/molecule3d/ui/viewer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"viewer.js","sourceRoot":"","sources":["../../../src/molecule3d/ui/viewer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAC;AAE5D,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,OAAO,GACR,MAAM,6BAA6B,CAAC;AAOrC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EACL,wBAAwB,EACxB,aAAa,EACb,iBAAiB,EACjB,cAAc,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAOjE;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IAClB,OAAO,CAAgB;IAChC,OAAO,CAAgC;IACvC,QAAQ,CAA+B;IAEvC,0EAA0E;IACjE,KAAK,CAAgB;IAE9B;;;;OAIG;IACH,YAAY,SAAsB,EAAE,UAAmC,EAAE;QACvE,MAAM,EAAE,UAAU,EAAE,SAAS,GAAG,MAAM,E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E,MAAM,EAAE,oBAAoB,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,WAAW,CAAC,QAAmD;QAC7D,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC3E,CAAC;IAED;;;;;OAKG;IACH,OAAO,CAAC,QAAiB,EAAE,KAAK,GAAG,kBAAkB;QACnD,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;YAC1B,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;IACL,CAAC;IAED,kEAAkE;IAClE,YAAY;QACV,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC;IAC9B,CAAC;IAED,sEAAsE;IACtE,OAAO;QACL,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC;QACzB,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;IAED,IAAI,CACF,MAA2D;QAE3D,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;CACF;AAED,SAAS,MAAM;IACb,iBAAiB;AACnB,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Atoms and bonds of the displayed molecule emphasised in one colour, for as
|
|
3
|
+
* long as a site keeps pointing at them.
|
|
4
|
+
*
|
|
5
|
+
* Neither of molstar's own markings fits: its hover highlight is erased by the
|
|
6
|
+
* next move of the pointer, and its selection belongs to the measuring tools.
|
|
7
|
+
* This is an overpaint of the model's own representation instead, so it
|
|
8
|
+
* follows the model in every style, survives the hover, and leaves the camera
|
|
9
|
+
* and every other drawing alone.
|
|
10
|
+
*
|
|
11
|
+
* molstar paints an atom and every half-bond leaving it from one element loci,
|
|
12
|
+
* which would tint the C–C bonds of a row that names only C–H ones. So the
|
|
13
|
+
* overpaint has three layers: the atoms, then those half-bonds cleared again,
|
|
14
|
+
* then exactly the bonds the paths name, as bond loci.
|
|
15
|
+
*/
|
|
16
|
+
import type { Structure } from 'molstar/lib/mol-model/structure.js';
|
|
17
|
+
import { Bond, StructureElement } from 'molstar/lib/mol-model/structure.js';
|
|
18
|
+
import type { PluginContext } from 'molstar/lib/mol-plugin/context.js';
|
|
19
|
+
import { Overpaint } from 'molstar/lib/mol-theme/overpaint.js';
|
|
20
|
+
import type { Color } from 'molstar/lib/mol-util/color/color.js';
|
|
21
|
+
import type { Molecule3DHighlight } from '../../molecule3d/core/highlight.ts';
|
|
22
|
+
/** The loci an overpaint layer of {@link highlightOverpaint} holds. */
|
|
23
|
+
type HighlightLoci = StructureElement.Loci | Bond.Loci;
|
|
24
|
+
/**
|
|
25
|
+
* The overpaint that emphasises `highlights` on a representation of
|
|
26
|
+
* `structure`: their atoms, and exactly the bonds between consecutive atoms of
|
|
27
|
+
* each path.
|
|
28
|
+
* @param structure - The structure the representation is drawn from.
|
|
29
|
+
* @param highlights - The paths; an atom the structure lacks is skipped.
|
|
30
|
+
* @param color - What they are painted in.
|
|
31
|
+
* @returns The overpaint, empty when no atom is left to paint.
|
|
32
|
+
*/
|
|
33
|
+
export declare function highlightOverpaint(structure: Structure, highlights: readonly Molecule3DHighlight[], color: Color): Overpaint<HighlightLoci>;
|
|
34
|
+
/**
|
|
35
|
+
* Keeps one representation of the state tree painted with the highlights a
|
|
36
|
+
* site asks for: the one there now, and every one built under the same ref
|
|
37
|
+
* afterwards, so a restyled model or a new conformer comes up already painted.
|
|
38
|
+
*/
|
|
39
|
+
export declare class HighlightPainter {
|
|
40
|
+
#private;
|
|
41
|
+
/**
|
|
42
|
+
* Start following the representation at `representationRef`.
|
|
43
|
+
* @param plugin - The molstar context.
|
|
44
|
+
* @param representationRef - State-tree ref of the representation to paint.
|
|
45
|
+
*/
|
|
46
|
+
constructor(plugin: PluginContext, representationRef: string);
|
|
47
|
+
/**
|
|
48
|
+
* Paint exactly these highlights, in place of the ones painted.
|
|
49
|
+
* @param highlights - The paths; an empty list restores the plain model.
|
|
50
|
+
* @param color - What they are painted in.
|
|
51
|
+
*/
|
|
52
|
+
set(highlights: readonly Molecule3DHighlight[], color: Color): void;
|
|
53
|
+
/** Stop following the representation. */
|
|
54
|
+
dispose(): void;
|
|
55
|
+
}
|
|
56
|
+
export {};
|
|
57
|
+
//# sourceMappingURL=highlights.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"highlights.d.ts","sourceRoot":"","sources":["../../../src/molstar/core/highlights.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EACL,IAAI,EACJ,gBAAgB,EAEjB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAGvE,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAC;AAEjE,OAAO,KAAK,EAEV,mBAAmB,EACpB,MAAM,oCAAoC,CAAC;AAY5C,uEAAuE;AACvE,KAAK,aAAa,GAAG,gBAAgB,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;AAEvD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,SAAS,mBAAmB,EAAE,EAC1C,KAAK,EAAE,KAAK,GACX,SAAS,CAAC,aAAa,CAAC,CAgB1B;AAED;;;;GAIG;AACH,qBAAa,gBAAgB;;IAO3B;;;;OAIG;gBACS,MAAM,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM;IAgB5D;;;;OAIG;IACH,GAAG,CAAC,UAAU,EAAE,SAAS,mBAAmB,EAAE,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI;IASnE,yCAAyC;IACzC,OAAO,IAAI,IAAI;CAwBhB"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Atoms and bonds of the displayed molecule emphasised in one colour, for as
|
|
3
|
+
* long as a site keeps pointing at them.
|
|
4
|
+
*
|
|
5
|
+
* Neither of molstar's own markings fits: its hover highlight is erased by the
|
|
6
|
+
* next move of the pointer, and its selection belongs to the measuring tools.
|
|
7
|
+
* This is an overpaint of the model's own representation instead, so it
|
|
8
|
+
* follows the model in every style, survives the hover, and leaves the camera
|
|
9
|
+
* and every other drawing alone.
|
|
10
|
+
*
|
|
11
|
+
* molstar paints an atom and every half-bond leaving it from one element loci,
|
|
12
|
+
* which would tint the C–C bonds of a row that names only C–H ones. So the
|
|
13
|
+
* overpaint has three layers: the atoms, then those half-bonds cleared again,
|
|
14
|
+
* then exactly the bonds the paths name, as bond loci.
|
|
15
|
+
*/
|
|
16
|
+
import { OrderedSet, SortedArray } from 'molstar/lib/mol-data/int.js';
|
|
17
|
+
import { Bond, StructureElement, Unit, } from 'molstar/lib/mol-model/structure.js';
|
|
18
|
+
import { PluginStateObject } from 'molstar/lib/mol-plugin-state/objects.js';
|
|
19
|
+
import { Overpaint } from 'molstar/lib/mol-theme/overpaint.js';
|
|
20
|
+
import { highlightedParts, sameHighlights, } from "../../molecule3d/core/highlight.js";
|
|
21
|
+
// Lowercased: they are factories, not constructors.
|
|
22
|
+
const elementLoci = StructureElement.Loci;
|
|
23
|
+
const bondLoci = Bond.Loci;
|
|
24
|
+
const bondLocation = Bond.Location;
|
|
25
|
+
/**
|
|
26
|
+
* The overpaint that emphasises `highlights` on a representation of
|
|
27
|
+
* `structure`: their atoms, and exactly the bonds between consecutive atoms of
|
|
28
|
+
* each path.
|
|
29
|
+
* @param structure - The structure the representation is drawn from.
|
|
30
|
+
* @param highlights - The paths; an atom the structure lacks is skipped.
|
|
31
|
+
* @param color - What they are painted in.
|
|
32
|
+
* @returns The overpaint, empty when no atom is left to paint.
|
|
33
|
+
*/
|
|
34
|
+
export function highlightOverpaint(structure, highlights, color) {
|
|
35
|
+
const { atoms, bonds } = highlightedParts(highlights, (atom) => unitOf(structure, atom) !== undefined);
|
|
36
|
+
if (atoms.length === 0)
|
|
37
|
+
return { kind: 'bond-loci', layers: [] };
|
|
38
|
+
const layers = [
|
|
39
|
+
{ loci: atomsLoci(structure, atoms), color, clear: false },
|
|
40
|
+
{ loci: leavingBondsLoci(structure, atoms), color, clear: true },
|
|
41
|
+
];
|
|
42
|
+
if (bonds.length > 0) {
|
|
43
|
+
layers.push({ loci: pathBondsLoci(structure, bonds), color, clear: false });
|
|
44
|
+
}
|
|
45
|
+
// Not `element-loci`, which molstar would remap layer by layer as atoms, and
|
|
46
|
+
// a bond loci read as atoms is a crash.
|
|
47
|
+
return { kind: 'bond-loci', layers };
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Keeps one representation of the state tree painted with the highlights a
|
|
51
|
+
* site asks for: the one there now, and every one built under the same ref
|
|
52
|
+
* afterwards, so a restyled model or a new conformer comes up already painted.
|
|
53
|
+
*/
|
|
54
|
+
export class HighlightPainter {
|
|
55
|
+
#plugin;
|
|
56
|
+
#ref;
|
|
57
|
+
#unsubscribe;
|
|
58
|
+
#highlights = [];
|
|
59
|
+
#color;
|
|
60
|
+
/**
|
|
61
|
+
* Start following the representation at `representationRef`.
|
|
62
|
+
* @param plugin - The molstar context.
|
|
63
|
+
* @param representationRef - State-tree ref of the representation to paint.
|
|
64
|
+
*/
|
|
65
|
+
constructor(plugin, representationRef) {
|
|
66
|
+
this.#plugin = plugin;
|
|
67
|
+
this.#ref = representationRef;
|
|
68
|
+
const repaint = (event) => {
|
|
69
|
+
if (event.ref === this.#ref)
|
|
70
|
+
this.#paint(event.obj);
|
|
71
|
+
};
|
|
72
|
+
const { created, updated } = plugin.state.data.events.object;
|
|
73
|
+
const subscriptions = [
|
|
74
|
+
created.subscribe(repaint),
|
|
75
|
+
updated.subscribe(repaint),
|
|
76
|
+
];
|
|
77
|
+
this.#unsubscribe = () => {
|
|
78
|
+
for (const subscription of subscriptions)
|
|
79
|
+
subscription.unsubscribe();
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Paint exactly these highlights, in place of the ones painted.
|
|
84
|
+
* @param highlights - The paths; an empty list restores the plain model.
|
|
85
|
+
* @param color - What they are painted in.
|
|
86
|
+
*/
|
|
87
|
+
set(highlights, color) {
|
|
88
|
+
if (color === this.#color && sameHighlights(highlights, this.#highlights)) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
this.#highlights = highlights;
|
|
92
|
+
this.#color = color;
|
|
93
|
+
this.#paint(this.#plugin.state.data.cells.get(this.#ref)?.obj);
|
|
94
|
+
}
|
|
95
|
+
/** Stop following the representation. */
|
|
96
|
+
dispose() {
|
|
97
|
+
this.#unsubscribe();
|
|
98
|
+
}
|
|
99
|
+
#paint(object) {
|
|
100
|
+
if (!PluginStateObject.Molecule.Structure.Representation3D.is(object)) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const { repr, sourceData } = object.data;
|
|
104
|
+
const color = this.#color;
|
|
105
|
+
const overpaint = color === undefined
|
|
106
|
+
? Overpaint.Empty
|
|
107
|
+
: highlightOverpaint(sourceData, this.#highlights, color);
|
|
108
|
+
if (Overpaint.isEmpty(overpaint) &&
|
|
109
|
+
Overpaint.isEmpty(repr.state.overpaint)) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
repr.setState({ overpaint });
|
|
113
|
+
// No commit: the scene keeps its bounds, so the camera is never reframed.
|
|
114
|
+
this.#plugin.canvas3d?.update(repr, true);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function unitOf(structure, atom) {
|
|
118
|
+
const unit = structure.units[atom.unit];
|
|
119
|
+
if (unit === undefined || atom.element >= unit.elements.length) {
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
return unit;
|
|
123
|
+
}
|
|
124
|
+
function atomsLoci(structure, atoms) {
|
|
125
|
+
const elements = [];
|
|
126
|
+
for (let index = 0; index < structure.units.length; index++) {
|
|
127
|
+
const unit = structure.units[index];
|
|
128
|
+
const indices = [];
|
|
129
|
+
for (const atom of atoms) {
|
|
130
|
+
if (atom.unit === index)
|
|
131
|
+
indices.push(atom.element);
|
|
132
|
+
}
|
|
133
|
+
if (unit === undefined || indices.length === 0)
|
|
134
|
+
continue;
|
|
135
|
+
const sorted = SortedArray.ofUnsortedArray(indices);
|
|
136
|
+
elements.push({ unit, indices: OrderedSet.ofSortedArray(sorted) });
|
|
137
|
+
}
|
|
138
|
+
return elementLoci(structure, elements);
|
|
139
|
+
}
|
|
140
|
+
// Every half-bond leaving the atoms, which an element loci paints as well.
|
|
141
|
+
function leavingBondsLoci(structure, atoms) {
|
|
142
|
+
const locations = [];
|
|
143
|
+
const iterator = new Bond.ElementBondIterator();
|
|
144
|
+
for (const atom of atoms) {
|
|
145
|
+
const unit = unitOf(structure, atom);
|
|
146
|
+
if (unit === undefined || !Unit.isAtomic(unit))
|
|
147
|
+
continue;
|
|
148
|
+
const index = atom.element;
|
|
149
|
+
iterator.setElement(structure, unit, index);
|
|
150
|
+
while (iterator.hasNext) {
|
|
151
|
+
const { otherUnit, otherIndex } = iterator.move();
|
|
152
|
+
locations.push(bondLocation(structure, unit, index, structure, otherUnit, otherIndex));
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return bondLoci(structure, locations);
|
|
156
|
+
}
|
|
157
|
+
// molstar draws a bond as two halves, one from each atom.
|
|
158
|
+
function pathBondsLoci(structure, bonds) {
|
|
159
|
+
const locations = [];
|
|
160
|
+
for (const [first, second] of bonds) {
|
|
161
|
+
const forward = halfBond(structure, first, second);
|
|
162
|
+
const backward = halfBond(structure, second, first);
|
|
163
|
+
if (forward !== undefined && backward !== undefined) {
|
|
164
|
+
locations.push(forward, backward);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return bondLoci(structure, locations);
|
|
168
|
+
}
|
|
169
|
+
function halfBond(structure, from, to) {
|
|
170
|
+
const fromUnit = unitOf(structure, from);
|
|
171
|
+
const toUnit = unitOf(structure, to);
|
|
172
|
+
if (fromUnit === undefined || toUnit === undefined)
|
|
173
|
+
return undefined;
|
|
174
|
+
const fromIndex = from.element;
|
|
175
|
+
const toIndex = to.element;
|
|
176
|
+
return bondLocation(structure, fromUnit, fromIndex, structure, toUnit, toIndex);
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=highlights.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"highlights.js","sourceRoot":"","sources":["../../../src/molstar/core/highlights.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAGtE,OAAO,EACL,IAAI,EACJ,gBAAgB,EAChB,IAAI,GACL,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAE5E,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAO/D,OAAO,EACL,gBAAgB,EAChB,cAAc,GACf,MAAM,oCAAoC,CAAC;AAG5C,oDAAoD;AACpD,MAAM,WAAW,GAAG,gBAAgB,CAAC,IAAI,CAAC;AAC1C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC;AAC3B,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC;AAKnC;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAChC,SAAoB,EACpB,UAA0C,EAC1C,KAAY;IAEZ,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,gBAAgB,CACvC,UAAU,EACV,CAAC,IAAI,EAAE,EAAE,CA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AK,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,QAAQ,CAAC,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;QACnD,MAAM,QAAQ,GAAG,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QACpD,IAAI,OAAO,KAAK,SAAS,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YACpD,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;AACxC,CAAC;AAED,SAAS,QAAQ,CACf,SAAoB,EACpB,IAAmB,EACnB,EAAiB;IAEjB,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IACzC,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IACrC,IAAI,QAAQ,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACrE,MAAM,SAAS,GAAG,IAAI,CAAC,OAAoB,CAAC;IAC5C,MAAM,OAAO,GAAG,EAAE,CAAC,OAAoB,CAAC;IACxC,OAAO,YAAY,CACjB,SAAS,EACT,QAAQ,EACR,SAAS,EACT,SAAS,EACT,MAAM,EACN,OAAO,CACR,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The molstar layer under the 3D views: the plugin lifecycle, the camera, the
|
|
3
|
-
* hover labels, the measurements and the picture of a scene.
|
|
3
|
+
* hover labels, the measurements, the highlights and the picture of a scene.
|
|
4
4
|
*
|
|
5
5
|
* Three of our sites mount a headless molstar canvas — the molecule viewer
|
|
6
6
|
* here, lcao's orbitals and symmetry's crystals — and each of them had its own
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
export type { CameraPose, CameraReference, PoseOptions } from './cameraPose.ts';
|
|
18
18
|
export { cameraToPose, poseToCamera } from './cameraPose.ts';
|
|
19
19
|
export { DEFAULT_CAMERA_DURATION, DEFAULT_SPIN_SPEED, FRAMING_MARGIN, MINIMUM_FRAMING_RADIUS, framedRadius, setSpin, } from './camera.ts';
|
|
20
|
+
export { HighlightPainter, highlightOverpaint } from './highlights.ts';
|
|
20
21
|
export { atomName, atomText, lociText, subscribeHover } from './hover.ts';
|
|
21
22
|
export type { MolstarPluginOptions } from './plugin.ts';
|
|
22
23
|
export { MolstarPlugin } from './plugin.ts';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/molstar/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,cAAc,EACd,sBAAsB,EACtB,YAAY,EACZ,OAAO,GACR,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC1E,YAAY,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,YAAY,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/molstar/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,YAAY,EAAE,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