diff --git a/src/mol-geo/geometry/geometry.ts b/src/mol-geo/geometry/geometry.ts index 37cdf4b43955673e25acfdef657fcc058de5eebe..7e364387cb763ca6a9bb2e4e1c398ba355849be0 100644 --- a/src/mol-geo/geometry/geometry.ts +++ b/src/mol-geo/geometry/geometry.ts @@ -62,7 +62,6 @@ export namespace Geometry { export const Params = { alpha: PD.Range('Opacity', '', 1, 0, 1, 0.01), - visible: PD.Boolean('Visible', '', true), depthMask: PD.Boolean('Depth Mask', '', true), useFog: PD.Boolean('Use Fog', '', false), highlightColor: PD.Color('Highlight Color', '', Color.fromNormalizedRgb(1.0, 0.4, 0.6)), @@ -105,13 +104,12 @@ export namespace Geometry { export function createRenderableState(props: Geometry.Props): RenderableState { return { - visible: props.visible, + visible: true, depthMask: props.depthMask } } export function updateRenderableState(state: RenderableState, props: Geometry.Props) { - state.visible = props.visible state.depthMask = props.depthMask } diff --git a/src/mol-plugin/behavior/static/representation.ts b/src/mol-plugin/behavior/static/representation.ts index ee5c6a0e8343ee643070d580d1f3a282d54bffb4..0bd4ec276ddbf7f2be67231bdcfc86e6c4f51ac7 100644 --- a/src/mol-plugin/behavior/static/representation.ts +++ b/src/mol-plugin/behavior/static/representation.ts @@ -18,7 +18,7 @@ export function SyncRepresentationToCanvas(ctx: PluginContext) { ctx.canvas3d.add(e.obj.data); ctx.canvas3d.requestDraw(true); - // TODO: update visiblity + // TODO: update visiblity, e.obj.data.setVisibility() }); events.object.updated.subscribe(e => { if (e.oldObj && SO.isRepresentation3D(e.oldObj)) { @@ -29,7 +29,7 @@ export function SyncRepresentationToCanvas(ctx: PluginContext) { if (!SO.isRepresentation3D(e.obj)) return; - // TODO: update visiblity + // TODO: update visiblity, e.obj.data.setVisibility() ctx.canvas3d.add(e.obj.data); ctx.canvas3d.requestDraw(true); }); @@ -47,6 +47,6 @@ export function UpdateRepresentationVisibility(ctx: PluginContext) { const cell = e.state.cells.get(e.ref)!; if (!SO.isRepresentation3D(cell.obj)) return; - // TODO: update visiblity + // TODO: update visiblity, e.obj.data.setVisibility() }) } \ No newline at end of file diff --git a/src/mol-repr/representation.ts b/src/mol-repr/representation.ts index 708cede42468ce8fff5239b61e8b567df02f07fb..c456ffcfce5fe78108c0d4b1519e563fe27c2f4e 100644 --- a/src/mol-repr/representation.ts +++ b/src/mol-repr/representation.ts @@ -87,6 +87,7 @@ interface Representation<D, P extends PD.Params = {}> { createOrUpdate: (ctx: RepresentationContext, props?: Partial<PD.Values<P>>, themeProps?: ThemeProps, data?: D) => Task<void> getLoci: (pickingId: PickingId) => Loci mark: (loci: Loci, action: MarkerAction) => boolean + setVisibility: (value: boolean) => void destroy: () => void } namespace Representation { @@ -96,6 +97,7 @@ namespace Representation { createOrUpdate: () => Task.constant('', undefined), getLoci: () => EmptyLoci, mark: () => false, + setVisibility: () => {}, destroy: () => {} } @@ -168,6 +170,11 @@ namespace Representation { } return marked }, + setVisibility: (value: boolean) => { + for (let i = 0, il = reprList.length; i < il; ++i) { + reprList[i].setVisibility(value) + } + }, destroy() { for (let i = 0, il = reprList.length; i < il; ++i) { reprList[i].destroy() @@ -189,5 +196,6 @@ export interface Visual<D, P extends PD.Params> { createOrUpdate: (ctx: VisualContext, theme: Theme, props?: Partial<PD.Values<P>>, data?: D) => Promise<void> getLoci: (pickingId: PickingId) => Loci mark: (loci: Loci, action: MarkerAction) => boolean + setVisibility: (value: boolean) => void destroy: () => void } \ No newline at end of file diff --git a/src/mol-repr/shape/representation.ts b/src/mol-repr/shape/representation.ts index 9e283591f388d0c63167f22bbc9c4ce69e61dd5e..f9588891c092f2857753c552b4d297024feef2de 100644 --- a/src/mol-repr/shape/representation.ts +++ b/src/mol-repr/shape/representation.ts @@ -100,6 +100,9 @@ export function ShapeRepresentation<P extends ShapeParams>(): ShapeRepresentatio } return changed }, + setVisibility(value: boolean) { + renderObjects.forEach(ro => ro.state.visible = value) + }, destroy() { // TODO renderObjects.length = 0 diff --git a/src/mol-repr/structure/complex-representation.ts b/src/mol-repr/structure/complex-representation.ts index bf0350bcb4cd31af3d41620e441ae19716f2f4e8..c99f9c32b60a571797f5aa35db14002e0b1492ee 100644 --- a/src/mol-repr/structure/complex-representation.ts +++ b/src/mol-repr/structure/complex-representation.ts @@ -50,6 +50,10 @@ export function ComplexRepresentation<P extends StructureParams>(label: string, return visual ? visual.mark(loci, action) : false } + function setVisibility(value: boolean) { + if (visual) visual.setVisibility(value) + } + function destroy() { if (visual) visual.destroy() } @@ -65,6 +69,7 @@ export function ComplexRepresentation<P extends StructureParams>(label: string, createOrUpdate, getLoci, mark, + setVisibility, destroy } } \ No newline at end of file diff --git a/src/mol-repr/structure/complex-visual.ts b/src/mol-repr/structure/complex-visual.ts index 9d27d8bca1a1aadf810da95155f7e1a016c88d87..b24737ef35d6df0aa2b6f48b699cc65ae832e324 100644 --- a/src/mol-repr/structure/complex-visual.ts +++ b/src/mol-repr/structure/complex-visual.ts @@ -162,6 +162,9 @@ export function ComplexVisual<P extends ComplexParams>(builder: ComplexVisualGeo } return changed }, + setVisibility(value: boolean) { + if (renderObject) renderObject.state.visible = value + }, destroy() { // TODO renderObject = undefined diff --git a/src/mol-repr/structure/units-representation.ts b/src/mol-repr/structure/units-representation.ts index c91a664a6a3529dea3b4b11df46ed38f33ef810c..f0d38b6699cb593a3ccbdd40cf8ab387029fcac5 100644 --- a/src/mol-repr/structure/units-representation.ts +++ b/src/mol-repr/structure/units-representation.ts @@ -141,6 +141,12 @@ export function UnitsRepresentation<P extends UnitsParams>(label: string, getPar return changed } + function setVisibility(value: boolean) { + visuals.forEach(({ visual }) => { + visual.setVisibility(value) + }) + } + function destroy() { visuals.forEach(({ visual }) => visual.destroy()) visuals.clear() @@ -161,6 +167,7 @@ export function UnitsRepresentation<P extends UnitsParams>(label: string, getPar createOrUpdate, getLoci, mark, + setVisibility, destroy } } \ No newline at end of file diff --git a/src/mol-repr/structure/units-visual.ts b/src/mol-repr/structure/units-visual.ts index ebfb6ab0461e97fd449b9c69dda6095ec83f18a4..f5cc5a4a58ce0ae94f8eb3bd551a47d0d49565f8 100644 --- a/src/mol-repr/structure/units-visual.ts +++ b/src/mol-repr/structure/units-visual.ts @@ -192,6 +192,9 @@ export function UnitsVisual<P extends UnitsParams>(builder: UnitsVisualGeometryB } return changed }, + setVisibility(value: boolean) { + if (renderObject) renderObject.state.visible = value + }, destroy() { // TODO renderObject = undefined diff --git a/src/mol-repr/volume/representation.ts b/src/mol-repr/volume/representation.ts index 86eb9bb4912d75dce7a6e55a354e6805b53bfd72..d974b4e49bb964d45ffae23b7e639a7c4bc2fd9d 100644 --- a/src/mol-repr/volume/representation.ts +++ b/src/mol-repr/volume/representation.ts @@ -127,6 +127,9 @@ export function VolumeVisual<P extends VolumeParams>(builder: VolumeVisualGeomet } return changed }, + setVisibility(value: boolean) { + if (renderObject) renderObject.state.visible = value + }, destroy() { // TODO renderObject = undefined @@ -198,6 +201,10 @@ export function VolumeRepresentation<P extends VolumeParams>(label: string, getP if (visual) visual.destroy() } + function setVisibility(value: boolean) { + if (visual) visual.setVisibility(value) + } + return { label, get renderObjects() { @@ -209,6 +216,7 @@ export function VolumeRepresentation<P extends VolumeParams>(label: string, getP createOrUpdate, getLoci, mark, + setVisibility, destroy } } \ No newline at end of file