From fd6b900abff9739450494bc9aad437f955878d42 Mon Sep 17 00:00:00 2001 From: Alexander Rose <alex.rose@rcsb.org> Date: Wed, 5 Sep 2018 17:10:13 -0700 Subject: [PATCH] wip, representation props --- .../representation/structure/complex-representation.ts | 3 +-- .../representation/structure/representation/backbone.ts | 4 +++- .../structure/representation/ball-and-stick.ts | 6 ++++-- .../representation/structure/representation/carbohydrate.ts | 4 +++- .../representation/structure/representation/cartoon.ts | 4 +++- .../structure/representation/distance-restraint.ts | 4 +++- .../representation/structure/representation/point.ts | 2 +- .../representation/structure/representation/spacefill.ts | 4 +++- .../representation/structure/units-representation.ts | 4 +--- .../structure/visual/carbohydrate-symbol-mesh.ts | 6 ++++-- .../structure/visual/intra-unit-link-cylinder.ts | 6 ++++-- .../structure/visual/polymer-backbone-cylinder.ts | 6 ++++-- .../representation/structure/visual/polymer-gap-cylinder.ts | 6 ++++-- 13 files changed, 38 insertions(+), 21 deletions(-) diff --git a/src/mol-geo/representation/structure/complex-representation.ts b/src/mol-geo/representation/structure/complex-representation.ts index 32d4816bf..3e4b42416 100644 --- a/src/mol-geo/representation/structure/complex-representation.ts +++ b/src/mol-geo/representation/structure/complex-representation.ts @@ -10,7 +10,6 @@ import { Task } from 'mol-task' import { PickingId } from '../../util/picking'; import { Loci, EmptyLoci } from 'mol-model/loci'; import { MarkerAction } from '../../util/marker-data'; -import { getQualityProps } from '../util'; import { StructureProps, StructureRepresentation } from '.'; import { ComplexVisual } from './complex-visual'; @@ -19,7 +18,7 @@ export function ComplexRepresentation<P extends StructureProps>(label: string, v let _props: P function createOrUpdate(props: Partial<P> = {}, structure?: Structure) { - _props = Object.assign({}, _props, props, getQualityProps(props, structure)) + _props = Object.assign({}, _props, props) if (structure) _props.colorTheme.structure = structure return Task.create('Creating StructureRepresentation', async ctx => { diff --git a/src/mol-geo/representation/structure/representation/backbone.ts b/src/mol-geo/representation/structure/representation/backbone.ts index cb6c6f9d5..6cd7425a2 100644 --- a/src/mol-geo/representation/structure/representation/backbone.ts +++ b/src/mol-geo/representation/structure/representation/backbone.ts @@ -11,6 +11,7 @@ import { Task } from 'mol-task'; import { Loci } from 'mol-model/loci'; import { MarkerAction } from '../../../util/marker-data'; import { PolymerBackboneVisual, DefaultPolymerBackboneProps } from '../visual/polymer-backbone-cylinder'; +import { getQualityProps } from '../../util'; export const DefaultBackboneProps = { ...DefaultPolymerBackboneProps @@ -32,7 +33,8 @@ export function BackboneRepresentation(): BackboneRepresentation { return { ...traceRepr.props } }, createOrUpdate: (props: Partial<BackboneProps> = {}, structure?: Structure) => { - currentProps = Object.assign({}, DefaultBackboneProps, props) + const qualityProps = getQualityProps(Object.assign({}, currentProps, props), structure) + currentProps = Object.assign({}, DefaultBackboneProps, currentProps, props, qualityProps) return Task.create('BackboneRepresentation', async ctx => { await traceRepr.createOrUpdate(currentProps, structure).runInContext(ctx) }) 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 2c4bbceca..e465f7ff4 100644 --- a/src/mol-geo/representation/structure/representation/ball-and-stick.ts +++ b/src/mol-geo/representation/structure/representation/ball-and-stick.ts @@ -14,6 +14,7 @@ import { Loci, isEmptyLoci } from 'mol-model/loci'; import { MarkerAction } from '../../../util/marker-data'; import { InterUnitLinkVisual } from '../visual/inter-unit-link-cylinder'; import { SizeThemeProps } from 'mol-view/theme/size'; +import { getQualityProps } from '../../util'; export const DefaultBallAndStickProps = { ...DefaultElementSphereProps, @@ -41,8 +42,9 @@ export function BallAndStickRepresentation(): BallAndStickRepresentation { return { ...elmementRepr.props, ...intraLinkRepr.props, ...interLinkRepr.props } }, createOrUpdate: (props: Partial<BallAndStickProps> = {}, structure?: Structure) => { - currentProps = Object.assign({}, DefaultBallAndStickProps, props) - return Task.create('DistanceRestraintRepresentation', async ctx => { + const qualityProps = getQualityProps(Object.assign({}, currentProps, props), structure) + currentProps = Object.assign({}, DefaultBallAndStickProps, currentProps, props, qualityProps) + return Task.create('BallAndStickRepresentation', async ctx => { await elmementRepr.createOrUpdate(currentProps, structure).runInContext(ctx) await intraLinkRepr.createOrUpdate(currentProps, structure).runInContext(ctx) await interLinkRepr.createOrUpdate(currentProps, structure).runInContext(ctx) diff --git a/src/mol-geo/representation/structure/representation/carbohydrate.ts b/src/mol-geo/representation/structure/representation/carbohydrate.ts index 1c5dc2922..cf39824fb 100644 --- a/src/mol-geo/representation/structure/representation/carbohydrate.ts +++ b/src/mol-geo/representation/structure/representation/carbohydrate.ts @@ -13,6 +13,7 @@ import { MarkerAction } from '../../../util/marker-data'; import { CarbohydrateSymbolVisual, DefaultCarbohydrateSymbolProps } from '../visual/carbohydrate-symbol-mesh'; import { CarbohydrateLinkVisual, DefaultCarbohydrateLinkProps } from '../visual/carbohydrate-link-cylinder'; import { SizeThemeProps } from 'mol-view/theme/size'; +import { getQualityProps } from '../../util'; export const DefaultCartoonProps = { ...DefaultCarbohydrateSymbolProps, @@ -38,7 +39,8 @@ export function CarbohydrateRepresentation(): CarbohydrateRepresentation { return { ...carbohydrateSymbolRepr.props, ...carbohydrateLinkRepr.props } }, createOrUpdate: (props: Partial<CarbohydrateProps> = {}, structure?: Structure) => { - currentProps = Object.assign({}, DefaultCartoonProps, props) + const qualityProps = getQualityProps(Object.assign({}, currentProps, props), structure) + currentProps = Object.assign({}, DefaultCartoonProps, currentProps, props, qualityProps) return Task.create('Creating CarbohydrateRepresentation', async ctx => { await carbohydrateSymbolRepr.createOrUpdate(currentProps, structure).runInContext(ctx) await carbohydrateLinkRepr.createOrUpdate(currentProps, structure).runInContext(ctx) diff --git a/src/mol-geo/representation/structure/representation/cartoon.ts b/src/mol-geo/representation/structure/representation/cartoon.ts index 9f503a092..7e42ec115 100644 --- a/src/mol-geo/representation/structure/representation/cartoon.ts +++ b/src/mol-geo/representation/structure/representation/cartoon.ts @@ -14,6 +14,7 @@ import { PolymerTraceVisual, DefaultPolymerTraceProps } from '../visual/polymer- import { PolymerGapVisual, DefaultPolymerGapProps } from '../visual/polymer-gap-cylinder'; import { NucleotideBlockVisual, DefaultNucleotideBlockProps } from '../visual/nucleotide-block-mesh'; import { SizeThemeProps } from 'mol-view/theme/size'; +import { getQualityProps } from '../../util'; // import { PolymerDirectionVisual, DefaultPolymerDirectionProps } from '../visual/polymer-direction-wedge'; export const DefaultCartoonProps = { @@ -46,7 +47,8 @@ export function CartoonRepresentation(): CartoonRepresentation { return { ...traceRepr.props, ...gapRepr.props, ...blockRepr.props } }, createOrUpdate: (props: Partial<CartoonProps> = {}, structure?: Structure) => { - currentProps = Object.assign({}, DefaultCartoonProps, props) + const qualityProps = getQualityProps(Object.assign({}, currentProps, props), structure) + currentProps = Object.assign({}, DefaultCartoonProps, currentProps, props, qualityProps) return Task.create('Creating CartoonRepresentation', async ctx => { await traceRepr.createOrUpdate(currentProps, structure).runInContext(ctx) await gapRepr.createOrUpdate(currentProps, structure).runInContext(ctx) diff --git a/src/mol-geo/representation/structure/representation/distance-restraint.ts b/src/mol-geo/representation/structure/representation/distance-restraint.ts index 2c61a224e..0a2d9c289 100644 --- a/src/mol-geo/representation/structure/representation/distance-restraint.ts +++ b/src/mol-geo/representation/structure/representation/distance-restraint.ts @@ -12,6 +12,7 @@ import { Loci } from 'mol-model/loci'; import { MarkerAction } from '../../../util/marker-data'; import { CrossLinkRestraintVisual, DefaultCrossLinkRestraintProps } from '../visual/cross-link-restraint-cylinder'; import { SizeThemeProps } from 'mol-view/theme/size'; +import { getQualityProps } from '../../util'; export const DefaultDistanceRestraintProps = { ...DefaultCrossLinkRestraintProps, @@ -34,7 +35,8 @@ export function DistanceRestraintRepresentation(): DistanceRestraintRepresentati return { ...crossLinkRepr.props } }, createOrUpdate: (props: Partial<DistanceRestraintProps> = {}, structure?: Structure) => { - currentProps = Object.assign({}, DefaultDistanceRestraintProps, props) + const qualityProps = getQualityProps(Object.assign({}, currentProps, props), structure) + currentProps = Object.assign({}, DefaultDistanceRestraintProps, currentProps, props, qualityProps) return Task.create('DistanceRestraintRepresentation', async ctx => { await crossLinkRepr.createOrUpdate(currentProps, structure).runInContext(ctx) }) diff --git a/src/mol-geo/representation/structure/representation/point.ts b/src/mol-geo/representation/structure/representation/point.ts index d9a2de382..5c45a6ca1 100644 --- a/src/mol-geo/representation/structure/representation/point.ts +++ b/src/mol-geo/representation/structure/representation/point.ts @@ -31,7 +31,7 @@ export function PointRepresentation(): PointRepresentation { return { ...pointRepr.props } }, createOrUpdate: (props: Partial<PointProps> = {}, structure?: Structure) => { - currentProps = Object.assign({}, DefaultPointProps, props) + currentProps = Object.assign({}, DefaultPointProps, currentProps, props) return pointRepr.createOrUpdate(currentProps, structure) }, getLoci: (pickingId: PickingId) => { diff --git a/src/mol-geo/representation/structure/representation/spacefill.ts b/src/mol-geo/representation/structure/representation/spacefill.ts index 355334932..ee18231d9 100644 --- a/src/mol-geo/representation/structure/representation/spacefill.ts +++ b/src/mol-geo/representation/structure/representation/spacefill.ts @@ -11,6 +11,7 @@ import { Structure } from 'mol-model/structure'; import { PickingId } from '../../../util/picking'; import { MarkerAction } from '../../../util/marker-data'; import { Loci } from 'mol-model/loci'; +import { getQualityProps } from '../../util'; export const DefaultSpacefillProps = { ...DefaultElementSphereProps @@ -31,7 +32,8 @@ export function SpacefillRepresentation(): SpacefillRepresentation { return { ...sphereRepr.props } }, createOrUpdate: (props: Partial<SpacefillProps> = {}, structure?: Structure) => { - currentProps = Object.assign({}, DefaultSpacefillProps, props) + const qualityProps = getQualityProps(Object.assign({}, currentProps, props), structure) + currentProps = Object.assign({}, DefaultSpacefillProps, currentProps, props, qualityProps) return sphereRepr.createOrUpdate(currentProps, structure) }, getLoci: (pickingId: PickingId) => { diff --git a/src/mol-geo/representation/structure/units-representation.ts b/src/mol-geo/representation/structure/units-representation.ts index d88f68cb0..766845896 100644 --- a/src/mol-geo/representation/structure/units-representation.ts +++ b/src/mol-geo/representation/structure/units-representation.ts @@ -12,7 +12,6 @@ import { Representation, RepresentationProps, Visual } from '..'; import { PickingId } from '../../util/picking'; import { Loci, EmptyLoci, isEmptyLoci } from 'mol-model/loci'; import { MarkerAction } from '../../util/marker-data'; -import { getQualityProps } from '../util'; import { StructureProps } from '.'; import { StructureGroup } from './units-visual'; @@ -29,8 +28,7 @@ export function UnitsRepresentation<P extends StructureProps>(label: string, vis let _groups: ReadonlyArray<Unit.SymmetryGroup> function createOrUpdate(props: Partial<P> = {}, structure?: Structure) { - console.log(props) - _props = Object.assign({}, _props, props, getQualityProps(props, structure)) + _props = Object.assign({}, _props, props) return Task.create('Creating or updating StructureRepresentation', async ctx => { if (!_structure && !structure) { 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 50b85fb4d..309319c00 100644 --- a/src/mol-geo/representation/structure/visual/carbohydrate-symbol-mesh.ts +++ b/src/mol-geo/representation/structure/visual/carbohydrate-symbol-mesh.ts @@ -5,7 +5,7 @@ */ import { Unit, Structure, StructureElement } from 'mol-model/structure'; -import { ComplexVisual } from '..'; +import { ComplexVisual, MeshUpdateState } from '..'; import { RuntimeContext } from 'mol-task' import { Mesh } from '../../../mesh/mesh'; import { PickingId } from '../../../util/picking'; @@ -154,7 +154,9 @@ export function CarbohydrateSymbolVisual(): ComplexVisual<CarbohydrateSymbolProp createLocationIterator: CarbohydrateElementIterator, getLoci: getCarbohydrateLoci, mark: markCarbohydrate, - setUpdateState: () => {} + setUpdateState: (state: MeshUpdateState, newProps: CarbohydrateSymbolProps, currentProps: CarbohydrateSymbolProps) => { + state.createMesh = newProps.detail !== currentProps.detail + } }) } 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 f5934887e..66c2817fd 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 @@ -6,7 +6,7 @@ */ import { Unit, Link, StructureElement } from 'mol-model/structure'; -import { UnitsVisual } from '..'; +import { UnitsVisual, MeshUpdateState } from '..'; import { RuntimeContext } from 'mol-task' import { DefaultLinkCylinderProps, LinkCylinderProps, createLinkCylinderMesh, LinkIterator } from './util/link'; import { Mesh } from '../../../mesh/mesh'; @@ -77,7 +77,9 @@ export function IntraUnitLinkVisual(): UnitsVisual<IntraUnitLinkProps> { createLocationIterator: LinkIterator.fromGroup, getLoci: getLinkLoci, mark: markLink, - setUpdateState: () => {} + setUpdateState: (state: MeshUpdateState, newProps: LinkCylinderProps, currentProps: LinkCylinderProps) => { + state.createMesh = newProps.radialSegments !== currentProps.radialSegments + } }) } 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 8c848a8cb..fb3521a29 100644 --- a/src/mol-geo/representation/structure/visual/polymer-backbone-cylinder.ts +++ b/src/mol-geo/representation/structure/visual/polymer-backbone-cylinder.ts @@ -5,7 +5,7 @@ */ import { Unit } from 'mol-model/structure'; -import { UnitsVisual } from '..'; +import { UnitsVisual, MeshUpdateState } from '..'; import { RuntimeContext } from 'mol-task' import { Mesh } from '../../../mesh/mesh'; import { MeshBuilder } from '../../../mesh/mesh-builder'; @@ -77,6 +77,8 @@ export function PolymerBackboneVisual(): UnitsVisual<PolymerBackboneProps> { createLocationIterator: StructureElementIterator.fromGroup, getLoci: getElementLoci, mark: markElement, - setUpdateState: () => {} + setUpdateState: (state: MeshUpdateState, newProps: PolymerBackboneProps, currentProps: PolymerBackboneProps) => { + state.createMesh = newProps.radialSegments !== currentProps.radialSegments + } }) } \ No newline at end of file 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 05a945cba..3c7afa802 100644 --- a/src/mol-geo/representation/structure/visual/polymer-gap-cylinder.ts +++ b/src/mol-geo/representation/structure/visual/polymer-gap-cylinder.ts @@ -5,7 +5,7 @@ */ import { Unit } from 'mol-model/structure'; -import { UnitsVisual } from '..'; +import { UnitsVisual, MeshUpdateState } from '..'; import { RuntimeContext } from 'mol-task' import { Mesh } from '../../../mesh/mesh'; import { MeshBuilder } from '../../../mesh/mesh-builder'; @@ -85,6 +85,8 @@ export function PolymerGapVisual(): UnitsVisual<PolymerGapProps> { createLocationIterator: PolymerGapLocationIterator.fromGroup, getLoci: getElementLoci, mark: markElement, - setUpdateState: () => {} + setUpdateState: (state: MeshUpdateState, newProps: PolymerGapProps, currentProps: PolymerGapProps) => { + state.createMesh = newProps.radialSegments !== currentProps.radialSegments + } }) } \ No newline at end of file -- GitLab