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

cleanup

parent be1737a8
No related branches found
No related tags found
No related merge requests found
......@@ -18,7 +18,7 @@ import { StateContext } from 'mol-view/state/context';
import { ColorTheme, SizeTheme } from 'mol-geo/theme';
import { Color, ColorNames } from 'mol-util/color';
import { Slider } from '../controls/slider';
import { VisualQuality } from 'mol-geo/representation';
import { VisualQuality } from 'mol-geo/representation/util';
export const ColorThemeInfo = {
'atom-index': {},
......
......@@ -18,7 +18,7 @@ import { StateContext } from 'mol-view/state/context';
import { ColorTheme, SizeTheme } from 'mol-geo/theme';
import { Color, ColorNames } from 'mol-util/color';
import { Slider } from '../controls/slider';
import { VisualQuality } from 'mol-geo/representation';
import { VisualQuality } from 'mol-geo/representation/util';
export const ColorThemeInfo = {
'atom-index': {},
......
......@@ -10,25 +10,6 @@ import { PickingId } from '../util/picking';
import { Loci } from 'mol-model/loci';
import { MarkerAction } from '../util/marker-data';
export type VisualQuality = 'custom' | 'auto' | 'highest' | 'high' | 'medium' | 'low' | 'lowest'
export const DefaultBaseProps = {
alpha: 1,
visible: true,
depthMask: true,
useFog: true,
quality: 'auto' as VisualQuality
}
export type BaseProps = Partial<typeof DefaultBaseProps>
export const DefaultMeshProps = {
...DefaultBaseProps,
doubleSided: false,
flipSided: false,
flatShaded: false,
}
export type MeshProps = Partial<typeof DefaultMeshProps>
export interface RepresentationProps {}
export interface Representation<D, P extends RepresentationProps = {}> {
......
......@@ -8,75 +8,18 @@
import { Structure, StructureSymmetry, Unit } from 'mol-model/structure';
import { Task } from 'mol-task'
import { RenderObject } from 'mol-gl/render-object';
import { Representation, RepresentationProps, Visual, VisualQuality, DefaultBaseProps } from '..';
import { Representation, RepresentationProps, Visual } from '..';
import { ColorTheme, SizeTheme } from '../../theme';
import { PickingId } from '../../util/picking';
import { Loci, EmptyLoci, isEmptyLoci } from 'mol-model/loci';
import { MarkerAction } from '../../util/marker-data';
import { defaults } from 'mol-util';
import { getQualityProps, DefaultBaseProps } from '../util';
export interface UnitsVisual<P extends RepresentationProps = {}> extends Visual<Unit.SymmetryGroup, P> { }
export interface StructureVisual<P extends RepresentationProps = {}> extends Visual<Structure, P> { }
export interface StructureRepresentation<P extends RepresentationProps = {}> extends Representation<Structure, P> { }
interface QualityProps {
quality: VisualQuality
detail: number
radialSegments: number
}
function getQualityProps(props: Partial<QualityProps>, structure: Structure) {
let quality = defaults(props.quality, 'auto' as VisualQuality)
let detail = 1
let radialSegments = 12
if (quality === 'auto') {
const score = structure.elementCount
if (score > 500_000) {
quality = 'lowest'
} else if (score > 100_000) {
quality = 'low'
} else if (score > 30_000) {
quality = 'medium'
} else {
quality = 'high'
}
}
switch (quality) {
case 'highest':
detail = 3
radialSegments = 36
break
case 'high':
detail = 2
radialSegments = 24
break
case 'medium':
detail = 1
radialSegments = 12
break
case 'low':
detail = 0
radialSegments = 5
break
case 'lowest':
detail = 0
radialSegments = 3
break
case 'custom':
detail = defaults(props.detail, 1)
radialSegments = defaults(props.radialSegments, 12)
break
}
return {
detail,
radialSegments
}
}
export const DefaultStructureProps = {
...DefaultBaseProps,
colorTheme: { name: 'instance-index' } as ColorTheme,
......
......@@ -22,8 +22,7 @@ import { OrderedSet } from 'mol-data/int';
import { createMarkers, MarkerAction } from '../../../util/marker-data';
import { Loci, EmptyLoci } from 'mol-model/loci';
import { SizeTheme } from '../../../theme';
import { DefaultMeshProps } from '../..';
import { createMeshValues, updateMeshValues, updateRenderableState, createRenderableState } from '../../util';
import { createMeshValues, updateMeshValues, updateRenderableState, createRenderableState, DefaultMeshProps } from '../../util';
export const DefaultElementSphereProps = {
...DefaultMeshProps,
......
......@@ -9,7 +9,7 @@ import { RuntimeContext } from 'mol-task';
import { Mesh } from '../../../../shape/mesh';
import { MeshBuilder } from '../../../../shape/mesh-builder';
import { LinkType } from 'mol-model/structure/model/types';
import { DefaultMeshProps } from '../../..';
import { DefaultMeshProps } from '../../../util';
export const DefaultLinkCylinderProps = {
...DefaultMeshProps,
......
......@@ -6,9 +6,27 @@
import { ValueCell } from 'mol-util/value-cell'
import { BaseValues } from 'mol-gl/renderable/schema';
import { BaseProps, MeshProps } from '.';
import { MeshValues, RenderableState } from 'mol-gl/renderable';
import { fillSerial } from 'mol-gl/renderable/util';
import { defaults } from 'mol-util';
import { Structure } from 'mol-model/structure';
export const DefaultBaseProps = {
alpha: 1,
visible: true,
depthMask: true,
useFog: true,
quality: 'auto' as VisualQuality
}
export type BaseProps = Partial<typeof DefaultBaseProps>
export const DefaultMeshProps = {
...DefaultBaseProps,
doubleSided: false,
flipSided: false,
flatShaded: false,
}
export type MeshProps = Partial<typeof DefaultMeshProps>
type Counts = { drawCount: number, elementCount: number, instanceCount: number }
......@@ -55,4 +73,63 @@ export function updateMeshValues(values: MeshValues, props: Required<MeshProps>)
export function updateRenderableState(state: RenderableState, props: Required<BaseProps>) {
state.visible = props.visible
state.depthMask = props.depthMask
}
export type VisualQuality = 'custom' | 'auto' | 'highest' | 'high' | 'medium' | 'low' | 'lowest'
interface QualityProps {
quality: VisualQuality
detail: number
radialSegments: number
}
export function getQualityProps(props: Partial<QualityProps>, structure: Structure) {
let quality = defaults(props.quality, 'auto' as VisualQuality)
let detail = 1
let radialSegments = 12
if (quality === 'auto') {
const score = structure.elementCount
if (score > 500_000) {
quality = 'lowest'
} else if (score > 100_000) {
quality = 'low'
} else if (score > 30_000) {
quality = 'medium'
} else {
quality = 'high'
}
}
switch (quality) {
case 'highest':
detail = 3
radialSegments = 36
break
case 'high':
detail = 2
radialSegments = 24
break
case 'medium':
detail = 1
radialSegments = 12
break
case 'low':
detail = 0
radialSegments = 5
break
case 'lowest':
detail = 0
radialSegments = 3
break
case 'custom':
detail = defaults(props.detail, 1)
radialSegments = defaults(props.radialSegments, 12)
break
}
return {
detail,
radialSegments
}
}
\ No newline at end of file
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