Ver Fonte

wip, representation props

Alexander Rose há 6 anos atrás
pai
commit
fd6b900abf

+ 1 - 2
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 => {

+ 3 - 1
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)
             })

+ 4 - 2
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)

+ 3 - 1
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)

+ 3 - 1
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)

+ 3 - 1
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)
             })

+ 1 - 1
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) => {

+ 3 - 1
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) => {

+ 1 - 3
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) {

+ 4 - 2
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
+        }
     })
 }
 

+ 4 - 2
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
+        }
     })
 }
 

+ 4 - 2
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
+        }
     })
 }

+ 4 - 2
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
+        }
     })
 }