Commit 9b84afab authored by Scott Wittenburg's avatar Scott Wittenburg
Browse files

Add new protocol and web test to get lut image as Base64. Moves VTK.

parent 6ce5d492
......@@ -276,6 +276,10 @@ FUNCTION(add_pvweb_tests prefix)
--test-image-file-name ${test_image_file_name}
)
set_tests_properties(${test_name} PROPERTIES LABELS "PARAVIEW")
if (${ACT_APP}-${short_script_name}_FORCE_SERIAL)
set_tests_properties("${test_name}" PROPERTIES RUN_SERIAL ON)
message(STATUS "Running in serial \"${test_name}\"")
endif()
MATH(EXPR pvw_port_number "${pvw_port_number}+1")
endwhile()
endwhile()
......
Subproject commit ca1e58b1a32f661a320c5faf6eb69aedefae2e8e
Subproject commit f26b8cf3b3ecedcc2dfa99b0c97cf7b12712e908
......@@ -1210,6 +1210,52 @@ function ParaViewWebTestFunctions(connection) {
'success': false,
'message': error });
}
},
/**
* This function exercises the following protocol rpc methods:
*
* 'pv.color.manager.lut.image.get'
*
* This function checks that the correct Base64 image is returned
* assuming the Wavelet and default color map.
*/
protocolGetLutImageTests: function(testName, resultCallback) {
var s = connection.session;
try {
var waveletArgs = ['Wavelet', -1];
s.call('pv.proxy.manager.create', waveletArgs).then(function(waveletProxy) {
var waveletPid = waveletProxy['id'];
s.call('pv.test.repr.get', [waveletPid]).then(function(reprStruct) {
var reprId = reprStruct['reprProxyId'],
args = [reprId, 'ARRAY'],
kwargs = { 'arrayLocation': 'POINTS', 'arrayName': 'RTData'};
s.call('pv.color.manager.color.by', args, kwargs).then(function(empty) {
s.call('pv.color.manager.lut.image.get', [reprId, 10]).then(function(lutResult) {
var m = "protocolGetLutImageTests succeeded",
success = true;
if (lutResult.image.indexOf("iVBOR") !== 0) {
m = "protocolGetLutImageTests failed due problem with returned Base64 image " +
"string (lutResult.image = '" + lutResult.image + "')";
success = false;
}
pipelineCleanup();
resultCallback({ 'name': testName,
'success': success,
'message': m });
}, function(e) { protocolError(e, testName, resultCallback); });
}, function(e) { protocolError(e, testName, resultCallback); });
}, function(e) { protocolError(e, testName, resultCallback); });
}, function(e) { protocolError(e, testName, resultCallback); });
} catch(error) {
console.log("Caught exception running test sequence for protocolGetLutImageTests");
console.log(error);
pipelineCleanup();
resultCallback({ 'name': testName,
'success': false,
'message': error });
}
}
};
}
......@@ -83,6 +83,9 @@ set(TESTAPP_WEB_TESTS_WITH_CHROME
${pv_pymodule_build_dir}/paraview/web/test/test_pv_web_testapp_all.py
)
# Make sure any tests that pop up a browser are run in serial
set (TestApp-all_FORCE_SERIAL TRUE)
add_pvweb_tests("pvweb"
APP TestApp
COMMAND $<TARGET_FILE:pvpython>
......
......@@ -20,6 +20,10 @@ from decorators import *
from vtkWebCorePython import vtkWebInteractionEvent
from vtk import vtkImageData
from vtk import vtkUnsignedCharArray
from vtk import vtkDataEncoder
# Needed for:
# vtkSMPVRepresentationProxy
# vtkSMTransferFunctionProxy
......@@ -794,6 +798,41 @@ class ParaViewWebColorManager(ParaViewWebProtocol):
simple.Render();
# RpcName: getLutImage => pv.color.manager.lut.image.get
@exportRpc("pv.color.manager.lut.image.get")
def getLutImage(self, representation, numSamples, customRange=None):
repProxy = self.mapIdToProxy(representation)
lut = repProxy.LookupTable.GetClientSideObject()
dataRange = customRange
if not dataRange:
dataRange = lut.GetRange()
delta = (dataRange[1] - dataRange[0]) / float(numSamples)
colorArray = vtkUnsignedCharArray()
colorArray.SetNumberOfComponents(3)
colorArray.SetNumberOfTuples(numSamples)
rgb = [ 0, 0, 0 ]
for i in range(numSamples):
lut.GetColor(dataRange[0] + float(i) * delta, rgb)
r = int(round(rgb[0] * 255))
g = int(round(rgb[1] * 255))
b = int(round(rgb[2] * 255))
colorArray.SetTuple3(i, r, g, b)
# Add the color array to an image data
imgData = vtkImageData()
imgData.SetDimensions(numSamples, 1, 1)
aIdx = imgData.GetPointData().SetScalars(colorArray)
# Use the vtk data encoder to base-64 encode the image as png, using no compression
encoder = vtkDataEncoder()
b64Str = encoder.EncodeAsBase64Png(imgData, 0)
return { 'range': dataRange, 'image': b64Str }
# RpcName: setSurfaceOpacity => pv.color.manager.surface.opacity.set
@exportRpc("pv.color.manager.surface.opacity.set")
def setSurfaceOpacity(self, representation, enabled):
......
Supports Markdown
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