From 4b36683e490038589442b83e272c627703292a4d Mon Sep 17 00:00:00 2001 From: Alexander Rose <alex.rose@rcsb.org> Date: Tue, 4 Sep 2018 15:12:20 -0700 Subject: [PATCH] added label propertiy to representation interface --- src/mol-geo/representation/index.ts | 1 + src/mol-geo/representation/shape/index.ts | 1 + .../structure/complex-representation.ts | 3 ++- .../structure/representation/backbone.ts | 3 ++- .../structure/representation/ball-and-stick.ts | 9 +++++---- .../structure/representation/carbohydrate.ts | 10 +++++++--- .../structure/representation/cartoon.ts | 16 ++++++++++------ .../representation/distance-restraint.ts | 3 ++- .../structure/representation/point.ts | 5 ++++- .../structure/representation/spacefill.ts | 2 +- .../structure/visual/element-point.ts | 1 + .../structure/visual/inter-unit-link-cylinder.ts | 1 + .../structure/visual/intra-unit-link-cylinder.ts | 1 + src/mol-geo/representation/util.ts | 2 +- src/mol-geo/representation/volume/index.ts | 1 + 15 files changed, 40 insertions(+), 19 deletions(-) diff --git a/src/mol-geo/representation/index.ts b/src/mol-geo/representation/index.ts index f1d635551..90ac94490 100644 --- a/src/mol-geo/representation/index.ts +++ b/src/mol-geo/representation/index.ts @@ -13,6 +13,7 @@ import { MarkerAction } from '../util/marker-data'; export interface RepresentationProps {} export interface Representation<D, P extends RepresentationProps = {}> { + readonly label: string readonly renderObjects: ReadonlyArray<RenderObject> readonly props: Readonly<P> createOrUpdate: (props?: Partial<P>, data?: D) => Task<void> diff --git a/src/mol-geo/representation/shape/index.ts b/src/mol-geo/representation/shape/index.ts index 3f5c40876..52ee7ebc4 100644 --- a/src/mol-geo/representation/shape/index.ts +++ b/src/mol-geo/representation/shape/index.ts @@ -73,6 +73,7 @@ export function ShapeRepresentation<P extends ShapeProps>(): ShapeRepresentation } return { + label: 'Shape mesh', get renderObjects () { return renderObjects }, get props () { return _props }, createOrUpdate, diff --git a/src/mol-geo/representation/structure/complex-representation.ts b/src/mol-geo/representation/structure/complex-representation.ts index ed9a0b1f3..6053df8f3 100644 --- a/src/mol-geo/representation/structure/complex-representation.ts +++ b/src/mol-geo/representation/structure/complex-representation.ts @@ -14,7 +14,7 @@ import { getQualityProps } from '../util'; import { StructureProps, DefaultStructureProps, StructureRepresentation } from '.'; import { ComplexVisual } from './complex-visual'; -export function ComplexRepresentation<P extends StructureProps>(visualCtor: () => ComplexVisual<P>): StructureRepresentation<P> { +export function ComplexRepresentation<P extends StructureProps>(label: string, visualCtor: () => ComplexVisual<P>): StructureRepresentation<P> { let visual: ComplexVisual<P> | undefined let _props: P @@ -41,6 +41,7 @@ export function ComplexRepresentation<P extends StructureProps>(visualCtor: () = } return { + label, get renderObjects() { return visual && visual.renderObject ? [ visual.renderObject ] : [] }, diff --git a/src/mol-geo/representation/structure/representation/backbone.ts b/src/mol-geo/representation/structure/representation/backbone.ts index a76e239a5..cb6c6f9d5 100644 --- a/src/mol-geo/representation/structure/representation/backbone.ts +++ b/src/mol-geo/representation/structure/representation/backbone.ts @@ -20,10 +20,11 @@ export type BackboneProps = typeof DefaultBackboneProps export type BackboneRepresentation = StructureRepresentation<BackboneProps> export function BackboneRepresentation(): BackboneRepresentation { - const traceRepr = UnitsRepresentation(PolymerBackboneVisual) + const traceRepr = UnitsRepresentation('Polymer backbone cylinder', PolymerBackboneVisual) let currentProps: BackboneProps return { + label: 'Backbone', get renderObjects() { return [ ...traceRepr.renderObjects ] }, 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 3c236ede1..2c4bbceca 100644 --- a/src/mol-geo/representation/structure/representation/ball-and-stick.ts +++ b/src/mol-geo/representation/structure/representation/ball-and-stick.ts @@ -19,7 +19,7 @@ export const DefaultBallAndStickProps = { ...DefaultElementSphereProps, ...DefaultIntraUnitLinkProps, - sizeTheme: { name: 'uniform', value: 0.25 } as SizeThemeProps, + sizeTheme: { name: 'uniform', value: 0.2 } as SizeThemeProps, unitKinds: [ Unit.Kind.Atomic ] as Unit.Kind[] } export type BallAndStickProps = typeof DefaultBallAndStickProps @@ -27,12 +27,13 @@ export type BallAndStickProps = typeof DefaultBallAndStickProps export type BallAndStickRepresentation = StructureRepresentation<BallAndStickProps> export function BallAndStickRepresentation(): BallAndStickRepresentation { - const elmementRepr = UnitsRepresentation(ElementSphereVisual) - const intraLinkRepr = UnitsRepresentation(IntraUnitLinkVisual) - const interLinkRepr = ComplexRepresentation(InterUnitLinkVisual) + const elmementRepr = UnitsRepresentation('Element sphere mesh', ElementSphereVisual) + const intraLinkRepr = UnitsRepresentation('Intra-unit link cylinder', IntraUnitLinkVisual) + const interLinkRepr = ComplexRepresentation('Inter-unit link cylinder', InterUnitLinkVisual) let currentProps: BallAndStickProps return { + label: 'Ball & Stick', get renderObjects() { return [ ...elmementRepr.renderObjects, ...intraLinkRepr.renderObjects, ...interLinkRepr.renderObjects ] }, diff --git a/src/mol-geo/representation/structure/representation/carbohydrate.ts b/src/mol-geo/representation/structure/representation/carbohydrate.ts index 6a01069b4..1c5dc2922 100644 --- a/src/mol-geo/representation/structure/representation/carbohydrate.ts +++ b/src/mol-geo/representation/structure/representation/carbohydrate.ts @@ -12,21 +12,25 @@ import { Loci, isEmptyLoci } from 'mol-model/loci'; 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'; export const DefaultCartoonProps = { ...DefaultCarbohydrateSymbolProps, - ...DefaultCarbohydrateLinkProps + ...DefaultCarbohydrateLinkProps, + + sizeTheme: { name: 'uniform', value: 1, factor: 1 } as SizeThemeProps, } export type CarbohydrateProps = typeof DefaultCartoonProps export type CarbohydrateRepresentation = StructureRepresentation<CarbohydrateProps> export function CarbohydrateRepresentation(): CarbohydrateRepresentation { - const carbohydrateSymbolRepr = ComplexRepresentation(CarbohydrateSymbolVisual) - const carbohydrateLinkRepr = ComplexRepresentation(CarbohydrateLinkVisual) + const carbohydrateSymbolRepr = ComplexRepresentation('Carbohydrate symbol mesh', CarbohydrateSymbolVisual) + const carbohydrateLinkRepr = ComplexRepresentation('Carbohydrate link cylinder', CarbohydrateLinkVisual) let currentProps: CarbohydrateProps return { + label: 'Carbohydrate', get renderObjects() { return [ ...carbohydrateSymbolRepr.renderObjects, ...carbohydrateLinkRepr.renderObjects ] }, diff --git a/src/mol-geo/representation/structure/representation/cartoon.ts b/src/mol-geo/representation/structure/representation/cartoon.ts index ca40d4ee8..9f503a092 100644 --- a/src/mol-geo/representation/structure/representation/cartoon.ts +++ b/src/mol-geo/representation/structure/representation/cartoon.ts @@ -13,26 +13,30 @@ import { MarkerAction } from '../../../util/marker-data'; import { PolymerTraceVisual, DefaultPolymerTraceProps } from '../visual/polymer-trace-mesh'; import { PolymerGapVisual, DefaultPolymerGapProps } from '../visual/polymer-gap-cylinder'; import { NucleotideBlockVisual, DefaultNucleotideBlockProps } from '../visual/nucleotide-block-mesh'; -import { /* PolymerDirectionVisual, */ DefaultPolymerDirectionProps } from '../visual/polymer-direction-wedge'; +import { SizeThemeProps } from 'mol-view/theme/size'; +// import { PolymerDirectionVisual, DefaultPolymerDirectionProps } from '../visual/polymer-direction-wedge'; export const DefaultCartoonProps = { ...DefaultPolymerTraceProps, ...DefaultPolymerGapProps, ...DefaultNucleotideBlockProps, - ...DefaultPolymerDirectionProps + // ...DefaultPolymerDirectionProps, + + sizeTheme: { name: 'uniform', value: 0.2 } as SizeThemeProps, } export type CartoonProps = typeof DefaultCartoonProps export type CartoonRepresentation = StructureRepresentation<CartoonProps> export function CartoonRepresentation(): CartoonRepresentation { - const traceRepr = UnitsRepresentation(PolymerTraceVisual) - const gapRepr = UnitsRepresentation(PolymerGapVisual) - const blockRepr = UnitsRepresentation(NucleotideBlockVisual) - // const directionRepr = UnitsRepresentation(PolymerDirectionVisual) + const traceRepr = UnitsRepresentation('Polymer trace mesh', PolymerTraceVisual) + const gapRepr = UnitsRepresentation('Polymer gap cylinder', PolymerGapVisual) + const blockRepr = UnitsRepresentation('Nucleotide block mesh', NucleotideBlockVisual) + // const directionRepr = UnitsRepresentation('Polymer direction wedge', PolymerDirectionVisual) let currentProps: CartoonProps return { + label: 'Cartoon', get renderObjects() { return [ ...traceRepr.renderObjects, ...gapRepr.renderObjects, ...blockRepr.renderObjects // , ...directionRepr.renderObjects diff --git a/src/mol-geo/representation/structure/representation/distance-restraint.ts b/src/mol-geo/representation/structure/representation/distance-restraint.ts index 47a340e9a..2c61a224e 100644 --- a/src/mol-geo/representation/structure/representation/distance-restraint.ts +++ b/src/mol-geo/representation/structure/representation/distance-restraint.ts @@ -22,10 +22,11 @@ export type DistanceRestraintProps = typeof DefaultDistanceRestraintProps export type DistanceRestraintRepresentation = StructureRepresentation<DistanceRestraintProps> export function DistanceRestraintRepresentation(): DistanceRestraintRepresentation { - const crossLinkRepr = ComplexRepresentation(CrossLinkRestraintVisual) + const crossLinkRepr = ComplexRepresentation('Cross-link restraint', CrossLinkRestraintVisual) let currentProps: DistanceRestraintProps return { + label: 'Distance restraint', get renderObjects() { return [ ...crossLinkRepr.renderObjects ] }, diff --git a/src/mol-geo/representation/structure/representation/point.ts b/src/mol-geo/representation/structure/representation/point.ts index 6ea64af0e..892ffa0c2 100644 --- a/src/mol-geo/representation/structure/representation/point.ts +++ b/src/mol-geo/representation/structure/representation/point.ts @@ -7,14 +7,17 @@ import { UnitsRepresentation } from '..'; import { ElementPointVisual, DefaultElementPointProps } from '../visual/element-point'; import { StructureRepresentation } from '../units-representation'; +import { SizeThemeProps } from 'mol-view/theme/size'; export const DefaultPointProps = { ...DefaultElementPointProps, + + sizeTheme: { name: 'uniform', value: 0.2 } as SizeThemeProps, } export type PointProps = typeof DefaultPointProps export type PointRepresentation = StructureRepresentation<PointProps> export function PointRepresentation(): PointRepresentation { - return UnitsRepresentation(ElementPointVisual) + return UnitsRepresentation('Point', ElementPointVisual) } \ No newline at end of file diff --git a/src/mol-geo/representation/structure/representation/spacefill.ts b/src/mol-geo/representation/structure/representation/spacefill.ts index fb18a901a..ede5bb1b7 100644 --- a/src/mol-geo/representation/structure/representation/spacefill.ts +++ b/src/mol-geo/representation/structure/representation/spacefill.ts @@ -16,5 +16,5 @@ export type SpacefillProps = typeof DefaultSpacefillProps export type SpacefillRepresentation = StructureRepresentation<SpacefillProps> export function SpacefillRepresentation(): SpacefillRepresentation { - return UnitsRepresentation(ElementSphereVisual) + return UnitsRepresentation('Spacefill', ElementSphereVisual) } \ No newline at end of file diff --git a/src/mol-geo/representation/structure/visual/element-point.ts b/src/mol-geo/representation/structure/visual/element-point.ts index b244c830c..549ff4aab 100644 --- a/src/mol-geo/representation/structure/visual/element-point.ts +++ b/src/mol-geo/representation/structure/visual/element-point.ts @@ -75,6 +75,7 @@ export function ElementPointVisual(): UnitsVisual<ElementPointProps> { vertices = await createElementPointVertices(ctx, unit, vertices) renderObject = await createUnitsPointRenderObject(ctx, group, vertices, locationIt, currentProps) + console.log(renderObject) } else if (renderObject) { if (group) currentGroup = group diff --git a/src/mol-geo/representation/structure/visual/inter-unit-link-cylinder.ts b/src/mol-geo/representation/structure/visual/inter-unit-link-cylinder.ts index 813da2a3b..44469dacf 100644 --- a/src/mol-geo/representation/structure/visual/inter-unit-link-cylinder.ts +++ b/src/mol-geo/representation/structure/visual/inter-unit-link-cylinder.ts @@ -51,6 +51,7 @@ async function createInterUnitLinkCylinderMesh(ctx: RuntimeContext, structure: S export const DefaultInterUnitLinkProps = { ...DefaultComplexMeshProps, ...DefaultLinkCylinderProps, + sizeTheme: { name: 'physical', factor: 0.3 } as SizeThemeProps, } export type InterUnitLinkProps = typeof DefaultInterUnitLinkProps 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 bf3e964bc..f5934887e 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 @@ -65,6 +65,7 @@ async function createIntraUnitLinkCylinderMesh(ctx: RuntimeContext, unit: Unit, export const DefaultIntraUnitLinkProps = { ...DefaultUnitsMeshProps, ...DefaultLinkCylinderProps, + sizeTheme: { name: 'physical', factor: 0.3 } as SizeThemeProps, } export type IntraUnitLinkProps = typeof DefaultIntraUnitLinkProps diff --git a/src/mol-geo/representation/util.ts b/src/mol-geo/representation/util.ts index 7d548d60d..50c795ce0 100644 --- a/src/mol-geo/representation/util.ts +++ b/src/mol-geo/representation/util.ts @@ -14,7 +14,7 @@ export const DefaultBaseProps = { alpha: 1, visible: true, depthMask: true, - useFog: true, + useFog: false, quality: 'auto' as VisualQuality } export type BaseProps = typeof DefaultBaseProps diff --git a/src/mol-geo/representation/volume/index.ts b/src/mol-geo/representation/volume/index.ts index 588712d7a..5f3234dcb 100644 --- a/src/mol-geo/representation/volume/index.ts +++ b/src/mol-geo/representation/volume/index.ts @@ -42,6 +42,7 @@ export function VolumeRepresentation<P extends VolumeProps>(visualCtor: (volumeD } return { + label: 'Volume mesh', get renderObjects () { return renderObjects }, get props () { return _props }, createOrUpdate, -- GitLab