Skip to content
This repository has been archived by the owner on Sep 10, 2021. It is now read-only.

Commit

Permalink
ENH: refs #1030. Refactor to support vtkWeb API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
zachmullen committed Oct 11, 2013
1 parent a10a36b commit 754baed
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 38 deletions.
19 changes: 10 additions & 9 deletions modules/pvw/apps/midas.py
Expand Up @@ -15,7 +15,9 @@
from autobahn.wamp import exportRpc

# import paraview modules.
from paraview import simple, web, servermanager, web_helper, paraviewweb_wamp, paraviewweb_protocols
from paraview import simple, servermanager
from paraview.web import paraviewweb_protocols, paraviewweb_wamp
from vtk.web import server

# Setup global variables
timesteps = []
Expand All @@ -36,7 +38,7 @@ def initView(width, height):


# This class defines the exposed RPC methods for the midas application
class MidasApp(paraviewweb_wamp.ServerProtocol):
class MidasApp(paraviewweb_wamp.PVServerProtocol):
DISTANCE_FACTOR = 2.0
CONTOUR_LINE_WIDTH = 2.0

Expand All @@ -61,10 +63,10 @@ def initialize(self):
global authKey

# Bring used components
self.registerParaViewWebProtocol(paraviewweb_protocols.ParaViewWebMouseHandler())
self.registerParaViewWebProtocol(paraviewweb_protocols.ParaViewWebViewPort())
self.registerParaViewWebProtocol(paraviewweb_protocols.ParaViewWebViewPortImageDelivery())
self.registerParaViewWebProtocol(paraviewweb_protocols.ParaViewWebViewPortGeometryDelivery())
self.registerVtkWebProtocol(paraviewweb_protocols.ParaViewWebMouseHandler())
self.registerVtkWebProtocol(paraviewweb_protocols.ParaViewWebViewPort())
self.registerVtkWebProtocol(paraviewweb_protocols.ParaViewWebViewPortImageDelivery())
self.registerVtkWebProtocol(paraviewweb_protocols.ParaViewWebViewPortGeometryDelivery())

# Update authentication key to use
self.updateSecret(authKey)
Expand Down Expand Up @@ -174,7 +176,6 @@ def loadData(self):
simple.SetActiveSource(self.srcObj)
simple.ResetCamera()
simple.Render()
return self.srcObj

@exportRpc("showSphere")
def showSphere(self, params):
Expand Down Expand Up @@ -442,7 +443,7 @@ def extractSubgrid(self, bounds):
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Midas+ParaViewWeb application")
web.add_arguments(parser)
server.add_arguments(parser)
parser.add_argument("--data-dir", default=os.getcwd(),
help="path to data directory", dest="path")
parser.add_argument("--width", default=575,
Expand All @@ -457,4 +458,4 @@ def extractSubgrid(self, bounds):
height = args.height

initView(width, height)
web.start_webserver(options=args, protocol=MidasApp)
server.start_webserver(options=args, protocol=MidasApp)
12 changes: 6 additions & 6 deletions modules/pvw/public/js/paraview/paraview.common.js
Expand Up @@ -24,7 +24,7 @@ midas.pvw.setupBgColor = function () {
onSubmit: function(hsb, hex, rgb, el) {
midas.pvw.bgColor = rgb;
container.dialog('close');
pv.connection.session.call('pv:changeBgColor', [rgb.r / 255.0, rgb.g / 255.0, rgb.b / 255.0])
pv.connection.session.call('vtk:changeBgColor', [rgb.r / 255.0, rgb.g / 255.0, rgb.b / 255.0])
.then(pv.viewport.render);
}
});
Expand Down Expand Up @@ -77,15 +77,15 @@ midas.pvw._commonStart = function (text) {
* This function also sets up the
*/
midas.pvw.loadData = function () {
paraview.connect(pv.connection, function(conn) {
vtkWeb.connect(pv.connection, function(conn) {
pv.connection = conn;
pv.viewport = paraview.createViewport(pv.connection);
pv.viewport = vtkWeb.createViewport(pv.connection);
pv.viewport.bind('#renderercontainer');

$('#renderercontainer').show();

midas.pvw.waitingDialog('Loading data into scene...');
pv.connection.session.call('pv:loadData')
pv.connection.session.call('vtk:loadData')
.then(midas.pvw.dataLoaded)
.otherwise(midas.pvw.rpcFailure);
}, function(code, msg) {
Expand All @@ -112,7 +112,7 @@ midas.pvw.testIdle = function () {
*/
midas.pvw.stopSession = function () {
if(pv.connection) {
paraview.stop(pv.connection);
vtkWeb.stop(pv.connection);
pv.connection = null;
}
if(midas.pvw.idleInterval) {
Expand Down Expand Up @@ -158,7 +158,7 @@ midas.pvw.waitingDialog = function(text) {
};

$(window).load(function () {
if(paraview) {
if(vtkWeb) {
if(!json.pvw.meshIds) {
json.pvw.meshIds = [];
}
Expand Down
4 changes: 2 additions & 2 deletions modules/pvw/public/js/paraview/paraview.share.js
Expand Up @@ -19,9 +19,9 @@ $(window).load(function () {
secret: json.pvw.instance.secret
};

paraview.connect(pv.connection, function(conn) {
vtkWeb.connect(pv.connection, function(conn) {
pv.connection = conn;
pv.viewport = paraview.createViewport(pv.connection);
pv.viewport = vtkWeb.createViewport(pv.connection);
pv.viewport.bind('#renderercontainer');

$('#renderercontainer').show();
Expand Down
11 changes: 5 additions & 6 deletions modules/pvw/public/js/paraview/paraview.slice.js
@@ -1,4 +1,3 @@
var paraview;
var midas = midas || {};
midas.pvw = midas.pvw || {};
midas.pvw.sliceMode = 'XY Plane'; //Initial slice plane
Expand Down Expand Up @@ -42,7 +41,7 @@ midas.pvw.dataLoaded = function (resp) {
midas.pvw.mainProxy = resp;
pv.viewport.render();
midas.pvw.waitingDialog('Starting slice rendering...');
pv.connection.session.call('pv:sliceRender', midas.pvw.sliceMode)
pv.connection.session.call('vtk:sliceRender', midas.pvw.sliceMode)
.then(midas.pvw.sliceRenderStarted)
.otherwise(midas.pvw.rpcFailure);
};
Expand Down Expand Up @@ -123,7 +122,7 @@ midas.pvw.updateWindowInfo = function (values) {

/** Make the actual request to PVWeb to set the window */
midas.pvw.changeWindow = function (values) {
pv.connection.session.call('pv:changeWindow', [values[0], 0.0, 0.0, 0.0, values[1], 1.0, 1.0, 1.0])
pv.connection.session.call('vtk:changeWindow', [values[0], 0.0, 0.0, 0.0, values[1], 1.0, 1.0, 1.0])
.then(function () {
pv.viewport.render();
midas.pvw.releaseUpdateLock();
Expand All @@ -137,7 +136,7 @@ midas.pvw.changeSlice = function (slice, degradeQuality) {
midas.pvw.slice = slice;

if(midas.pvw.acquireUpdateLock()) {
pv.connection.session.call('pv:changeSlice', slice)
pv.connection.session.call('vtk:changeSlice', slice)
.then(function (resp) {
if(degradeQuality) {
pv.viewport.render(null, {quality: 50});
Expand Down Expand Up @@ -230,7 +229,7 @@ midas.pvw.pointSelectMode = function () {
point: [x, y, z],
color: [1.0, 0.0, 0.0]
};
pv.connection.session.call('pv:showSphere', params)
pv.connection.session.call('vtk:showSphere', params)
.then(pv.viewport.render)
.otherwise(midas.pvw.rpcFailure);
});
Expand Down Expand Up @@ -305,7 +304,7 @@ midas.pvw.setSliceMode = function (sliceMode) {
return; //nothing to do, already in this mode
}
midas.pvw.sliceMode = sliceMode;
pv.connection.session.call('pv:setSliceMode', midas.pvw.sliceMode)
pv.connection.session.call('vtk:setSliceMode', midas.pvw.sliceMode)
.then(midas.pvw.sliceModeChanged)
.otherwise(midas.pvw.rpcFailure);
};
Expand Down
9 changes: 4 additions & 5 deletions modules/pvw/public/js/paraview/paraview.surface.js
Expand Up @@ -12,10 +12,9 @@ midas.pvw.start = function () {

/** Callback for once the loadData RPC has returned */
midas.pvw.dataLoaded = function (resp) {
midas.pvw.mainProxy = resp;
pv.viewport.render();
midas.pvw.waitingDialog('Starting surface rendering...');
pv.connection.session.call('pv:surfaceRender')
pv.connection.session.call('vtk:surfaceRender')
.then(midas.pvw.surfaceRenderStarted)
.otherwise(midas.pvw.rpcFailure);
};
Expand All @@ -31,7 +30,7 @@ midas.pvw.surfaceRenderStarted = function (resp) {
midas.pvw.renderer = $(this).val();
pv.connection.renderer = midas.pvw.renderer;
pv.viewport.unbind();
pv.viewport = paraview.createViewport(pv.connection);
pv.viewport = vtkWeb.createViewport(pv.connection);
pv.viewport.bind('#renderercontainer');
pv.viewport.render();
}
Expand All @@ -48,7 +47,7 @@ midas.pvw.populateInfo = function () {
};

midas.pvw.resetCamera = function () {
pv.connection.session.call('pv:cameraPreset', '+x')
pv.connection.session.call('vtk:cameraPreset', '+x')
.then(function () {
if(midas.pvw.renderer == 'webgl') {
pv.viewport.invalidateScene();
Expand All @@ -59,7 +58,7 @@ midas.pvw.resetCamera = function () {
};

midas.pvw.toggleEdges = function () {
pv.connection.session.call('pv:toggleEdges')
pv.connection.session.call('vtk:toggleEdges')
.then(function () {
if(midas.pvw.renderer == 'webgl') {
pv.viewport.invalidateScene();
Expand Down
12 changes: 6 additions & 6 deletions modules/pvw/public/js/paraview/paraview.volume.js
@@ -1,4 +1,4 @@
var paraview, pv;
var pv;
var midas = midas || {};
midas.pvw = midas.pvw || {};

Expand Down Expand Up @@ -53,7 +53,7 @@ midas.pvw.renderSubgrid = function (bounds) {
var container = $('div.MainDialog');
container.find('img.extractInProgress').show();
container.find('button.extractSubgridApply').attr('disabled', 'disabled');
pv.connection.session.call('pv:extractSubgrid', bounds)
pv.connection.session.call('vtk:extractSubgrid', bounds)
.then(function (resp) {
pv.viewport.render();
container.find('img.extractInProgress').hide();
Expand Down Expand Up @@ -250,7 +250,7 @@ midas.pvw.setupColorMapping = function () {
parseFloat(tokens[3]) / 255.0);
});
midas.pvw.colorMap = colorMap;
pv.connection.session.call('pv:updateColorMap', colorMap)
pv.connection.session.call('vtk:updateColorMap', colorMap)
.then(function () {
pv.viewport.render();
})
Expand Down Expand Up @@ -350,7 +350,7 @@ midas.pvw.applySofCurve = function () {
}

midas.pvw.sof = points;
pv.connection.session.call('pv:updateSof', points)
pv.connection.session.call('vtk:updateSof', points)
.then(function () {
pv.viewport.render();
})
Expand Down Expand Up @@ -523,7 +523,7 @@ midas.pvw.dataLoaded = function (resp) {
midas.pvw.mainProxy = resp;
pv.viewport.render();
midas.pvw.waitingDialog('Starting volume rendering...');
pv.connection.session.call('pv:volumeRender')
pv.connection.session.call('vtk:volumeRender')
.then(midas.pvw.vrStarted)
.otherwise(midas.pvw.rpcFailure);
};
Expand Down Expand Up @@ -552,7 +552,7 @@ midas.pvw.vrStarted = function (resp) {
/** Bind the renderer overlay buttons */
midas.pvw.setupOverlay = function () {
$('button.cameraPreset').click(function () {
pv.connection.session.call('pv:cameraPreset', $(this).attr('type'))
pv.connection.session.call('vtk:cameraPreset', $(this).attr('type'))
.then(pv.viewport.render())
.otherwise(midas.pvw.rpcFailure);
});
Expand Down
2 changes: 1 addition & 1 deletion modules/pvw/views/paraview/share.phtml
Expand Up @@ -15,7 +15,7 @@ PURPOSE. See the above copyright notices for more information.
<?php
$this->headScript()->appendFile($this->moduleWebroot.'/public/import/ext/js-core/autobahn.min.js');
$this->headScript()->appendFile($this->moduleWebroot.'/public/import/ext/js-core/jquery.hammer.min.js');
$this->headScript()->appendFile($this->moduleWebroot.'/public/import/lib/js/paraview-all.js');
$this->headScript()->appendFile($this->moduleWebroot.'/public/import/lib/js/vtkweb-all.min.js');

$this->headScript()->appendFile($this->coreWebroot.'/public/js/layout/midas.progress.js');
$this->headScript()->appendFile($this->moduleWebroot.'/public/js/paraview/paraview.share.js');
Expand Down
2 changes: 1 addition & 1 deletion modules/pvw/views/paraview/slice.phtml
Expand Up @@ -15,7 +15,7 @@ PURPOSE. See the above copyright notices for more information.

<?php
$this->headScript()->appendFile($this->moduleWebroot.'/public/import/ext/js-core/autobahn.min.js');
$this->headScript()->appendFile($this->moduleWebroot.'/public/import/lib/js/paraview-all.js');
$this->headScript()->appendFile($this->moduleWebroot.'/public/import/lib/js/vtkweb-all.min.js');

$this->headScript()->appendFile($this->moduleWebroot.'/public/js/paraview/paraview.common.js');
$this->headScript()->appendFile($this->moduleWebroot.'/public/js/paraview/paraview.slice.js');
Expand Down
2 changes: 1 addition & 1 deletion modules/pvw/views/paraview/surface.phtml
Expand Up @@ -18,7 +18,7 @@ PURPOSE. See the above copyright notices for more information.
$this->headScript()->appendFile($this->moduleWebroot.'/public/import/ext/js-core/autobahn.min.js');
$this->headScript()->appendFile($this->moduleWebroot.'/public/import/ext/js-core/gl-matrix-min.js');
$this->headScript()->appendFile($this->moduleWebroot.'/public/import/ext/js-core/jquery.hammer.min.js');
$this->headScript()->appendFile($this->moduleWebroot.'/public/import/lib/js/paraview-all.js');
$this->headScript()->appendFile($this->moduleWebroot.'/public/import/lib/js/vtkweb-all.min.js');

$this->headScript()->appendFile($this->moduleWebroot.'/public/js/paraview/paraview.common.js');
$this->headScript()->appendFile($this->moduleWebroot.'/public/js/paraview/paraview.surface.js');
Expand Down
2 changes: 1 addition & 1 deletion modules/pvw/views/paraview/volume.phtml
Expand Up @@ -19,7 +19,7 @@ PURPOSE. See the above copyright notices for more information.
<?php
$this->headScript()->appendFile($this->moduleWebroot.'/public/import/ext/js-core/autobahn.min.js');
$this->headScript()->appendFile($this->moduleWebroot.'/public/import/ext/js-core/jquery.hammer.min.js');
$this->headScript()->appendFile($this->moduleWebroot.'/public/import/lib/js/paraview-all.js');
$this->headScript()->appendFile($this->moduleWebroot.'/public/import/lib/js/vtkweb-all.min.js');

$this->headScript()->appendFile($this->coreWebroot.'/public/js/jquery/jquery.spinbox.js');
$this->headScript()->appendFile($this->coreWebroot.'/public/js/jquery/jquery.jqplot.min.js');
Expand Down

0 comments on commit 754baed

Please sign in to comment.