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

log tweaks

parent 9cf599d8
No related branches found
No related tags found
No related merge requests found
...@@ -11,6 +11,7 @@ import { BehaviorSubject } from 'rxjs'; ...@@ -11,6 +11,7 @@ import { BehaviorSubject } from 'rxjs';
import { CifBlock } from 'mol-io/reader/cif'; import { CifBlock } from 'mol-io/reader/cif';
import { VolumeView } from './volume-view'; import { VolumeView } from './volume-view';
import { Ccp4File } from 'mol-io/reader/ccp4/schema'; import { Ccp4File } from 'mol-io/reader/ccp4/schema';
import { Progress } from 'mol-task';
export class App { export class App {
canvas3d: Canvas3D canvas3d: Canvas3D
...@@ -59,6 +60,10 @@ export class App { ...@@ -59,6 +60,10 @@ export class App {
return result return result
} }
log(progress: Progress) {
console.log(Progress.format(progress))
}
// //
async loadMmcif(cif: CifBlock, assemblyId?: string) { async loadMmcif(cif: CifBlock, assemblyId?: string) {
......
...@@ -10,14 +10,13 @@ import { App } from '../app'; ...@@ -10,14 +10,13 @@ import { App } from '../app';
import { Params } from 'mol-util/parameter'; import { Params } from 'mol-util/parameter';
import { Representation } from 'mol-geo/representation'; import { Representation } from 'mol-geo/representation';
import { ParametersComponent } from 'mol-app/component/parameters'; import { ParametersComponent } from 'mol-app/component/parameters';
import { Progress } from 'mol-task';
import { ColorTheme } from 'mol-theme/color'; import { ColorTheme } from 'mol-theme/color';
import { getColorThemeProps } from 'mol-geo/geometry/color-data'; import { getColorThemeProps } from 'mol-geo/geometry/color-data';
import { ColorThemeComponent } from 'mol-app/component/color-theme'; import { ColorThemeComponent } from 'mol-app/component/color-theme';
export interface RepresentationComponentProps { export interface RepresentationComponentProps {
app: App app: App
viewer: Canvas3D canvas3d: Canvas3D
repr: Representation<Params> repr: Representation<Params>
} }
...@@ -43,10 +42,10 @@ export class RepresentationComponent extends React.Component<RepresentationCompo ...@@ -43,10 +42,10 @@ export class RepresentationComponent extends React.Component<RepresentationCompo
async onChange(k: string, v: any) { async onChange(k: string, v: any) {
await this.props.app.runTask(this.props.repr.createOrUpdate({ [k]: v }).run( await this.props.app.runTask(this.props.repr.createOrUpdate({ [k]: v }).run(
progress => console.log(Progress.format(progress)) progress => this.props.app.log(progress)
), 'Representation Update') ), 'Representation Update')
this.props.viewer.add(this.props.repr) this.props.canvas3d.add(this.props.repr)
this.props.viewer.requestDraw(true) this.props.canvas3d.requestDraw(true)
this.setState(this.stateFromRepr(this.props.repr)) this.setState(this.stateFromRepr(this.props.repr))
} }
......
...@@ -174,7 +174,7 @@ export class StructureViewComponent extends React.Component<StructureViewCompone ...@@ -174,7 +174,7 @@ export class StructureViewComponent extends React.Component<StructureViewCompone
return <div key={i}> return <div key={i}>
<RepresentationComponent <RepresentationComponent
repr={structureRepresentations[k] as Representation<any>} repr={structureRepresentations[k] as Representation<any>}
viewer={structureView.viewer} canvas3d={structureView.viewer}
app={structureView.app} app={structureView.app}
/> />
</div> </div>
......
...@@ -89,7 +89,7 @@ export class VolumeViewComponent extends React.Component<VolumeViewComponentProp ...@@ -89,7 +89,7 @@ export class VolumeViewComponent extends React.Component<VolumeViewComponentProp
return <div key={i}> return <div key={i}>
<RepresentationComponent <RepresentationComponent
repr={volumeRepresentations[k] as Representation<any>} repr={volumeRepresentations[k] as Representation<any>}
viewer={volumeView.viewer} canvas3d={volumeView.viewer}
app={volumeView.app} app={volumeView.app}
/> />
</div> </div>
......
...@@ -26,7 +26,6 @@ import { SpacefillRepresentation } from 'mol-geo/representation/structure/repres ...@@ -26,7 +26,6 @@ import { SpacefillRepresentation } from 'mol-geo/representation/structure/repres
import { DistanceRestraintRepresentation } from 'mol-geo/representation/structure/representation/distance-restraint'; import { DistanceRestraintRepresentation } from 'mol-geo/representation/structure/representation/distance-restraint';
import { MolecularSurfaceRepresentation } from 'mol-geo/representation/structure/representation/molecular-surface'; import { MolecularSurfaceRepresentation } from 'mol-geo/representation/structure/representation/molecular-surface';
import { App } from './app'; import { App } from './app';
import { Progress } from 'mol-task';
export interface StructureView { export interface StructureView {
readonly app: App readonly app: App
...@@ -211,7 +210,7 @@ export async function StructureView(app: App, viewer: Canvas3D, models: Readonly ...@@ -211,7 +210,7 @@ export async function StructureView(app: App, viewer: Canvas3D, models: Readonly
if (active[k]) { if (active[k]) {
const p = { webgl: viewer.webgl } const p = { webgl: viewer.webgl }
await app.runTask(structureRepresentations[k].createOrUpdate(p, structure).run( await app.runTask(structureRepresentations[k].createOrUpdate(p, structure).run(
progress => console.log(Progress.format(progress)) progress => app.log(progress)
), 'Create/update representation') ), 'Create/update representation')
viewer.add(structureRepresentations[k]) viewer.add(structureRepresentations[k])
} else { } else {
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
import Canvas3D from 'mol-canvas3d/canvas3d'; import Canvas3D from 'mol-canvas3d/canvas3d';
import { BehaviorSubject } from 'rxjs'; import { BehaviorSubject } from 'rxjs';
import { App } from './app'; import { App } from './app';
import { Progress } from 'mol-task';
import { VolumeData } from 'mol-model/volume'; import { VolumeData } from 'mol-model/volume';
import { VolumeRepresentation } from 'mol-geo/representation/volume'; import { VolumeRepresentation } from 'mol-geo/representation/volume';
import { IsosurfaceRepresentation } from 'mol-geo/representation/volume/isosurface-mesh'; import { IsosurfaceRepresentation } from 'mol-geo/representation/volume/isosurface-mesh';
...@@ -57,7 +56,7 @@ export async function VolumeView(app: App, viewer: Canvas3D, volume: VolumeData, ...@@ -57,7 +56,7 @@ export async function VolumeView(app: App, viewer: Canvas3D, volume: VolumeData,
if (active[k]) { if (active[k]) {
const p = { webgl: viewer.webgl } const p = { webgl: viewer.webgl }
await app.runTask(volumeRepresentations[k].createOrUpdate(p, volume).run( await app.runTask(volumeRepresentations[k].createOrUpdate(p, volume).run(
progress => console.log(Progress.format(progress)) progress => app.log(progress)
), 'Create/update representation') ), 'Create/update representation')
viewer.add(volumeRepresentations[k]) viewer.add(volumeRepresentations[k])
} else { } else {
......
...@@ -17,7 +17,7 @@ import { RenderableState, Renderable } from 'mol-gl/renderable' ...@@ -17,7 +17,7 @@ import { RenderableState, Renderable } from 'mol-gl/renderable'
import { createRenderable, createGaussianDensityRenderObject } from 'mol-gl/render-object' import { createRenderable, createGaussianDensityRenderObject } from 'mol-gl/render-object'
import { WebGLContext, createContext, getGLContext } from 'mol-gl/webgl/context'; import { WebGLContext, createContext, getGLContext } from 'mol-gl/webgl/context';
import { createTexture, Texture } from 'mol-gl/webgl/texture'; import { createTexture, Texture } from 'mol-gl/webgl/texture';
import { GLRenderingContext, isWebGL2 } from 'mol-gl/webgl/compat'; import { GLRenderingContext } from 'mol-gl/webgl/compat';
import { decodeIdRGB } from 'mol-geo/geometry/picking'; import { decodeIdRGB } from 'mol-geo/geometry/picking';
/** name for shared framebuffer used for gpu gaussian surface operations */ /** name for shared framebuffer used for gpu gaussian surface operations */
...@@ -27,9 +27,9 @@ export async function GaussianDensityGPU(ctx: RuntimeContext, position: Position ...@@ -27,9 +27,9 @@ export async function GaussianDensityGPU(ctx: RuntimeContext, position: Position
const webgl = defaults(props.webgl, getWebGLContext()) const webgl = defaults(props.webgl, getWebGLContext())
// always use texture2d when the gaussian density needs to be downloaded from the GPU, // always use texture2d when the gaussian density needs to be downloaded from the GPU,
// it's faster than texture3d // it's faster than texture3d
console.time('GaussianDensityTexture2d') // console.time('GaussianDensityTexture2d')
const { scale, bbox, texture, dim } = await GaussianDensityTexture2d(ctx, webgl, position, box, radius, props) const { scale, bbox, texture, dim } = await GaussianDensityTexture2d(ctx, webgl, position, box, radius, props)
console.timeEnd('GaussianDensityTexture2d') // console.timeEnd('GaussianDensityTexture2d')
const { field, idField } = await fieldFromTexture2d(webgl, texture, dim) const { field, idField } = await fieldFromTexture2d(webgl, texture, dim)
const transform = Mat4.identity() const transform = Mat4.identity()
...@@ -40,11 +40,11 @@ export async function GaussianDensityGPU(ctx: RuntimeContext, position: Position ...@@ -40,11 +40,11 @@ export async function GaussianDensityGPU(ctx: RuntimeContext, position: Position
} }
export async function GaussianDensityTexture(ctx: RuntimeContext, webgl: WebGLContext, position: PositionData, box: Box3D, radius: (index: number) => number, props: GaussianDensityProps, oldTexture?: Texture): Promise<DensityTextureData> { export async function GaussianDensityTexture(ctx: RuntimeContext, webgl: WebGLContext, position: PositionData, box: Box3D, radius: (index: number) => number, props: GaussianDensityProps, oldTexture?: Texture): Promise<DensityTextureData> {
console.time(`GaussianDensityTexture, ${webgl.isWebGL2 ? '3d' : '2d'}`) // console.time(`GaussianDensityTexture, ${webgl.isWebGL2 ? '3d' : '2d'}`)
const { texture, scale, bbox, dim } = webgl.isWebGL2 ? const { texture, scale, bbox, dim } = webgl.isWebGL2 ?
await GaussianDensityTexture3d(ctx, webgl, position, box, radius, props, oldTexture) : await GaussianDensityTexture3d(ctx, webgl, position, box, radius, props, oldTexture) :
await GaussianDensityTexture2d(ctx, webgl, position, box, radius, props, oldTexture) await GaussianDensityTexture2d(ctx, webgl, position, box, radius, props, oldTexture)
console.timeEnd(`GaussianDensityTexture, ${webgl.isWebGL2 ? '3d' : '2d'}`) // console.timeEnd(`GaussianDensityTexture, ${webgl.isWebGL2 ? '3d' : '2d'}`)
const transform = Mat4.identity() const transform = Mat4.identity()
Mat4.fromScaling(transform, scale) Mat4.fromScaling(transform, scale)
...@@ -215,7 +215,7 @@ async function prepareGaussianDensityData(ctx: RuntimeContext, position: Positio ...@@ -215,7 +215,7 @@ async function prepareGaussianDensityData(ctx: RuntimeContext, position: Positio
const delta = getDelta(expandedBox, resolution) const delta = getDelta(expandedBox, resolution)
const dim = Vec3.zero() const dim = Vec3.zero()
Vec3.ceil(dim, Vec3.mul(dim, extent, delta)) Vec3.ceil(dim, Vec3.mul(dim, extent, delta))
console.log('grid dim gpu', dim) // console.log('grid dim gpu', dim)
return { drawCount: n, positions, radii, groups, delta, expandedBox, dim } return { drawCount: n, positions, radii, groups, delta, expandedBox, dim }
} }
...@@ -309,8 +309,7 @@ function getTexture2dSize(maxTexSize: number, gridDim: Vec3) { ...@@ -309,8 +309,7 @@ function getTexture2dSize(maxTexSize: number, gridDim: Vec3) {
} }
async function fieldFromTexture2d(ctx: WebGLContext, texture: Texture, dim: Vec3) { async function fieldFromTexture2d(ctx: WebGLContext, texture: Texture, dim: Vec3) {
console.log('isWebGL2', isWebGL2(ctx.gl)) // console.time('fieldFromTexture2d')
console.time('fieldFromTexture2d')
const { framebufferCache } = ctx const { framebufferCache } = ctx
const [ dx, dy, dz ] = dim const [ dx, dy, dz ] = dim
const { width, height } = texture const { width, height } = texture
...@@ -348,7 +347,7 @@ async function fieldFromTexture2d(ctx: WebGLContext, texture: Texture, dim: Vec3 ...@@ -348,7 +347,7 @@ async function fieldFromTexture2d(ctx: WebGLContext, texture: Texture, dim: Vec3
tmpCol++ tmpCol++
} }
console.timeEnd('fieldFromTexture2d') // console.timeEnd('fieldFromTexture2d')
return { field, idField } return { field, idField }
} }
\ 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