/** * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose */ import { Location } from 'mol-model/location'; import { Shape } from 'mol-model/shape'; import { ParamDefinition as PD } from 'mol-util/param-definition' import { ThemeDataContext } from 'mol-theme/theme'; import { SizeTheme } from 'mol-theme/size'; const DefaultSize = 1 const Description = 'Assigns sizes as defined by the shape object.' export const ShapeGroupSizeThemeParams = {} export type ShapeGroupSizeThemeParams = typeof ShapeGroupSizeThemeParams export function getShapeGroupSizeThemeParams(ctx: ThemeDataContext) { return ShapeGroupSizeThemeParams // TODO return copy } export function ShapeGroupSizeTheme(ctx: ThemeDataContext, props: PD.Values): SizeTheme { return { factory: ShapeGroupSizeTheme, granularity: 'groupInstance', size: (location: Location): number => { if (Shape.isLocation(location)) { return location.shape.getSize(location.group, location.instance) } return DefaultSize }, props, description: Description } } export const ShapeGroupSizeThemeProvider: SizeTheme.Provider = { label: 'Shape Group', factory: ShapeGroupSizeTheme, getParams: getShapeGroupSizeThemeParams, defaultValues: PD.getDefaultValues(ShapeGroupSizeThemeParams), isApplicable: (ctx: ThemeDataContext) => !!ctx.shape }