Skip to content

Commit

Permalink
VTK layout continued
Browse files Browse the repository at this point in the history
  • Loading branch information
xavArtley committed Jan 23, 2020
1 parent 8f87cfa commit f7c0d13
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 26 deletions.
21 changes: 13 additions & 8 deletions panel/models/vtk/vtk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class VTKPlotView extends VTKHTMLBoxView {
protected _orientationWidget: any
protected _widgetManager: any
protected _axes: any
protected _axes_initialized: boolean = false

connect_signals(): void {
super.connect_signals()
Expand Down Expand Up @@ -47,16 +48,20 @@ export class VTKPlotView extends VTKHTMLBoxView {
})
}

render(): void {
super.render()
this._axes_initialized = false
this._plot()
this._vtk_renwin.getRenderer().getActiveCamera().onModified(() => this._get_camera_state())
this._remove_default_key_binding()
this.model.renderer_el = this._vtk_renwin
}

after_layout(): void {
if(!this._initialized){
if (!this._axes_initialized) {
this._render_axes_canvas()
this._plot()
this._vtk_renwin.getRenderer().getActiveCamera().onModified(() => this._get_camera_state())
this._remove_default_key_binding()
this.model.renderer_el = this._vtk_renwin
this._initialized = true
this._axes_initialized = true
}
super.after_layout()
}

_create_orientation_widget(): void {
Expand Down Expand Up @@ -235,7 +240,7 @@ export class VTKPlotView extends VTKHTMLBoxView {
this._create_orientation_widget()
if (this._axes == null && this.model.axes)
this._set_axes()
this._set_camera_state()
this._set_camera_state()
}, 100)
sceneImporter.setUrl('index.json')
sceneImporter.onReady(fn)
Expand Down
12 changes: 9 additions & 3 deletions panel/models/vtk/vtk_layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import {vtkns} from "./vtk_utils"
export class VTKHTMLBoxView extends PanelHTMLBoxView{
protected _vtk_container: HTMLDivElement
protected _vtk_renwin: any
protected _initialized: boolean = false

render(): void{
render(): void {
super.render()
this._vtk_container = div()
set_size(this._vtk_container, this.model)
Expand All @@ -17,6 +16,13 @@ export class VTKHTMLBoxView extends PanelHTMLBoxView{
rootContainer: this.el,
container: this._vtk_container
})
this._initialized = false
}

after_layout(): void {
super.after_layout()
const {width, height} = this._vtk_container.getBoundingClientRect()
const openGLRenderWindow = this._vtk_renwin.getOpenGLRenderWindow()
openGLRenderWindow.setSize(Math.floor(width), Math.floor(height))
this._vtk_renwin.getRenderWindow().render()
}
}
26 changes: 11 additions & 15 deletions panel/models/vtk/vtkvolume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,17 @@ export class VTKVolumePlotView extends VTKHTMLBoxView {
})
}

after_layout(): void{
if(!this._initialized){
this._controllerWidget = vtk.Interaction.UI.vtkVolumeController.newInstance({
size: [400, 150],
rescaleColorMap: false,
})
this._controllerWidget.setContainer(this.el)
this._vtk_renwin.getRenderWindow().getInteractor()
this._vtk_renwin.getRenderWindow().getInteractor().setDesiredUpdateRate(45)
this._plot()
this._vtk_renwin.getRenderer().resetCamera()
this._vtk_renwin.getRenderWindow().render()
this._initialized = true
}
super.after_layout()
render(): void {
super.render()
this._controllerWidget = vtk.Interaction.UI.vtkVolumeController.newInstance({
size: [400, 150],
rescaleColorMap: false,
})
this._controllerWidget.setContainer(this.el)
this._vtk_renwin.getRenderWindow().getInteractor()
this._vtk_renwin.getRenderWindow().getInteractor().setDesiredUpdateRate(45)
this._plot()
this._vtk_renwin.getRenderer().resetCamera()
}

_create_source(): any{
Expand Down

0 comments on commit f7c0d13

Please sign in to comment.