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

check if structure has gaps or nucleotides when setting default visuals

parent 25fddb04
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,7 @@ import { UnitsRepresentation } from '../units-representation'; ...@@ -12,7 +12,7 @@ import { UnitsRepresentation } from '../units-representation';
import { StructureRepresentation, StructureRepresentationProvider } from '../representation'; import { StructureRepresentation, StructureRepresentationProvider } from '../representation';
import { Representation, RepresentationParamsGetter, RepresentationContext } from 'mol-repr/representation'; import { Representation, RepresentationParamsGetter, RepresentationContext } from 'mol-repr/representation';
import { PolymerDirectionVisual, PolymerDirectionParams } from '../visual/polymer-direction-wedge'; import { PolymerDirectionVisual, PolymerDirectionParams } from '../visual/polymer-direction-wedge';
import { Structure } from 'mol-model/structure'; import { Structure, Unit } from 'mol-model/structure';
import { ThemeRegistryContext } from 'mol-theme/theme'; import { ThemeRegistryContext } from 'mol-theme/theme';
const CartoonVisuals = { const CartoonVisuals = {
...@@ -34,7 +34,17 @@ export const CartoonParams = { ...@@ -34,7 +34,17 @@ export const CartoonParams = {
} }
export type CartoonParams = typeof CartoonParams export type CartoonParams = typeof CartoonParams
export function getCartoonParams(ctx: ThemeRegistryContext, structure: Structure) { export function getCartoonParams(ctx: ThemeRegistryContext, structure: Structure) {
return PD.clone(CartoonParams) const params = PD.clone(CartoonParams)
let hasNucleotides = false
let hasGaps = false
structure.units.forEach(u => {
if (!hasNucleotides && Unit.isAtomic(u) && u.nucleotideElements.length) hasNucleotides = true
if (!hasGaps && u.gapElements.length) hasGaps = true
})
params.visuals.defaultValue = ['polymer-trace']
if (hasNucleotides) params.visuals.defaultValue.push('nucleotide-block')
if (hasGaps) params.visuals.defaultValue.push('polymer-gap')
return params
} }
export type CartoonRepresentation = StructureRepresentation<CartoonParams> export type CartoonRepresentation = StructureRepresentation<CartoonParams>
......
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