Skip to content
Snippets Groups Projects
Commit 0bb37670 authored by Alexander Rose's avatar Alexander Rose
Browse files

fix ellipsoid repr and support includeParent

- switch off adjustCylinderLength
- handle structure with child
parent eca7da2c
Branches
No related tags found
No related merge requests found
...@@ -27,3 +27,4 @@ ...@@ -27,3 +27,4 @@
* DNA (5D3G) * DNA (5D3G)
* Multiple models with different sets of ligands or missing ligands (1J6T, 1VRC, 2ICY, 1O2F) * Multiple models with different sets of ligands or missing ligands (1J6T, 1VRC, 2ICY, 1O2F)
* Long linear sugar chain (4HG6) * Long linear sugar chain (4HG6)
* Anisotropic B-factors/Ellipsoids (1EJG)
...@@ -26,7 +26,6 @@ export const EllipsoidParams = { ...@@ -26,7 +26,6 @@ export const EllipsoidParams = {
...IntraUnitBondCylinderParams, ...IntraUnitBondCylinderParams,
...InterUnitBondCylinderParams, ...InterUnitBondCylinderParams,
adjustCylinderLength: PD.Boolean(false, { isHidden: true }), // not useful here adjustCylinderLength: PD.Boolean(false, { isHidden: true }), // not useful here
includeParent: PD.Boolean(false, { isHidden: true }), // not yet supported here
unitKinds: getUnitKindsParam(['atomic']), unitKinds: getUnitKindsParam(['atomic']),
sizeFactor: PD.Numeric(1, { min: 0.01, max: 10, step: 0.01 }), sizeFactor: PD.Numeric(1, { min: 0.01, max: 10, step: 0.01 }),
sizeAspectRatio: PD.Numeric(0.1, { min: 0.01, max: 3, step: 0.01 }), sizeAspectRatio: PD.Numeric(0.1, { min: 0.01, max: 3, step: 0.01 }),
...@@ -52,5 +51,11 @@ export const EllipsoidRepresentationProvider = StructureRepresentationProvider({ ...@@ -52,5 +51,11 @@ export const EllipsoidRepresentationProvider = StructureRepresentationProvider({
defaultValues: PD.getDefaultValues(EllipsoidParams), defaultValues: PD.getDefaultValues(EllipsoidParams),
defaultColorTheme: { name: 'element-symbol' }, defaultColorTheme: { name: 'element-symbol' },
defaultSizeTheme: { name: 'uniform' }, defaultSizeTheme: { name: 'uniform' },
isApplicable: (structure: Structure) => structure.elementCount > 0 && structure.models.some(m => AtomSiteAnisotrop.Provider.isApplicable(m)) isApplicable: (structure: Structure) => structure.elementCount > 0 && structure.models.some(m => AtomSiteAnisotrop.Provider.isApplicable(m)),
getData: (structure: Structure, props: PD.Values<EllipsoidParams>) => {
return props.includeParent ? Structure.WithChild.fromStructure(structure) : structure;
},
mustRecreate: (oldProps: PD.Values<EllipsoidParams>, newProps: PD.Values<EllipsoidParams>) => {
return oldProps.includeParent !== newProps.includeParent;
}
}); });
\ No newline at end of file
/** /**
* Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info. * Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
* *
* @author Alexander Rose <alexander.rose@weirdbyte.de> * @author Alexander Rose <alexander.rose@weirdbyte.de>
*/ */
...@@ -22,6 +22,7 @@ import { equalEps } from '../../../mol-math/linear-algebra/3d/common'; ...@@ -22,6 +22,7 @@ import { equalEps } from '../../../mol-math/linear-algebra/3d/common';
import { addSphere } from '../../../mol-geo/geometry/mesh/builder/sphere'; import { addSphere } from '../../../mol-geo/geometry/mesh/builder/sphere';
import { Sphere3D } from '../../../mol-math/geometry'; import { Sphere3D } from '../../../mol-math/geometry';
import { BaseGeometry } from '../../../mol-geo/geometry/base'; import { BaseGeometry } from '../../../mol-geo/geometry/base';
import { SortedArray } from '../../../mol-data/int/sorted-array';
export const EllipsoidMeshParams = { export const EllipsoidMeshParams = {
...UnitsMeshParams, ...UnitsMeshParams,
...@@ -57,7 +58,11 @@ export interface EllipsoidMeshProps { ...@@ -57,7 +58,11 @@ export interface EllipsoidMeshProps {
} }
export function createEllipsoidMesh(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: EllipsoidMeshProps, mesh?: Mesh): Mesh { export function createEllipsoidMesh(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: EllipsoidMeshProps, mesh?: Mesh): Mesh {
const { detail, sizeFactor } = props; const child = Structure.WithChild.getChild(structure);
const childUnit = child?.unitMap.get(unit.id);
if (child && !childUnit) return Mesh.createEmpty(mesh);
const { detail, sizeFactor, ignoreHydrogens } = props;
const { elements, model } = unit; const { elements, model } = unit;
const { atomicNumber } = unit.model.atomicHierarchy.derived.atom; const { atomicNumber } = unit.model.atomicHierarchy.derived.atom;
...@@ -84,7 +89,8 @@ export function createEllipsoidMesh(ctx: VisualContext, unit: Unit, structure: S ...@@ -84,7 +89,8 @@ export function createEllipsoidMesh(ctx: VisualContext, unit: Unit, structure: S
const ei = elements[i]; const ei = elements[i];
const ai = elementToAnsiotrop[ei]; const ai = elementToAnsiotrop[ei];
if (ai === -1) continue; if (ai === -1) continue;
if (props.ignoreHydrogens && isH(atomicNumber, ei)) continue; if (((!!childUnit && !SortedArray.has(childUnit.elements, ei))) ||
(ignoreHydrogens && isH(atomicNumber, ei))) continue;
l.element = ei; l.element = ei;
pos(ei, v); pos(ei, v);
...@@ -111,7 +117,7 @@ export function createEllipsoidMesh(ctx: VisualContext, unit: Unit, structure: S ...@@ -111,7 +117,7 @@ export function createEllipsoidMesh(ctx: VisualContext, unit: Unit, structure: S
const m = MeshBuilder.getMesh(builderState); const m = MeshBuilder.getMesh(builderState);
const sphere = Sphere3D.expand(Sphere3D(), unit.boundary.sphere, 1 * sizeFactor); const sphere = Sphere3D.expand(Sphere3D(), (childUnit || unit).boundary.sphere, 1 * sizeFactor);
m.setBoundingSphere(sphere); m.setBoundingSphere(sphere);
return m; return m;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment