react-cheminfo 0.139.0 → 0.140.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/credits/core/credits.d.ts +12 -0
- package/lib/credits/core/credits.d.ts.map +1 -1
- package/lib/credits/core/credits.js +16 -0
- package/lib/credits/core/credits.js.map +1 -1
- package/lib/crystal3d/ui/CrystalCanvas3D.d.ts +1 -1
- package/lib/crystal3d/ui/CrystalCanvas3D.d.ts.map +1 -1
- package/lib/crystal3d/ui/CrystalViewer3D.d.ts +1 -1
- package/lib/crystal3d/ui/CrystalViewer3D.d.ts.map +1 -1
- package/lib/crystal3d/ui/crystalStructureViewerProps.d.ts +1 -1
- package/lib/crystal3d/ui/crystalStructureViewerProps.d.ts.map +1 -1
- package/lib/download/ui/FigureDownloadPanel.d.ts +17 -3
- package/lib/download/ui/FigureDownloadPanel.d.ts.map +1 -1
- package/lib/download/ui/FigureDownloadPanel.js +1 -1
- package/lib/download/ui/FigureDownloadPanel.js.map +1 -1
- package/lib/download/ui/FigureQuickActions.d.ts +10 -4
- package/lib/download/ui/FigureQuickActions.d.ts.map +1 -1
- package/lib/download/ui/FigureQuickActions.js +12 -6
- package/lib/download/ui/FigureQuickActions.js.map +1 -1
- package/lib/ecosystem/core/home.d.ts +19 -0
- package/lib/ecosystem/core/home.d.ts.map +1 -0
- package/lib/ecosystem/core/home.js +23 -0
- package/lib/ecosystem/core/home.js.map +1 -0
- package/lib/ecosystem/core/index.d.ts +3 -0
- package/lib/ecosystem/core/index.d.ts.map +1 -1
- package/lib/ecosystem/core/index.js +2 -0
- package/lib/ecosystem/core/index.js.map +1 -1
- package/lib/ecosystem/core/searchSites.d.ts +39 -0
- package/lib/ecosystem/core/searchSites.d.ts.map +1 -0
- package/lib/ecosystem/core/searchSites.js +77 -0
- package/lib/ecosystem/core/searchSites.js.map +1 -0
- package/lib/ecosystem/core/types.d.ts +1 -1
- package/lib/ecosystem/core/types.d.ts.map +1 -1
- package/lib/ecosystem/core/unlistedSites.d.ts.map +1 -1
- package/lib/ecosystem/core/unlistedSites.js +14 -0
- package/lib/ecosystem/core/unlistedSites.js.map +1 -1
- package/lib/ecosystem/ui/EcosystemButton.d.ts +6 -0
- package/lib/ecosystem/ui/EcosystemButton.d.ts.map +1 -1
- package/lib/ecosystem/ui/EcosystemButton.js +2 -2
- package/lib/ecosystem/ui/EcosystemButton.js.map +1 -1
- package/lib/ecosystem/ui/EcosystemMenu.d.ts +13 -4
- package/lib/ecosystem/ui/EcosystemMenu.d.ts.map +1 -1
- package/lib/ecosystem/ui/EcosystemMenu.js +56 -6
- package/lib/ecosystem/ui/EcosystemMenu.js.map +1 -1
- package/lib/ecosystem/ui/SiteGroupGrid.d.ts +12 -0
- package/lib/ecosystem/ui/SiteGroupGrid.d.ts.map +1 -1
- package/lib/ecosystem/ui/SiteGroupGrid.js +15 -2
- package/lib/ecosystem/ui/SiteGroupGrid.js.map +1 -1
- package/lib/ecosystem/ui/glyphs.d.ts.map +1 -1
- package/lib/ecosystem/ui/glyphs.js +4 -0
- package/lib/ecosystem/ui/glyphs.js.map +1 -1
- package/lib/i18n/core/chromeCatalog.d.ts +1 -1
- package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
- package/lib/locales/de.json +10 -0
- package/lib/locales/en.json +10 -0
- package/lib/locales/es.json +10 -0
- package/lib/locales/fr.json +10 -0
- package/lib/locales/it.json +10 -0
- package/lib/molecule3d/core/bondNeighbours.d.ts +30 -0
- package/lib/molecule3d/core/bondNeighbours.d.ts.map +1 -0
- package/lib/molecule3d/core/bondNeighbours.js +108 -0
- package/lib/molecule3d/core/bondNeighbours.js.map +1 -0
- package/lib/molecule3d/core/file.d.ts +15 -4
- package/lib/molecule3d/core/file.d.ts.map +1 -1
- package/lib/molecule3d/core/file.js +10 -1
- package/lib/molecule3d/core/file.js.map +1 -1
- package/lib/molecule3d/core/index.d.ts +11 -2
- package/lib/molecule3d/core/index.d.ts.map +1 -1
- package/lib/molecule3d/core/index.js +6 -1
- package/lib/molecule3d/core/index.js.map +1 -1
- package/lib/molecule3d/core/partialBondMode.d.ts +34 -0
- package/lib/molecule3d/core/partialBondMode.d.ts.map +1 -0
- package/lib/molecule3d/core/partialBondMode.js +39 -0
- package/lib/molecule3d/core/partialBondMode.js.map +1 -0
- package/lib/molecule3d/core/partialBondRanges.d.ts +61 -0
- package/lib/molecule3d/core/partialBondRanges.d.ts.map +1 -0
- package/lib/molecule3d/core/partialBondRanges.js +89 -0
- package/lib/molecule3d/core/partialBondRanges.js.map +1 -0
- package/lib/molecule3d/core/partialBonds.d.ts +61 -0
- package/lib/molecule3d/core/partialBonds.d.ts.map +1 -0
- package/lib/molecule3d/core/partialBonds.js +115 -0
- package/lib/molecule3d/core/partialBonds.js.map +1 -0
- package/lib/molecule3d/core/settings.d.ts +13 -35
- package/lib/molecule3d/core/settings.d.ts.map +1 -1
- package/lib/molecule3d/core/settings.js +17 -25
- package/lib/molecule3d/core/settings.js.map +1 -1
- package/lib/molecule3d/core/tools.d.ts +36 -0
- package/lib/molecule3d/core/tools.d.ts.map +1 -0
- package/lib/molecule3d/core/tools.js +24 -0
- package/lib/molecule3d/core/tools.js.map +1 -0
- package/lib/molecule3d/ui/Molecule3DExport.d.ts.map +1 -1
- package/lib/molecule3d/ui/Molecule3DExport.js +19 -2
- package/lib/molecule3d/ui/Molecule3DExport.js.map +1 -1
- package/lib/molecule3d/ui/Molecule3DOptions.d.ts +5 -2
- package/lib/molecule3d/ui/Molecule3DOptions.d.ts.map +1 -1
- package/lib/molecule3d/ui/Molecule3DOptions.js +6 -4
- package/lib/molecule3d/ui/Molecule3DOptions.js.map +1 -1
- package/lib/molecule3d/ui/Molecule3DPartialBonds.d.ts +22 -0
- package/lib/molecule3d/ui/Molecule3DPartialBonds.d.ts.map +1 -0
- package/lib/molecule3d/ui/Molecule3DPartialBonds.js +53 -0
- package/lib/molecule3d/ui/Molecule3DPartialBonds.js.map +1 -0
- package/lib/molecule3d/ui/Molecule3DToolbar.d.ts +1 -1
- package/lib/molecule3d/ui/Molecule3DToolbar.d.ts.map +1 -1
- package/lib/molecule3d/ui/Molecule3DToolbar.js +1 -1
- package/lib/molecule3d/ui/Molecule3DToolbar.js.map +1 -1
- package/lib/molecule3d/ui/MoleculeCanvas3D.d.ts.map +1 -1
- package/lib/molecule3d/ui/MoleculeCanvas3D.js +3 -2
- package/lib/molecule3d/ui/MoleculeCanvas3D.js.map +1 -1
- package/lib/molecule3d/ui/drawScene.d.ts +4 -3
- package/lib/molecule3d/ui/drawScene.d.ts.map +1 -1
- package/lib/molecule3d/ui/drawScene.js +12 -2
- package/lib/molecule3d/ui/drawScene.js.map +1 -1
- package/lib/molecule3d/ui/moleculeFileFormats.d.ts +3 -2
- package/lib/molecule3d/ui/moleculeFileFormats.d.ts.map +1 -1
- package/lib/molecule3d/ui/moleculeFileFormats.js +5 -3
- package/lib/molecule3d/ui/moleculeFileFormats.js.map +1 -1
- package/lib/molecule3d/ui/moleculeViewer3DProps.d.ts +2 -1
- package/lib/molecule3d/ui/moleculeViewer3DProps.d.ts.map +1 -1
- package/lib/molecule3d/ui/partialBondShapes.d.ts +117 -0
- package/lib/molecule3d/ui/partialBondShapes.d.ts.map +1 -0
- package/lib/molecule3d/ui/partialBondShapes.js +164 -0
- package/lib/molecule3d/ui/partialBondShapes.js.map +1 -0
- package/lib/molecule3d/ui/renderMolecule.d.ts +9 -0
- package/lib/molecule3d/ui/renderMolecule.d.ts.map +1 -1
- package/lib/molecule3d/ui/renderMolecule.js +17 -0
- package/lib/molecule3d/ui/renderMolecule.js.map +1 -1
- package/lib/molecule3d/ui/renderPartialBonds.d.ts +19 -0
- package/lib/molecule3d/ui/renderPartialBonds.d.ts.map +1 -0
- package/lib/molecule3d/ui/renderPartialBonds.js +90 -0
- package/lib/molecule3d/ui/renderPartialBonds.js.map +1 -0
- package/lib/molecule3d/ui/structureGeometry.d.ts +22 -0
- package/lib/molecule3d/ui/structureGeometry.d.ts.map +1 -0
- package/lib/molecule3d/ui/structureGeometry.js +63 -0
- package/lib/molecule3d/ui/structureGeometry.js.map +1 -0
- package/lib/molecule3d/ui/usePolarSurfaceArea.d.ts +2 -2
- package/lib/molecule3d/ui/usePolarSurfaceArea.d.ts.map +1 -1
- package/lib/molecule3d/ui/usePolarSurfaceArea.js +5 -4
- package/lib/molecule3d/ui/usePolarSurfaceArea.js.map +1 -1
- package/lib/molecule3d/ui/viewer.d.ts +8 -1
- package/lib/molecule3d/ui/viewer.d.ts.map +1 -1
- package/lib/molecule3d/ui/viewer.js +10 -0
- package/lib/molecule3d/ui/viewer.js.map +1 -1
- package/lib/molecule3d/ui/viewerTypes.d.ts +18 -0
- package/lib/molecule3d/ui/viewerTypes.d.ts.map +1 -1
- package/lib/panel/ui/FilterInput.d.ts +11 -0
- package/lib/panel/ui/FilterInput.d.ts.map +1 -1
- package/lib/panel/ui/FilterInput.js +10 -1
- package/lib/panel/ui/FilterInput.js.map +1 -1
- package/lib/shell/ui/ShellFrame.d.ts.map +1 -1
- package/lib/shell/ui/ShellFrame.js +3 -2
- package/lib/shell/ui/ShellFrame.js.map +1 -1
- package/package.json +1 -1
- package/src/credits/core/credits.ts +16 -0
- package/src/crystal3d/ui/CrystalCanvas3D.tsx +1 -1
- package/src/crystal3d/ui/CrystalViewer3D.tsx +1 -1
- package/src/crystal3d/ui/crystalStructureViewerProps.ts +1 -1
- package/src/download/ui/FigureDownloadPanel.tsx +20 -4
- package/src/download/ui/FigureQuickActions.tsx +18 -6
- package/src/ecosystem/core/home.ts +27 -0
- package/src/ecosystem/core/index.ts +7 -0
- package/src/ecosystem/core/searchSites.ts +102 -0
- package/src/ecosystem/core/types.ts +1 -0
- package/src/ecosystem/core/unlistedSites.ts +15 -0
- package/src/ecosystem/ui/EcosystemButton.tsx +8 -2
- package/src/ecosystem/ui/EcosystemMenu.tsx +103 -7
- package/src/ecosystem/ui/SiteGroupGrid.tsx +28 -3
- package/src/ecosystem/ui/glyphs.tsx +14 -0
- package/src/locales/de.json +10 -0
- package/src/locales/en.json +10 -0
- package/src/locales/es.json +10 -0
- package/src/locales/fr.json +10 -0
- package/src/locales/it.json +10 -0
- package/src/molecule3d/core/bondNeighbours.ts +108 -0
- package/src/molecule3d/core/file.ts +18 -4
- package/src/molecule3d/core/index.ts +17 -3
- package/src/molecule3d/core/partialBondMode.ts +48 -0
- package/src/molecule3d/core/partialBondRanges.ts +120 -0
- package/src/molecule3d/core/partialBonds.ts +180 -0
- package/src/molecule3d/core/settings.ts +29 -52
- package/src/molecule3d/core/tools.ts +51 -0
- package/src/molecule3d/ui/Molecule3DExport.tsx +17 -2
- package/src/molecule3d/ui/Molecule3DOptions.tsx +16 -3
- package/src/molecule3d/ui/Molecule3DPartialBonds.tsx +100 -0
- package/src/molecule3d/ui/Molecule3DToolbar.tsx +2 -2
- package/src/molecule3d/ui/MoleculeCanvas3D.tsx +3 -4
- package/src/molecule3d/ui/drawScene.ts +15 -2
- package/src/molecule3d/ui/moleculeFileFormats.ts +5 -3
- package/src/molecule3d/ui/moleculeViewer3DProps.ts +2 -1
- package/src/molecule3d/ui/partialBondShapes.ts +246 -0
- package/src/molecule3d/ui/renderMolecule.ts +20 -0
- package/src/molecule3d/ui/renderPartialBonds.ts +122 -0
- package/src/molecule3d/ui/structureGeometry.ts +73 -0
- package/src/molecule3d/ui/usePolarSurfaceArea.ts +5 -4
- package/src/molecule3d/ui/viewer.ts +12 -0
- package/src/molecule3d/ui/viewerTypes.ts +19 -0
- package/src/panel/ui/FilterInput.tsx +24 -0
- package/src/shell/ui/ShellFrame.tsx +7 -1
- package/styles/chrome.css +30 -6
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the viewer draws the partial bonds of a molecule, as a setting a site
|
|
3
|
+
* can persist.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { Molecule3DFile } from './file.ts';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* `auto` draws the partial bonds of an XYZ file and not those of a molfile;
|
|
10
|
+
* `on` and `off` draw them, or not, whatever the file.
|
|
11
|
+
*/
|
|
12
|
+
export const PARTIAL_BOND_MODES = ['auto', 'on', 'off'] as const;
|
|
13
|
+
|
|
14
|
+
/** One of {@link PARTIAL_BOND_MODES}. */
|
|
15
|
+
export type PartialBondMode = (typeof PARTIAL_BOND_MODES)[number];
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Narrow an arbitrary value — a stored preference — to a partial bond mode.
|
|
19
|
+
* @param value - Candidate mode.
|
|
20
|
+
* @returns True when it is one of {@link PARTIAL_BOND_MODES}.
|
|
21
|
+
*/
|
|
22
|
+
export function isPartialBondMode(value: unknown): value is PartialBondMode {
|
|
23
|
+
for (const mode of PARTIAL_BOND_MODES) {
|
|
24
|
+
if (mode === value) return true;
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Whether a file's partial bonds are drawn.
|
|
31
|
+
*
|
|
32
|
+
* An XYZ file carries no bonds: they are guessed from the distances, and the
|
|
33
|
+
* guess is what drops the stretched bonds of a transition state, so `auto`
|
|
34
|
+
* draws them. A molfile states its bonds, the forming ones included when its
|
|
35
|
+
* author wanted them, so `auto` adds nothing to it. Nor to a PDB: its bonds
|
|
36
|
+
* are written in `CONECT` records, and where they are not, the file is mostly
|
|
37
|
+
* a measured structure, whose stretched pairs are far likelier two sites of a
|
|
38
|
+
* disorder than a bond being made.
|
|
39
|
+
* @param mode - The setting.
|
|
40
|
+
* @param format - The format of the file on screen.
|
|
41
|
+
* @returns True when the partial bonds are drawn.
|
|
42
|
+
*/
|
|
43
|
+
export function showsPartialBonds(
|
|
44
|
+
mode: PartialBondMode,
|
|
45
|
+
format: Molecule3DFile['format'],
|
|
46
|
+
): boolean {
|
|
47
|
+
return mode === 'auto' ? format === 'xyz' : mode === 'on';
|
|
48
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The distances a partial bond may span, per pair of elements.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/** How far past the bonding limit a partial bond may be. */
|
|
6
|
+
export interface PartialBondReach {
|
|
7
|
+
/** The most a partial bond may be, as a multiple of the bonding limit. */
|
|
8
|
+
readonly stretch: number;
|
|
9
|
+
/** And the most it may exceed the limit by, Å. */
|
|
10
|
+
readonly reach: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The reach of a pair three bonds apart, or holding a hydrogen: 1.4 times the
|
|
15
|
+
* limit, and at most 0.7 Å past it — 2.45 Å for C–C.
|
|
16
|
+
*
|
|
17
|
+
* Three bonds apart, the ends of a ring are already close: 2.59 Å across
|
|
18
|
+
* bicyclo[2.2.2]octane, 2.63 Å across a boat cyclohexane. With a hydrogen, the
|
|
19
|
+
* stretch stops short of a hydrogen bond: O–H is bonded up to 1.1 Å, and
|
|
20
|
+
* O–H···O starts near 1.6 Å. The 0.7 Å holds back the elements whose limit is
|
|
21
|
+
* long already: 1.4 times the 2.48 Å of C–I would reach the carbon three bonds
|
|
22
|
+
* away in a gauche iodoalkane, at 3.4 Å.
|
|
23
|
+
*/
|
|
24
|
+
export const NEAR_PARTIAL_BOND: PartialBondReach = { stretch: 1.4, reach: 0.7 };
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The reach of two heavy atoms further apart, or in separate molecules: 1.5
|
|
28
|
+
* times the limit, and at most 0.85 Å past it — 2.6 Å for C–C, which takes in
|
|
29
|
+
* the forming bonds of the usual transition states, 2.0–2.6 Å, while two
|
|
30
|
+
* molecules merely in contact are 3.2 Å apart or more.
|
|
31
|
+
*/
|
|
32
|
+
export const FAR_PARTIAL_BOND: PartialBondReach = { stretch: 1.5, reach: 0.85 };
|
|
33
|
+
|
|
34
|
+
/** The limits of every pair of elements, row-major over the elements present. */
|
|
35
|
+
export interface PairRanges {
|
|
36
|
+
/** The longest bond, Å; a partial bond is longer. */
|
|
37
|
+
readonly limit: Float64Array;
|
|
38
|
+
/** The longest partial bond three bonds apart, or with a hydrogen, Å. */
|
|
39
|
+
readonly near: Float64Array;
|
|
40
|
+
/** The longest partial bond otherwise, Å. */
|
|
41
|
+
readonly far: Float64Array;
|
|
42
|
+
/** The longest partial bond of all, Å. */
|
|
43
|
+
readonly longest: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The bonding limit and the two partial bond limits of every pair of the
|
|
48
|
+
* elements present, row-major; all 0 for a pair never partially bonded.
|
|
49
|
+
* @param symbols - The elements present.
|
|
50
|
+
* @param bondLimit - The longest bond between two elements, 0 for never.
|
|
51
|
+
* @param nearReach - The reach of a pair three bonds apart, or with a hydrogen.
|
|
52
|
+
* @param farReach - The reach of any other pair.
|
|
53
|
+
* @returns The limits, and the longest partial bond of all.
|
|
54
|
+
*/
|
|
55
|
+
export function pairRanges(
|
|
56
|
+
symbols: readonly string[],
|
|
57
|
+
bondLimit: (a: string, b: string) => number,
|
|
58
|
+
nearReach: PartialBondReach,
|
|
59
|
+
farReach: PartialBondReach,
|
|
60
|
+
): PairRanges {
|
|
61
|
+
const size = symbols.length;
|
|
62
|
+
const limit = new Float64Array(size * size);
|
|
63
|
+
const near = new Float64Array(size * size);
|
|
64
|
+
const far = new Float64Array(size * size);
|
|
65
|
+
let longest = 0;
|
|
66
|
+
for (let a = 0; a < size; a++) {
|
|
67
|
+
for (let b = 0; b < size; b++) {
|
|
68
|
+
const first = symbols[a] ?? '';
|
|
69
|
+
const second = symbols[b] ?? '';
|
|
70
|
+
const bonded = bondLimit(first, second);
|
|
71
|
+
const hydrogens = Number(isHydrogen(first)) + Number(isHydrogen(second));
|
|
72
|
+
if (!(bonded > 0) || hydrogens === 2) continue;
|
|
73
|
+
const cell = a * size + b;
|
|
74
|
+
const nearest = reachOf(bonded, nearReach);
|
|
75
|
+
const farthest =
|
|
76
|
+
hydrogens === 1
|
|
77
|
+
? nearest
|
|
78
|
+
: Math.max(nearest, reachOf(bonded, farReach));
|
|
79
|
+
limit[cell] = bonded;
|
|
80
|
+
near[cell] = nearest;
|
|
81
|
+
far[cell] = farthest;
|
|
82
|
+
longest = Math.max(longest, farthest);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return { limit, near, far, longest };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function reachOf(limit: number, { stretch, reach }: PartialBondReach): number {
|
|
89
|
+
return Math.max(limit, Math.min(limit * stretch, limit + reach));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Hydrogen and its isotopes, written as molstar reads them.
|
|
93
|
+
function isHydrogen(symbol: string): boolean {
|
|
94
|
+
return HYDROGENS.has(symbol.toUpperCase());
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const HYDROGENS: ReadonlySet<string> = new Set(['H', 'D', 'T']);
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* The elements present, and which of them each atom is.
|
|
101
|
+
* @param elements - The element of each atom.
|
|
102
|
+
* @param count - How many atoms are read.
|
|
103
|
+
* @returns The index of each atom's element, and the elements.
|
|
104
|
+
*/
|
|
105
|
+
export function elementKinds(elements: readonly string[], count: number) {
|
|
106
|
+
const indices = new Int32Array(count);
|
|
107
|
+
const symbols: string[] = [];
|
|
108
|
+
const known = new Map<string, number>();
|
|
109
|
+
for (let atom = 0; atom < count; atom++) {
|
|
110
|
+
const element = elements[atom] ?? '';
|
|
111
|
+
let kind = known.get(element);
|
|
112
|
+
if (kind === undefined) {
|
|
113
|
+
kind = symbols.length;
|
|
114
|
+
known.set(element, kind);
|
|
115
|
+
symbols.push(element);
|
|
116
|
+
}
|
|
117
|
+
indices[atom] = kind;
|
|
118
|
+
}
|
|
119
|
+
return { indices, symbols };
|
|
120
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The partial bonds of a geometry: pairs of atoms a little too far apart to be
|
|
3
|
+
* bonded, as the bonds being formed and broken in a transition state are.
|
|
4
|
+
*
|
|
5
|
+
* A viewer that infers bonds from distances drops exactly those, so a
|
|
6
|
+
* transition state loses the feature it is about. A pair is a partial bond
|
|
7
|
+
* when it is longer than the longest bond between its elements, but not by
|
|
8
|
+
* more than its {@link PartialBondReach} allows, and when its two atoms are
|
|
9
|
+
* neither both hydrogens nor within two bonds of each other: a 1,3 pair is the
|
|
10
|
+
* two ends of a bond angle, never a bond. Nor does one pass through a third
|
|
11
|
+
* atom: the oxygens either side of a proton in flight are joined through it.
|
|
12
|
+
*
|
|
13
|
+
* Free of molstar: the bonding rule is handed in, so the viewer passes the one
|
|
14
|
+
* it bonds by and a page listing the partial bonds beside it can do the same.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { BondNeighbours } from './bondNeighbours.ts';
|
|
18
|
+
import type { PartialBondReach } from './partialBondRanges.ts';
|
|
19
|
+
import {
|
|
20
|
+
FAR_PARTIAL_BOND,
|
|
21
|
+
NEAR_PARTIAL_BOND,
|
|
22
|
+
elementKinds,
|
|
23
|
+
pairRanges,
|
|
24
|
+
} from './partialBondRanges.ts';
|
|
25
|
+
|
|
26
|
+
/** The atoms a partial bond is looked for between. */
|
|
27
|
+
export interface PartialBondGeometry {
|
|
28
|
+
/** The element of each atom, e.g. `C`. */
|
|
29
|
+
readonly elements: readonly string[];
|
|
30
|
+
/** Cartesian coordinates, ångström: x, y and z of each atom in turn. */
|
|
31
|
+
readonly coordinates: ArrayLike<number>;
|
|
32
|
+
/** The bonds already drawn, in atom-index pairs: `[a0, b0, a1, b1, …]`. */
|
|
33
|
+
readonly bonds: ArrayLike<number>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Options of {@link findPartialBonds}. */
|
|
37
|
+
export interface PartialBondOptions {
|
|
38
|
+
/**
|
|
39
|
+
* The longest bond between two elements, ångström, and 0 for a pair never
|
|
40
|
+
* bonded: the viewer passes molstar's own, `bondLimit` from
|
|
41
|
+
* `react-cheminfo/molstar/bonds`.
|
|
42
|
+
*/
|
|
43
|
+
readonly bondLimit: (a: string, b: string) => number;
|
|
44
|
+
/**
|
|
45
|
+
* The reach of a pair three bonds apart, or holding a hydrogen.
|
|
46
|
+
* @default NEAR_PARTIAL_BOND
|
|
47
|
+
*/
|
|
48
|
+
readonly near?: PartialBondReach;
|
|
49
|
+
/**
|
|
50
|
+
* The reach of any other pair.
|
|
51
|
+
* @default FAR_PARTIAL_BOND
|
|
52
|
+
*/
|
|
53
|
+
readonly far?: PartialBondReach;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** One partial bond. */
|
|
57
|
+
export interface PartialBond {
|
|
58
|
+
/** One atom, from 0 in the order of the geometry. */
|
|
59
|
+
readonly first: number;
|
|
60
|
+
/** The other, always after `first`. */
|
|
61
|
+
readonly second: number;
|
|
62
|
+
/** Their distance, Å. */
|
|
63
|
+
readonly distance: number;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Every partial bond of a geometry.
|
|
68
|
+
* @param geometry - The atoms and the bonds already drawn between them.
|
|
69
|
+
* @param options - The bonding rule, and how far past it to look.
|
|
70
|
+
* @returns The partial bonds, ordered by `first` then `second`.
|
|
71
|
+
*/
|
|
72
|
+
export function findPartialBonds(
|
|
73
|
+
geometry: PartialBondGeometry,
|
|
74
|
+
options: PartialBondOptions,
|
|
75
|
+
): PartialBond[] {
|
|
76
|
+
const { elements, coordinates, bonds } = geometry;
|
|
77
|
+
const count = Math.min(elements.length, Math.floor(coordinates.length / 3));
|
|
78
|
+
const kinds = elementKinds(elements, count);
|
|
79
|
+
const ranges = pairRanges(
|
|
80
|
+
kinds.symbols,
|
|
81
|
+
options.bondLimit,
|
|
82
|
+
options.near ?? NEAR_PARTIAL_BOND,
|
|
83
|
+
options.far ?? FAR_PARTIAL_BOND,
|
|
84
|
+
);
|
|
85
|
+
const kindCount = kinds.symbols.length;
|
|
86
|
+
const neighbours = new BondNeighbours(count, bonds);
|
|
87
|
+
const order = alongX(coordinates, count);
|
|
88
|
+
const found: PartialBond[] = [];
|
|
89
|
+
|
|
90
|
+
for (let p = 0; p < count; p++) {
|
|
91
|
+
const i = order[p] ?? 0;
|
|
92
|
+
const xi = coordinates[i * 3] ?? 0;
|
|
93
|
+
const yi = coordinates[i * 3 + 1] ?? 0;
|
|
94
|
+
const zi = coordinates[i * 3 + 2] ?? 0;
|
|
95
|
+
const row = (kinds.indices[i] ?? 0) * kindCount;
|
|
96
|
+
for (let q = p + 1; q < count; q++) {
|
|
97
|
+
const j = order[q] ?? 0;
|
|
98
|
+
const dx = (coordinates[j * 3] ?? 0) - xi;
|
|
99
|
+
if (dx > ranges.longest) break;
|
|
100
|
+
const dy = (coordinates[j * 3 + 1] ?? 0) - yi;
|
|
101
|
+
const dz = (coordinates[j * 3 + 2] ?? 0) - zi;
|
|
102
|
+
const squared = dx * dx + dy * dy + dz * dz;
|
|
103
|
+
const pair = row + (kinds.indices[j] ?? 0);
|
|
104
|
+
const lower = ranges.limit[pair] ?? 0;
|
|
105
|
+
const far = ranges.far[pair] ?? 0;
|
|
106
|
+
if (squared <= lower * lower || squared > far * far) continue;
|
|
107
|
+
const separation = neighbours.separation(i, j);
|
|
108
|
+
if (separation < 3) continue;
|
|
109
|
+
const near = ranges.near[pair] ?? 0;
|
|
110
|
+
if (separation === 3 && squared > near * near) continue;
|
|
111
|
+
if (passesThroughAtom(coordinates, count, i, j, squared)) continue;
|
|
112
|
+
found.push({
|
|
113
|
+
first: Math.min(i, j),
|
|
114
|
+
second: Math.max(i, j),
|
|
115
|
+
distance: Math.sqrt(squared),
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return found.toSorted(
|
|
120
|
+
(one, other) => one.first - other.first || one.second - other.second,
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* The atoms in increasing x, so that a pair further apart along x than the
|
|
126
|
+
* longest partial bond ends the search from its first atom.
|
|
127
|
+
* @param coordinates - x, y, z of each atom.
|
|
128
|
+
* @param count - How many atoms.
|
|
129
|
+
* @returns Atom indices.
|
|
130
|
+
*/
|
|
131
|
+
function alongX(coordinates: ArrayLike<number>, count: number): Int32Array {
|
|
132
|
+
const order = new Int32Array(count);
|
|
133
|
+
for (let atom = 0; atom < count; atom++) order[atom] = atom;
|
|
134
|
+
return order.toSorted(
|
|
135
|
+
(a, b) => (coordinates[a * 3] ?? 0) - (coordinates[b * 3] ?? 0),
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Whether a third atom stands between two, nearly on the line joining them:
|
|
141
|
+
* seen from it, the two make an angle of 150° or more.
|
|
142
|
+
* @param coordinates - x, y, z of each atom.
|
|
143
|
+
* @param count - How many atoms.
|
|
144
|
+
* @param i - One end.
|
|
145
|
+
* @param j - The other.
|
|
146
|
+
* @param squared - Their squared distance.
|
|
147
|
+
* @returns True when the line from `i` to `j` passes through an atom.
|
|
148
|
+
*/
|
|
149
|
+
function passesThroughAtom(
|
|
150
|
+
coordinates: ArrayLike<number>,
|
|
151
|
+
count: number,
|
|
152
|
+
i: number,
|
|
153
|
+
j: number,
|
|
154
|
+
squared: number,
|
|
155
|
+
): boolean {
|
|
156
|
+
for (let k = 0; k < count; k++) {
|
|
157
|
+
if (k === i || k === j) continue;
|
|
158
|
+
const toI = squaredDistance(coordinates, k, i);
|
|
159
|
+
const toJ = squaredDistance(coordinates, k, j);
|
|
160
|
+
if (toI >= squared || toJ >= squared) continue;
|
|
161
|
+
// The law of cosines, at k.
|
|
162
|
+
const cosine = (toI + toJ - squared) / (2 * Math.sqrt(toI * toJ));
|
|
163
|
+
if (cosine <= THROUGH_COSINE) return true;
|
|
164
|
+
}
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** cos 150°. */
|
|
169
|
+
const THROUGH_COSINE = -Math.sqrt(3) / 2;
|
|
170
|
+
|
|
171
|
+
function squaredDistance(
|
|
172
|
+
coordinates: ArrayLike<number>,
|
|
173
|
+
a: number,
|
|
174
|
+
b: number,
|
|
175
|
+
): number {
|
|
176
|
+
const dx = (coordinates[a * 3] ?? 0) - (coordinates[b * 3] ?? 0);
|
|
177
|
+
const dy = (coordinates[a * 3 + 1] ?? 0) - (coordinates[b * 3 + 1] ?? 0);
|
|
178
|
+
const dz = (coordinates[a * 3 + 2] ?? 0) - (coordinates[b * 3 + 2] ?? 0);
|
|
179
|
+
return dx * dx + dy * dy + dz * dz;
|
|
180
|
+
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The display settings of the 3D molecule viewer
|
|
3
|
-
*
|
|
2
|
+
* The display settings of the 3D molecule viewer, free of React and molstar so
|
|
3
|
+
* a site can persist and validate them.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import type { PartialBondMode } from './partialBondMode.ts';
|
|
7
|
+
import { isPartialBondMode } from './partialBondMode.ts';
|
|
8
|
+
|
|
6
9
|
/** Ways the model can be drawn, in the order the picker offers them. */
|
|
7
10
|
export const REPRESENTATIONS = [
|
|
8
11
|
'ball-and-stick',
|
|
@@ -51,6 +54,14 @@ export interface Molecule3DSettings {
|
|
|
51
54
|
surfaceColoring: SurfaceColoringId;
|
|
52
55
|
/** Surface colour in `uniform` mode, `#rrggbb`. */
|
|
53
56
|
surfaceColor: string;
|
|
57
|
+
/**
|
|
58
|
+
* Whether the partial bonds are drawn dashed: pairs a little too far apart
|
|
59
|
+
* to be bonded, as the forming and breaking bonds of a transition state.
|
|
60
|
+
* `auto` draws them for an XYZ file, whose bonds are guessed from distances.
|
|
61
|
+
*/
|
|
62
|
+
partialBonds: PartialBondMode;
|
|
63
|
+
/** Whether each partial bond is labelled with its length. */
|
|
64
|
+
partialBondLengths: boolean;
|
|
54
65
|
}
|
|
55
66
|
|
|
56
67
|
/**
|
|
@@ -74,6 +85,8 @@ export const DEFAULT_MOLECULE_3D_SETTINGS: Molecule3DSettings = {
|
|
|
74
85
|
surfaceColoring: 'uniform',
|
|
75
86
|
// A scene colour: WebGL cannot read a CSS custom property.
|
|
76
87
|
surfaceColor: '#94a3b8', // tokens-ok
|
|
88
|
+
partialBonds: 'auto',
|
|
89
|
+
partialBondLengths: true,
|
|
77
90
|
};
|
|
78
91
|
|
|
79
92
|
/** The span, and the slider step, of every numeric setting. */
|
|
@@ -83,42 +96,6 @@ export const MOLECULE_3D_RANGES = {
|
|
|
83
96
|
probeRadius: { minimum: 1, maximum: 3, step: 0.1 },
|
|
84
97
|
} as const;
|
|
85
98
|
|
|
86
|
-
/** Which buttons the toolbar over the canvas shows. */
|
|
87
|
-
export interface Molecule3DTools {
|
|
88
|
-
/** Distance, angle and dihedral tools, and a button removing them all. */
|
|
89
|
-
measure: boolean;
|
|
90
|
-
/** A popover with the representation, the size and the surface sliders. */
|
|
91
|
-
options: boolean;
|
|
92
|
-
/** A toggle turning the model on its own. */
|
|
93
|
-
spin: boolean;
|
|
94
|
-
/** A toggle drawing the molecular surface. */
|
|
95
|
-
surface: boolean;
|
|
96
|
-
/** A button framing the model again. */
|
|
97
|
-
reset: boolean;
|
|
98
|
-
/** A popover saving the picture as a PNG or an SVG. */
|
|
99
|
-
export: boolean;
|
|
100
|
-
/**
|
|
101
|
-
* A toggle filling the screen with the canvas and its toolbars. It is left
|
|
102
|
-
* out where the browser cannot fill the screen, as on an iPhone or in a
|
|
103
|
-
* frame not allowed to.
|
|
104
|
-
*/
|
|
105
|
-
fullscreen: boolean;
|
|
106
|
-
/** A popover listing what the mouse and the keyboard do on the canvas. */
|
|
107
|
-
help: boolean;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/** Every tool on. */
|
|
111
|
-
export const DEFAULT_MOLECULE_3D_TOOLS: Molecule3DTools = {
|
|
112
|
-
measure: true,
|
|
113
|
-
options: true,
|
|
114
|
-
spin: true,
|
|
115
|
-
surface: true,
|
|
116
|
-
reset: true,
|
|
117
|
-
export: true,
|
|
118
|
-
fullscreen: true,
|
|
119
|
-
help: true,
|
|
120
|
-
};
|
|
121
|
-
|
|
122
99
|
/**
|
|
123
100
|
* Narrow an arbitrary string — a stored preference, a picker's value — to a
|
|
124
101
|
* representation.
|
|
@@ -147,8 +124,8 @@ export function isSurfaceColoringId(value: string): value is SurfaceColoringId {
|
|
|
147
124
|
/**
|
|
148
125
|
* Complete and repair settings from any source: missing fields take their
|
|
149
126
|
* default, numbers are clamped into {@link MOLECULE_3D_RANGES}, an unknown
|
|
150
|
-
* representation or
|
|
151
|
-
* is not `#rrggbb` to its default.
|
|
127
|
+
* representation, colouring or partial bond mode falls back to the default
|
|
128
|
+
* one, and a colour that is not `#rrggbb` to its default.
|
|
152
129
|
* @param settings - Whatever a site has, possibly read back from storage.
|
|
153
130
|
* @returns Settings the viewer can draw.
|
|
154
131
|
*/
|
|
@@ -164,6 +141,8 @@ export function normalizeMolecule3DSettings(
|
|
|
164
141
|
probeRadius,
|
|
165
142
|
surfaceColoring,
|
|
166
143
|
surfaceColor,
|
|
144
|
+
partialBonds,
|
|
145
|
+
partialBondLengths,
|
|
167
146
|
} = settings;
|
|
168
147
|
return {
|
|
169
148
|
representation:
|
|
@@ -181,6 +160,13 @@ export function normalizeMolecule3DSettings(
|
|
|
181
160
|
? surfaceColoring
|
|
182
161
|
: defaults.surfaceColoring,
|
|
183
162
|
surfaceColor: hexColor(surfaceColor, defaults.surfaceColor),
|
|
163
|
+
partialBonds: isPartialBondMode(partialBonds)
|
|
164
|
+
? partialBonds
|
|
165
|
+
: defaults.partialBonds,
|
|
166
|
+
partialBondLengths:
|
|
167
|
+
typeof partialBondLengths === 'boolean'
|
|
168
|
+
? partialBondLengths
|
|
169
|
+
: defaults.partialBondLengths,
|
|
184
170
|
};
|
|
185
171
|
}
|
|
186
172
|
|
|
@@ -215,21 +201,12 @@ export function sameMolecule3DSettings(
|
|
|
215
201
|
first.surfaceAlpha === second.surfaceAlpha &&
|
|
216
202
|
first.probeRadius === second.probeRadius &&
|
|
217
203
|
first.surfaceColoring === second.surfaceColoring &&
|
|
218
|
-
first.surfaceColor === second.surfaceColor
|
|
204
|
+
first.surfaceColor === second.surfaceColor &&
|
|
205
|
+
first.partialBonds === second.partialBonds &&
|
|
206
|
+
first.partialBondLengths === second.partialBondLengths
|
|
219
207
|
);
|
|
220
208
|
}
|
|
221
209
|
|
|
222
|
-
/**
|
|
223
|
-
* Complete a partial tool selection.
|
|
224
|
-
* @param tools - The tools a site switched on or off.
|
|
225
|
-
* @returns Every tool, those not named left on.
|
|
226
|
-
*/
|
|
227
|
-
export function resolveMolecule3DTools(
|
|
228
|
-
tools: Partial<Molecule3DTools> = {},
|
|
229
|
-
): Molecule3DTools {
|
|
230
|
-
return { ...DEFAULT_MOLECULE_3D_TOOLS, ...tools };
|
|
231
|
-
}
|
|
232
|
-
|
|
233
210
|
function hexColor(value: string | undefined, fallback: string): string {
|
|
234
211
|
return typeof value === 'string' && /^#[\da-f]{6}$/i.test(value)
|
|
235
212
|
? value.toLowerCase()
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which buttons the toolbar over the 3D molecule canvas shows, free of React
|
|
3
|
+
* and molstar so a site can persist them.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/** Which buttons the toolbar over the canvas shows. */
|
|
7
|
+
export interface Molecule3DTools {
|
|
8
|
+
/** Distance, angle and dihedral tools, and a button removing them all. */
|
|
9
|
+
measure: boolean;
|
|
10
|
+
/** A popover with the representation, the size and the surface sliders. */
|
|
11
|
+
options: boolean;
|
|
12
|
+
/** A toggle turning the model on its own. */
|
|
13
|
+
spin: boolean;
|
|
14
|
+
/** A toggle drawing the molecular surface. */
|
|
15
|
+
surface: boolean;
|
|
16
|
+
/** A button framing the model again. */
|
|
17
|
+
reset: boolean;
|
|
18
|
+
/** A popover saving the picture as a PNG or an SVG. */
|
|
19
|
+
export: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* A toggle filling the screen with the canvas and its toolbars. It is left
|
|
22
|
+
* out where the browser cannot fill the screen, as on an iPhone or in a
|
|
23
|
+
* frame not allowed to.
|
|
24
|
+
*/
|
|
25
|
+
fullscreen: boolean;
|
|
26
|
+
/** A popover listing what the mouse and the keyboard do on the canvas. */
|
|
27
|
+
help: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Every tool on. */
|
|
31
|
+
export const DEFAULT_MOLECULE_3D_TOOLS: Molecule3DTools = {
|
|
32
|
+
measure: true,
|
|
33
|
+
options: true,
|
|
34
|
+
spin: true,
|
|
35
|
+
surface: true,
|
|
36
|
+
reset: true,
|
|
37
|
+
export: true,
|
|
38
|
+
fullscreen: true,
|
|
39
|
+
help: true,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Complete a partial tool selection.
|
|
44
|
+
* @param tools - The tools a site switched on or off.
|
|
45
|
+
* @returns Every tool, those not named left on.
|
|
46
|
+
*/
|
|
47
|
+
export function resolveMolecule3DTools(
|
|
48
|
+
tools: Partial<Molecule3DTools> = {},
|
|
49
|
+
): Molecule3DTools {
|
|
50
|
+
return { ...DEFAULT_MOLECULE_3D_TOOLS, ...tools };
|
|
51
|
+
}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import type { ReactElement } from 'react';
|
|
8
8
|
import { useCallback, useState } from 'react';
|
|
9
9
|
|
|
10
|
+
import { writeToClipboard } from '../../clipboard/core/writeToClipboard.ts';
|
|
10
11
|
import type { FigureNotice } from '../../download/core/copyFigure.ts';
|
|
11
12
|
import type { FigureFormat } from '../../download/core/downloadFigure.ts';
|
|
12
13
|
import {
|
|
@@ -99,7 +100,8 @@ export function Molecule3DExport(props: Molecule3DExportProps): ReactElement {
|
|
|
99
100
|
const versions = moleculeFileChoices(atoms, t);
|
|
100
101
|
const writtenVersion = versions[0]?.disabled ? 'molfileV3000' : version;
|
|
101
102
|
|
|
102
|
-
// Written once picked
|
|
103
|
+
// Written once picked rather than on the press: Safari only allows a
|
|
104
|
+
// clipboard write the click itself started, and Save has it at hand too.
|
|
103
105
|
const written = useAsync(
|
|
104
106
|
useCallback(
|
|
105
107
|
() =>
|
|
@@ -110,6 +112,12 @@ export function Molecule3DExport(props: Molecule3DExportProps): ReactElement {
|
|
|
110
112
|
),
|
|
111
113
|
);
|
|
112
114
|
const text = written.pending ? null : written.data;
|
|
115
|
+
const versionLabel = writtenVersion === 'molfileV3000' ? 'V3000' : 'V2000';
|
|
116
|
+
|
|
117
|
+
async function copyMolfile(molfileText: string): Promise<FigureNotice> {
|
|
118
|
+
if (await writeToClipboard(molfileText)) return 'copied';
|
|
119
|
+
throw new Error(t('clipboard.failed'));
|
|
120
|
+
}
|
|
113
121
|
|
|
114
122
|
// What the last copy came to only describes the choices it was made with.
|
|
115
123
|
function changed<T>(apply: (value: T) => void): (value: T) => void {
|
|
@@ -134,6 +142,12 @@ export function Molecule3DExport(props: Molecule3DExportProps): ReactElement {
|
|
|
134
142
|
value: file,
|
|
135
143
|
onChange: changed(setFile),
|
|
136
144
|
hint: t('molecule3d.molfileHint', { count: atoms }),
|
|
145
|
+
copy: {
|
|
146
|
+
ready: t('molecule3d.copyMolfile', { version: versionLabel }),
|
|
147
|
+
copied: t('molecule3d.copiedMolfile', {
|
|
148
|
+
version: versionLabel,
|
|
149
|
+
}),
|
|
150
|
+
},
|
|
137
151
|
}
|
|
138
152
|
: undefined
|
|
139
153
|
}
|
|
@@ -155,7 +169,8 @@ export function Molecule3DExport(props: Molecule3DExportProps): ReactElement {
|
|
|
155
169
|
}
|
|
156
170
|
}}
|
|
157
171
|
onCopy={() => {
|
|
158
|
-
run(onCopy(scale));
|
|
172
|
+
if (file === null) run(onCopy(scale));
|
|
173
|
+
else if (text) run(copyMolfile(text));
|
|
159
174
|
}}
|
|
160
175
|
onSend={
|
|
161
176
|
writeFile === undefined
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The display options of the molecule viewer, shown in the toolbar's popover:
|
|
3
|
-
* the representation, the size, and the surface's opacity,
|
|
4
|
-
* colours, with a button returning them all to the defaults.
|
|
3
|
+
* the representation, the size, the partial bonds, and the surface's opacity,
|
|
4
|
+
* solvent probe and colours, with a button returning them all to the defaults.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { Button, SegmentedControl, Slider } from '@blueprintjs/core';
|
|
@@ -9,6 +9,7 @@ import type { CSSProperties, ReactElement } from 'react';
|
|
|
9
9
|
|
|
10
10
|
import { formatDecimal } from '../../format/core/numbers.ts';
|
|
11
11
|
import { useChromeT } from '../../i18n/ui/useT.ts';
|
|
12
|
+
import type { Molecule3DFile } from '../core/file.ts';
|
|
12
13
|
import type { Molecule3DSettings } from '../core/settings.ts';
|
|
13
14
|
import {
|
|
14
15
|
MOLECULE_3D_RANGES,
|
|
@@ -19,6 +20,7 @@ import {
|
|
|
19
20
|
sameMolecule3DSettings,
|
|
20
21
|
} from '../core/settings.ts';
|
|
21
22
|
|
|
23
|
+
import { Molecule3DPartialBonds } from './Molecule3DPartialBonds.tsx';
|
|
22
24
|
import { Molecule3DSurfaceColors } from './Molecule3DSurfaceColors.tsx';
|
|
23
25
|
|
|
24
26
|
/** Props of {@link Molecule3DOptions}. */
|
|
@@ -29,6 +31,8 @@ export interface Molecule3DOptionsProps {
|
|
|
29
31
|
polarSurfaceArea: number | null;
|
|
30
32
|
/** What the reset button returns to; `showSurface` is left as it is. */
|
|
31
33
|
defaults: Molecule3DSettings;
|
|
34
|
+
/** The format of the file on screen, which decides the partial bonds' `auto`. */
|
|
35
|
+
format: Molecule3DFile['format'];
|
|
32
36
|
}
|
|
33
37
|
|
|
34
38
|
/**
|
|
@@ -37,7 +41,7 @@ export interface Molecule3DOptionsProps {
|
|
|
37
41
|
* @returns The panel.
|
|
38
42
|
*/
|
|
39
43
|
export function Molecule3DOptions(props: Molecule3DOptionsProps): ReactElement {
|
|
40
|
-
const { settings, onChange, polarSurfaceArea, defaults } = props;
|
|
44
|
+
const { settings, onChange, polarSurfaceArea, defaults, format } = props;
|
|
41
45
|
const t = useChromeT();
|
|
42
46
|
const reset = resetMolecule3DSettings(settings, defaults);
|
|
43
47
|
const atDefaults = sameMolecule3DSettings(settings, reset);
|
|
@@ -73,6 +77,13 @@ export function Molecule3DOptions(props: Molecule3DOptionsProps): ReactElement {
|
|
|
73
77
|
onChange({ ...settings, sizeFactor });
|
|
74
78
|
}}
|
|
75
79
|
/>
|
|
80
|
+
<div style={FULL_ROW_STYLE}>
|
|
81
|
+
<Molecule3DPartialBonds
|
|
82
|
+
settings={settings}
|
|
83
|
+
onChange={onChange}
|
|
84
|
+
format={format}
|
|
85
|
+
/>
|
|
86
|
+
</div>
|
|
76
87
|
{settings.showSurface ? null : (
|
|
77
88
|
<span style={SURFACE_OFF_STYLE} data-testid="molecule3d-surface-off">
|
|
78
89
|
{t('molecule3d.surfaceOff')}
|
|
@@ -194,6 +205,8 @@ const GRID_STYLE: CSSProperties = {
|
|
|
194
205
|
|
|
195
206
|
const LABEL_STYLE: CSSProperties = { fontSize: 12 };
|
|
196
207
|
|
|
208
|
+
const FULL_ROW_STYLE: CSSProperties = { gridColumn: '1 / -1' };
|
|
209
|
+
|
|
197
210
|
/** Spans the grid, between the size and the surface rows it explains. */
|
|
198
211
|
const SURFACE_OFF_STYLE: CSSProperties = {
|
|
199
212
|
display: 'flex',
|