|
@@ -8,14 +8,14 @@
|
|
|
import { Structure } from 'mol-model/structure';
|
|
|
import { Task } from 'mol-task'
|
|
|
import { PickingId } from '../../util/picking';
|
|
|
-import { Loci, EmptyLoci, isEmptyLoci } from 'mol-model/loci';
|
|
|
+import { Loci, EmptyLoci } from 'mol-model/loci';
|
|
|
import { MarkerAction } from '../../util/marker-data';
|
|
|
import { getQualityProps } from '../util';
|
|
|
import { StructureProps, DefaultStructureProps, StructureRepresentation } from '.';
|
|
|
import { ComplexVisual } from './complex-visual';
|
|
|
|
|
|
export function ComplexRepresentation<P extends StructureProps>(visualCtor: () => ComplexVisual<P>): StructureRepresentation<P> {
|
|
|
- let visual: ComplexVisual<P>
|
|
|
+ let visual: ComplexVisual<P> | undefined
|
|
|
|
|
|
let _props: P
|
|
|
let _structure: Structure
|
|
@@ -32,7 +32,7 @@ export function ComplexRepresentation<P extends StructureProps>(visualCtor: () =
|
|
|
if (_structure.hashCode === structure.hashCode) {
|
|
|
await update(_props)
|
|
|
} else {
|
|
|
- if (!await visual.update(ctx, _props)) {
|
|
|
+ if (visual && !await visual.update(ctx, _props)) {
|
|
|
await visual.create(ctx, structure, _props)
|
|
|
}
|
|
|
}
|
|
@@ -46,30 +46,27 @@ export function ComplexRepresentation<P extends StructureProps>(visualCtor: () =
|
|
|
_props = Object.assign({}, DefaultStructureProps, _props, props, getQualityProps(props, _structure))
|
|
|
_props.colorTheme.structure = _structure
|
|
|
|
|
|
- if (!await visual.update(ctx, _props)) {
|
|
|
+ if (visual && !await visual.update(ctx, _props)) {
|
|
|
await visual.create(ctx, _structure, _props)
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
|
|
|
function getLoci(pickingId: PickingId) {
|
|
|
- let loci: Loci = EmptyLoci
|
|
|
- const _loci = visual.getLoci(pickingId)
|
|
|
- if (!isEmptyLoci(_loci)) loci = _loci
|
|
|
- return loci
|
|
|
+ return visual ? visual.getLoci(pickingId) : EmptyLoci
|
|
|
}
|
|
|
|
|
|
function mark(loci: Loci, action: MarkerAction) {
|
|
|
- visual.mark(loci, action)
|
|
|
+ if (visual) visual.mark(loci, action)
|
|
|
}
|
|
|
|
|
|
function destroy() {
|
|
|
- visual.destroy()
|
|
|
+ if (visual) visual.destroy()
|
|
|
}
|
|
|
|
|
|
return {
|
|
|
get renderObjects() {
|
|
|
- return visual.renderObject ? [ visual.renderObject ] : []
|
|
|
+ return visual && visual.renderObject ? [ visual.renderObject ] : []
|
|
|
},
|
|
|
get props() { return _props },
|
|
|
create,
|