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

added repr.setVisibility

parent 4924d434
No related branches found
No related tags found
No related merge requests found
...@@ -62,7 +62,6 @@ export namespace Geometry { ...@@ -62,7 +62,6 @@ export namespace Geometry {
export const Params = { export const Params = {
alpha: PD.Range('Opacity', '', 1, 0, 1, 0.01), alpha: PD.Range('Opacity', '', 1, 0, 1, 0.01),
visible: PD.Boolean('Visible', '', true),
depthMask: PD.Boolean('Depth Mask', '', true), depthMask: PD.Boolean('Depth Mask', '', true),
useFog: PD.Boolean('Use Fog', '', false), useFog: PD.Boolean('Use Fog', '', false),
highlightColor: PD.Color('Highlight Color', '', Color.fromNormalizedRgb(1.0, 0.4, 0.6)), highlightColor: PD.Color('Highlight Color', '', Color.fromNormalizedRgb(1.0, 0.4, 0.6)),
...@@ -105,13 +104,12 @@ export namespace Geometry { ...@@ -105,13 +104,12 @@ export namespace Geometry {
export function createRenderableState(props: Geometry.Props): RenderableState { export function createRenderableState(props: Geometry.Props): RenderableState {
return { return {
visible: props.visible, visible: true,
depthMask: props.depthMask depthMask: props.depthMask
} }
} }
export function updateRenderableState(state: RenderableState, props: Geometry.Props) { export function updateRenderableState(state: RenderableState, props: Geometry.Props) {
state.visible = props.visible
state.depthMask = props.depthMask state.depthMask = props.depthMask
} }
......
...@@ -18,7 +18,7 @@ export function SyncRepresentationToCanvas(ctx: PluginContext) { ...@@ -18,7 +18,7 @@ export function SyncRepresentationToCanvas(ctx: PluginContext) {
ctx.canvas3d.add(e.obj.data); ctx.canvas3d.add(e.obj.data);
ctx.canvas3d.requestDraw(true); ctx.canvas3d.requestDraw(true);
// TODO: update visiblity // TODO: update visiblity, e.obj.data.setVisibility()
}); });
events.object.updated.subscribe(e => { events.object.updated.subscribe(e => {
if (e.oldObj && SO.isRepresentation3D(e.oldObj)) { if (e.oldObj && SO.isRepresentation3D(e.oldObj)) {
...@@ -29,7 +29,7 @@ export function SyncRepresentationToCanvas(ctx: PluginContext) { ...@@ -29,7 +29,7 @@ export function SyncRepresentationToCanvas(ctx: PluginContext) {
if (!SO.isRepresentation3D(e.obj)) return; if (!SO.isRepresentation3D(e.obj)) return;
// TODO: update visiblity // TODO: update visiblity, e.obj.data.setVisibility()
ctx.canvas3d.add(e.obj.data); ctx.canvas3d.add(e.obj.data);
ctx.canvas3d.requestDraw(true); ctx.canvas3d.requestDraw(true);
}); });
...@@ -47,6 +47,6 @@ export function UpdateRepresentationVisibility(ctx: PluginContext) { ...@@ -47,6 +47,6 @@ export function UpdateRepresentationVisibility(ctx: PluginContext) {
const cell = e.state.cells.get(e.ref)!; const cell = e.state.cells.get(e.ref)!;
if (!SO.isRepresentation3D(cell.obj)) return; if (!SO.isRepresentation3D(cell.obj)) return;
// TODO: update visiblity // TODO: update visiblity, e.obj.data.setVisibility()
}) })
} }
\ No newline at end of file
...@@ -87,6 +87,7 @@ interface Representation<D, P extends PD.Params = {}> { ...@@ -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> createOrUpdate: (ctx: RepresentationContext, props?: Partial<PD.Values<P>>, themeProps?: ThemeProps, data?: D) => Task<void>
getLoci: (pickingId: PickingId) => Loci getLoci: (pickingId: PickingId) => Loci
mark: (loci: Loci, action: MarkerAction) => boolean mark: (loci: Loci, action: MarkerAction) => boolean
setVisibility: (value: boolean) => void
destroy: () => void destroy: () => void
} }
namespace Representation { namespace Representation {
...@@ -96,6 +97,7 @@ namespace Representation { ...@@ -96,6 +97,7 @@ namespace Representation {
createOrUpdate: () => Task.constant('', undefined), createOrUpdate: () => Task.constant('', undefined),
getLoci: () => EmptyLoci, getLoci: () => EmptyLoci,
mark: () => false, mark: () => false,
setVisibility: () => {},
destroy: () => {} destroy: () => {}
} }
...@@ -168,6 +170,11 @@ namespace Representation { ...@@ -168,6 +170,11 @@ namespace Representation {
} }
return marked return marked
}, },
setVisibility: (value: boolean) => {
for (let i = 0, il = reprList.length; i < il; ++i) {
reprList[i].setVisibility(value)
}
},
destroy() { destroy() {
for (let i = 0, il = reprList.length; i < il; ++i) { for (let i = 0, il = reprList.length; i < il; ++i) {
reprList[i].destroy() reprList[i].destroy()
...@@ -189,5 +196,6 @@ export interface Visual<D, P extends PD.Params> { ...@@ -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> createOrUpdate: (ctx: VisualContext, theme: Theme, props?: Partial<PD.Values<P>>, data?: D) => Promise<void>
getLoci: (pickingId: PickingId) => Loci getLoci: (pickingId: PickingId) => Loci
mark: (loci: Loci, action: MarkerAction) => boolean mark: (loci: Loci, action: MarkerAction) => boolean
setVisibility: (value: boolean) => void
destroy: () => void destroy: () => void
} }
\ No newline at end of file
...@@ -100,6 +100,9 @@ export function ShapeRepresentation<P extends ShapeParams>(): ShapeRepresentatio ...@@ -100,6 +100,9 @@ export function ShapeRepresentation<P extends ShapeParams>(): ShapeRepresentatio
} }
return changed return changed
}, },
setVisibility(value: boolean) {
renderObjects.forEach(ro => ro.state.visible = value)
},
destroy() { destroy() {
// TODO // TODO
renderObjects.length = 0 renderObjects.length = 0
......
...@@ -50,6 +50,10 @@ export function ComplexRepresentation<P extends StructureParams>(label: string, ...@@ -50,6 +50,10 @@ export function ComplexRepresentation<P extends StructureParams>(label: string,
return visual ? visual.mark(loci, action) : false return visual ? visual.mark(loci, action) : false
} }
function setVisibility(value: boolean) {
if (visual) visual.setVisibility(value)
}
function destroy() { function destroy() {
if (visual) visual.destroy() if (visual) visual.destroy()
} }
...@@ -65,6 +69,7 @@ export function ComplexRepresentation<P extends StructureParams>(label: string, ...@@ -65,6 +69,7 @@ export function ComplexRepresentation<P extends StructureParams>(label: string,
createOrUpdate, createOrUpdate,
getLoci, getLoci,
mark, mark,
setVisibility,
destroy destroy
} }
} }
\ No newline at end of file
...@@ -162,6 +162,9 @@ export function ComplexVisual<P extends ComplexParams>(builder: ComplexVisualGeo ...@@ -162,6 +162,9 @@ export function ComplexVisual<P extends ComplexParams>(builder: ComplexVisualGeo
} }
return changed return changed
}, },
setVisibility(value: boolean) {
if (renderObject) renderObject.state.visible = value
},
destroy() { destroy() {
// TODO // TODO
renderObject = undefined renderObject = undefined
......
...@@ -141,6 +141,12 @@ export function UnitsRepresentation<P extends UnitsParams>(label: string, getPar ...@@ -141,6 +141,12 @@ export function UnitsRepresentation<P extends UnitsParams>(label: string, getPar
return changed return changed
} }
function setVisibility(value: boolean) {
visuals.forEach(({ visual }) => {
visual.setVisibility(value)
})
}
function destroy() { function destroy() {
visuals.forEach(({ visual }) => visual.destroy()) visuals.forEach(({ visual }) => visual.destroy())
visuals.clear() visuals.clear()
...@@ -161,6 +167,7 @@ export function UnitsRepresentation<P extends UnitsParams>(label: string, getPar ...@@ -161,6 +167,7 @@ export function UnitsRepresentation<P extends UnitsParams>(label: string, getPar
createOrUpdate, createOrUpdate,
getLoci, getLoci,
mark, mark,
setVisibility,
destroy destroy
} }
} }
\ No newline at end of file
...@@ -192,6 +192,9 @@ export function UnitsVisual<P extends UnitsParams>(builder: UnitsVisualGeometryB ...@@ -192,6 +192,9 @@ export function UnitsVisual<P extends UnitsParams>(builder: UnitsVisualGeometryB
} }
return changed return changed
}, },
setVisibility(value: boolean) {
if (renderObject) renderObject.state.visible = value
},
destroy() { destroy() {
// TODO // TODO
renderObject = undefined renderObject = undefined
......
...@@ -127,6 +127,9 @@ export function VolumeVisual<P extends VolumeParams>(builder: VolumeVisualGeomet ...@@ -127,6 +127,9 @@ export function VolumeVisual<P extends VolumeParams>(builder: VolumeVisualGeomet
} }
return changed return changed
}, },
setVisibility(value: boolean) {
if (renderObject) renderObject.state.visible = value
},
destroy() { destroy() {
// TODO // TODO
renderObject = undefined renderObject = undefined
...@@ -198,6 +201,10 @@ export function VolumeRepresentation<P extends VolumeParams>(label: string, getP ...@@ -198,6 +201,10 @@ export function VolumeRepresentation<P extends VolumeParams>(label: string, getP
if (visual) visual.destroy() if (visual) visual.destroy()
} }
function setVisibility(value: boolean) {
if (visual) visual.setVisibility(value)
}
return { return {
label, label,
get renderObjects() { get renderObjects() {
...@@ -209,6 +216,7 @@ export function VolumeRepresentation<P extends VolumeParams>(label: string, getP ...@@ -209,6 +216,7 @@ export function VolumeRepresentation<P extends VolumeParams>(label: string, getP
createOrUpdate, createOrUpdate,
getLoci, getLoci,
mark, mark,
setVisibility,
destroy destroy
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment