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

better default props handling

parent 4b36683e
No related branches found
No related tags found
No related merge requests found
...@@ -11,7 +11,7 @@ import { PickingId } from '../../util/picking'; ...@@ -11,7 +11,7 @@ import { PickingId } from '../../util/picking';
import { Loci, EmptyLoci } from 'mol-model/loci'; import { Loci, EmptyLoci } from 'mol-model/loci';
import { MarkerAction } from '../../util/marker-data'; import { MarkerAction } from '../../util/marker-data';
import { getQualityProps } from '../util'; import { getQualityProps } from '../util';
import { StructureProps, DefaultStructureProps, StructureRepresentation } from '.'; import { StructureProps, StructureRepresentation } from '.';
import { ComplexVisual } from './complex-visual'; import { ComplexVisual } from './complex-visual';
export function ComplexRepresentation<P extends StructureProps>(label: string, visualCtor: () => ComplexVisual<P>): StructureRepresentation<P> { export function ComplexRepresentation<P extends StructureProps>(label: string, visualCtor: () => ComplexVisual<P>): StructureRepresentation<P> {
...@@ -19,7 +19,7 @@ export function ComplexRepresentation<P extends StructureProps>(label: string, v ...@@ -19,7 +19,7 @@ export function ComplexRepresentation<P extends StructureProps>(label: string, v
let _props: P let _props: P
function createOrUpdate(props: Partial<P> = {}, structure?: Structure) { function createOrUpdate(props: Partial<P> = {}, structure?: Structure) {
_props = Object.assign({}, DefaultStructureProps, _props, props, getQualityProps(props, structure)) _props = Object.assign({}, _props, props, getQualityProps(props, structure))
if (structure) _props.colorTheme.structure = structure if (structure) _props.colorTheme.structure = structure
return Task.create('Creating StructureRepresentation', async ctx => { return Task.create('Creating StructureRepresentation', async ctx => {
......
...@@ -7,12 +7,9 @@ ...@@ -7,12 +7,9 @@
import { UnitsRepresentation } from '..'; import { UnitsRepresentation } from '..';
import { ElementPointVisual, DefaultElementPointProps } from '../visual/element-point'; import { ElementPointVisual, DefaultElementPointProps } from '../visual/element-point';
import { StructureRepresentation } from '../units-representation'; import { StructureRepresentation } from '../units-representation';
import { SizeThemeProps } from 'mol-view/theme/size';
export const DefaultPointProps = { export const DefaultPointProps = {
...DefaultElementPointProps, ...DefaultElementPointProps,
sizeTheme: { name: 'uniform', value: 0.2 } as SizeThemeProps,
} }
export type PointProps = typeof DefaultPointProps export type PointProps = typeof DefaultPointProps
......
...@@ -13,14 +13,14 @@ import { PickingId } from '../../util/picking'; ...@@ -13,14 +13,14 @@ import { PickingId } from '../../util/picking';
import { Loci, EmptyLoci, isEmptyLoci } from 'mol-model/loci'; import { Loci, EmptyLoci, isEmptyLoci } from 'mol-model/loci';
import { MarkerAction } from '../../util/marker-data'; import { MarkerAction } from '../../util/marker-data';
import { getQualityProps } from '../util'; import { getQualityProps } from '../util';
import { DefaultStructureProps, StructureProps } from '.'; import { StructureProps } from '.';
export interface UnitsVisual<P extends RepresentationProps = {}> extends Visual<Unit.SymmetryGroup, P> { } export interface UnitsVisual<P extends RepresentationProps = {}> extends Visual<Unit.SymmetryGroup, P> { }
export interface StructureVisual<P extends RepresentationProps = {}> extends Visual<Structure, P> { } export interface StructureVisual<P extends RepresentationProps = {}> extends Visual<Structure, P> { }
export interface StructureRepresentation<P extends RepresentationProps = {}> extends Representation<Structure, P> { } export interface StructureRepresentation<P extends RepresentationProps = {}> extends Representation<Structure, P> { }
export function UnitsRepresentation<P extends StructureProps>(visualCtor: () => UnitsVisual<P>): StructureRepresentation<P> { export function UnitsRepresentation<P extends StructureProps>(label: string, visualCtor: () => UnitsVisual<P>): StructureRepresentation<P> {
let visuals = new Map<number, { group: Unit.SymmetryGroup, visual: UnitsVisual<P> }>() let visuals = new Map<number, { group: Unit.SymmetryGroup, visual: UnitsVisual<P> }>()
let _props: P let _props: P
...@@ -28,7 +28,7 @@ export function UnitsRepresentation<P extends StructureProps>(visualCtor: () => ...@@ -28,7 +28,7 @@ export function UnitsRepresentation<P extends StructureProps>(visualCtor: () =>
let _groups: ReadonlyArray<Unit.SymmetryGroup> let _groups: ReadonlyArray<Unit.SymmetryGroup>
function createOrUpdate(props: Partial<P> = {}, structure?: Structure) { function createOrUpdate(props: Partial<P> = {}, structure?: Structure) {
_props = Object.assign({}, DefaultStructureProps, _props, props, getQualityProps(props, structure)) _props = Object.assign({}, _props, props, getQualityProps(props, structure))
_props.colorTheme.structure = structure _props.colorTheme.structure = structure
return Task.create('Creating or updating StructureRepresentation', async ctx => { return Task.create('Creating or updating StructureRepresentation', async ctx => {
...@@ -120,6 +120,7 @@ export function UnitsRepresentation<P extends StructureProps>(visualCtor: () => ...@@ -120,6 +120,7 @@ export function UnitsRepresentation<P extends StructureProps>(visualCtor: () =>
} }
return { return {
label,
get renderObjects() { get renderObjects() {
const renderObjects: RenderObject[] = [] const renderObjects: RenderObject[] = []
visuals.forEach(({ visual }) => { visuals.forEach(({ visual }) => {
......
...@@ -25,7 +25,8 @@ import { createTransforms } from '../../../util/transform-data'; ...@@ -25,7 +25,8 @@ import { createTransforms } from '../../../util/transform-data';
export const DefaultElementPointProps = { export const DefaultElementPointProps = {
...DefaultStructureProps, ...DefaultStructureProps,
sizeTheme: { name: 'physical' } as SizeThemeProps,
sizeTheme: { name: 'uniform', value: 0.2 } as SizeThemeProps,
pointSizeAttenuation: true, pointSizeAttenuation: true,
} }
export type ElementPointProps = Partial<typeof DefaultElementPointProps> export type ElementPointProps = Partial<typeof DefaultElementPointProps>
...@@ -75,7 +76,6 @@ export function ElementPointVisual(): UnitsVisual<ElementPointProps> { ...@@ -75,7 +76,6 @@ export function ElementPointVisual(): UnitsVisual<ElementPointProps> {
vertices = await createElementPointVertices(ctx, unit, vertices) vertices = await createElementPointVertices(ctx, unit, vertices)
renderObject = await createUnitsPointRenderObject(ctx, group, vertices, locationIt, currentProps) renderObject = await createUnitsPointRenderObject(ctx, group, vertices, locationIt, currentProps)
console.log(renderObject)
} else if (renderObject) { } else if (renderObject) {
if (group) currentGroup = group if (group) currentGroup = group
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment