Commit e3944687 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit Committed by Kitware Robot
Browse files

Merge topic 'pvweb-loadsave-state-and-save-data' into pv-master

5337c315 Changes to viewports supporting capturing screenshots for pvweb.
parents 62e2fc14 5337c315
......@@ -231,6 +231,13 @@
}
}).bind('resetViewId', function(e){
options.view = -1;
}).bind('captureRenderedImage', function(e){
if(renderer.hasClass('active')){
$(container).parent().trigger({
type: 'captured-screenshot-ready',
imageData: bgImage.src
});
}
}).bind('render', function(e){
if(renderer.hasClass('active')){
var opts = e.options,
......
......@@ -645,6 +645,16 @@
rendererContainer.trigger('resetViewId');
},
/**
* Ask the concrete renderer to generate an image and trigger its own
* event when the image is ready.
*
* @member vtkWeb.Viewport
*/
captureScreenImage: function () {
rendererContainer.trigger('captureRenderedImage');
},
/**
* Attach viewport to a DOM element
*
......
......@@ -129,6 +129,7 @@
originalMouseMove = document.onmousemove,
originalContextMenu = document.oncontextmenu,
m_background = null;
screenImage = null,
m_vglActors = {}
// Helper functions -------------------------------------------------
......@@ -215,7 +216,7 @@
actors.invalid = false;
// Redraw the scene
drawScene();
drawScene(false);
} catch(error) {
console.log(error);
}
......@@ -227,7 +228,16 @@
// ------------------------------------------------------------------
function drawScene() {
function render(saveScreenOnRender) {
m_canvas3D.width = m_rendererAttrs.width();
m_canvas3D.height = m_rendererAttrs.height();
m_viewer = m_vglVtkReader.updateCanvas(m_canvas3D);
drawScene(saveScreenOnRender);
}
// ------------------------------------------------------------------
function drawScene(saveScreenOnRender) {
var layer;
try {
......@@ -248,6 +258,10 @@
m_viewer.render();
if (saveScreenOnRender === true) {
screenImage = m_canvas3D.toDataURL();
}
numObjects = m_vglVtkReader.numObjects();
// Update frame rate
......@@ -310,7 +324,7 @@
m_objectHandler.fetchMissingObjects(fetchObject, m_sceneJSON);
// Draw scene
drawScene();
drawScene(false);
} catch(error) {
console.log(error);
}
......@@ -358,10 +372,15 @@
}
}).bind('render', function(){
if(m_rendererAttrs.hasClass('active')){
m_canvas3D.width = m_rendererAttrs.width();
m_canvas3D.height = m_rendererAttrs.height();
m_viewer = m_vglVtkReader.updateCanvas(m_canvas3D);
drawScene();
render(false);
}
}).bind('captureRenderedImage', function(e){
if (m_rendererAttrs.hasClass('active')) {
render(true);
$(m_container).parent().trigger({
type: 'captured-screenshot-ready',
imageData: screenImage
});
}
}).bind('resetViewId', function(e){
m_options.view = -1;
......
......@@ -972,6 +972,7 @@
canvas2D = GLOBAL.document.createElement('canvas'),
canvas3D = GLOBAL.document.createElement('canvas'),
ctx2d = canvas2D.getContext('2d'),
screenImage = null,
gl = canvas3D.getContext("experimental-webgl") || canvas3D.getContext("webgl"),
shaderProgram = gl.createProgram(),
pointShaderProgram = gl.createProgram(),
......@@ -1053,7 +1054,7 @@
objectHandler.registerObject(newObject);
// Redraw the scene
drawScene();
drawScene(false);
} catch(error) {
console.log(error);
}
......@@ -1065,7 +1066,7 @@
// ------------------------------------------------------------------
function drawScene() {
function drawScene(saveScreenOnRender) {
try {
if (sceneJSON === null || cameraLayerZero === null){
return;
......@@ -1142,6 +1143,10 @@
gl.disable(gl.BLEND);
}
if (saveScreenOnRender === true) {
screenImage = renderingContext.gl.canvas.toDataURL();
}
// Update frame rate
container.trigger({
type: 'stats',
......@@ -1216,7 +1221,7 @@
objectHandler.fetchMissingObjects(fetchObject);
// Draw scene
drawScene();
drawScene(false);
} catch(error) {
console.log(error);
}
......@@ -1234,10 +1239,18 @@
}
}).bind('render', function(){
if(renderer.hasClass('active')){
drawScene();
drawScene(false);
}
}).bind('resetViewId', function(e){
options.view = -1;
}).bind('captureRenderedImage', function(e){
if (renderer.hasClass('active')) {
drawScene(true);
$(container).parent().trigger({
type: 'captured-screenshot-ready',
imageData: screenImage
});
}
}).bind('mouse', function(event){
if(renderer.hasClass('active')){
event.preventDefault();
......@@ -1285,7 +1298,7 @@
}
}
drawScene();
drawScene(false);
pushCameraState();
}
}
......@@ -1306,7 +1319,7 @@
// Ready to render data
fetchScene();
drawScene();
drawScene(false);
}
});
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment