12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- /**
- * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
- *
- * @author Alexander Rose <alexander.rose@weirdbyte.de>
- */
- 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<ShapeGroupSizeThemeParams>): SizeTheme<ShapeGroupSizeThemeParams> {
- 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<ShapeGroupSizeThemeParams> = {
- label: 'Shape Group',
- factory: ShapeGroupSizeTheme,
- getParams: getShapeGroupSizeThemeParams,
- defaultValues: PD.getDefaultValues(ShapeGroupSizeThemeParams),
- isApplicable: (ctx: ThemeDataContext) => !!ctx.shape
- }
|