Skip to content

Correct streamtube positions and colouring #4271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Oct 23, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"gl-scatter3d": "^1.2.2",
"gl-select-box": "^1.0.3",
"gl-spikes2d": "^1.0.2",
"gl-streamtube3d": "^1.3.1",
"gl-streamtube3d": "git://github.com/gl-vis/gl-streamtube3d.git#82a0dd7a8dc601f48ed4afdc5a3e40394b758deb",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"gl-surface3d": "^1.4.6",
"gl-text": "^1.1.8",
"glslify": "^7.0.0",
Expand Down
30 changes: 30 additions & 0 deletions src/traces/streamtube/calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,19 @@ module.exports = function calc(gd, trace) {
var zMax = -Infinity;
var zMin = Infinity;

var gridFill = '';
var filledX;
var filledY;
var filledZ;
var prevX;
var prevY;
var prevZ;
if(len) {
prevX = x[0];
prevY = y[0];
prevZ = z[0];
}

for(i = 0; i < len; i++) {
var xx = x[i];
xMax = Math.max(xMax, xx);
Expand All @@ -68,7 +81,23 @@ module.exports = function calc(gd, trace) {
var zz = z[i];
zMax = Math.max(zMax, zz);
zMin = Math.min(zMin, zz);

if(!filledX && xx !== prevX) {
filledX = true;
gridFill += 'x';
} else if(!filledY && yy !== prevY) {
filledY = true;
gridFill += 'y';
} else if(!filledZ && zz !== prevZ) {
filledZ = true;
gridFill += 'z';
}
}
// fill if not filled - case of having 1 dimension
if(!filledX) gridFill += 'x';
if(!filledY) gridFill += 'y';
if(!filledZ) gridFill += 'z';

for(i = 0; i < slen; i++) {
var sx = startx[i];
xMax = Math.max(xMax, sx);
Expand All @@ -89,4 +118,5 @@ module.exports = function calc(gd, trace) {
trace._xbnds = [xMin, xMax];
trace._ybnds = [yMin, yMax];
trace._zbnds = [zMin, zMax];
trace._gridFill = gridFill;
};
1 change: 1 addition & 0 deletions src/traces/streamtube/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ function convert(scene, trace) {
var meshz = toDataCoords(valsz, 'zaxis');

tubeOpts.meshgrid = [meshx, meshy, meshz];
tubeOpts.gridFill = trace._gridFill;

var slen = trace._slen;
if(slen) {
Expand Down
Binary file modified test/image/baselines/gl3d_coloraxes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl3d_cone-with-streamtube.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/image/baselines/gl3d_directions-cone1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/image/baselines/gl3d_directions-cone2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl3d_reversescale.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl3d_streamtube-first.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl3d_streamtube-simple.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl3d_streamtube-thin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl3d_streamtube-wind.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl3d_streamtube_reversed_ranges.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
167 changes: 167 additions & 0 deletions test/image/mocks/gl3d_directions-cone1.json

Large diffs are not rendered by default.

167 changes: 167 additions & 0 deletions test/image/mocks/gl3d_directions-cone2.json

Large diffs are not rendered by default.

197 changes: 197 additions & 0 deletions test/image/mocks/gl3d_directions-streamtube1.json

Large diffs are not rendered by default.

197 changes: 197 additions & 0 deletions test/image/mocks/gl3d_directions-streamtube2.json

Large diffs are not rendered by default.

54 changes: 27 additions & 27 deletions test/jasmine/tests/streamtube_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,19 @@ describe('Test streamtube autorange', function() {

Plotly.plot(gd, fig).then(function() {
_assertAxisRanges('base',
[-5.36, 5.525], [-3.73, 5.44], [-3.55, 3.78]
[-5.36, 5.55], [-6.36, 3.90], [-3.58, 3.95]
);
return Plotly.restyle(gd, 'sizeref', 10);
})
.then(function() {
_assertAxisRanges('with large sizeref',
[-9.86, 10.02], [-8.23, 9.935], [-8.045, 8.28]
[-9.86, 10.05], [-10.86, 8.39], [-8.08, 8.45]
);
return Plotly.restyle(gd, 'sizeref', 0.1);
})
.then(function() {
_assertAxisRanges('with small sizeref',
[-5.32, 5.48], [-3.69, 5.39], [-3.50, 3.73]
[-5.32, 5.51], [-6.32, 3.85], [-3.54, 3.91]
);
})
.catch(failTest)
Expand Down Expand Up @@ -157,8 +157,8 @@ describe('Test streamtube starting positions defaults:', function() {

Plotly.plot(gd, mock).then(function() {
_assert({
positionsLength: 6144,
cellsLength: 2048
positionsLength: 6288,
cellsLength: 2096
});
})
.catch(failTest)
Expand All @@ -179,8 +179,8 @@ describe('Test streamtube starting positions defaults:', function() {
it('@gl should take middle pt if mesh vector has length 2', function(done) {
Plotly.plot(gd, makeFigure(3, 3, 2)).then(function() {
_assert({
positionsLength: 1200,
cellsLength: 400
positionsLength: 1296,
cellsLength: 432
});
})
.catch(failTest)
Expand Down Expand Up @@ -343,10 +343,10 @@ describe('Test streamtube hover', function() {
.then(function() {
assertHoverLabelContent({
nums: [
'x: 2.250878',
'y: 0.5866609',
'z: 1.091627',
'norm: 2.06'
'x: 2.191782',
'y: 0.5538867',
'z: 1.057623',
'norm: 2.11'
].join('\n')
});

Expand All @@ -358,9 +358,9 @@ describe('Test streamtube hover', function() {
.then(function() {
assertHoverLabelContent({
nums: [
'u: 1.847686',
'v: 0.7303133',
'w: 0.1693927'
'u: 1.909297',
'v: 0.7453796',
'w: 0.09330833'
].join('\n')
});
return Plotly.restyle(gd, 'hoverinfo', 'divergence');
Expand All @@ -369,7 +369,7 @@ describe('Test streamtube hover', function() {
.then(_hover)
.then(delay(20))
.then(function() {
assertHoverLabelContent({nums: 'divergence: 0.465'});
assertHoverLabelContent({nums: 'divergence: 0.467'});
return Plotly.restyle(gd, {
hoverinfo: 'text',
text: '!SCALAR TX!'
Expand Down Expand Up @@ -416,10 +416,10 @@ describe('Test streamtube hover', function() {
.then(function() {
assertHoverLabelContent({
nums: [
'x: 2.059149',
'y: 0.5083682',
'z: 1.074042',
'norm: 2.07'
'x: 2.063244',
'y: 0.502517',
'z: 1.051367',
'norm: 2.12'
].join('\n'),
name: 'TUBE!'
});
Expand All @@ -428,7 +428,7 @@ describe('Test streamtube hover', function() {
})
.then(function() {
assertHoverLabelContent({
nums: '∇·F = 0.465',
nums: '∇·F = 0.467',
name: 'TUBE'
});
})
Expand Down Expand Up @@ -461,15 +461,15 @@ describe('Test streamtube hover', function() {
if(ptData) {
expect(Object.keys(ptData).length).toBe(12, 'key cnt');

expect(ptData.tubex).toBeCloseTo(2.25, TOL, 'tubex');
expect(ptData.tubey).toBeCloseTo(0.59, TOL, 'tubey');
expect(ptData.tubez).toBeCloseTo(1.09, TOL, 'tubez');
expect(ptData.tubex).toBeCloseTo(2.19, TOL, 'tubex');
expect(ptData.tubey).toBeCloseTo(0.55, TOL, 'tubey');
expect(ptData.tubez).toBeCloseTo(1.06, TOL, 'tubez');

expect(ptData.tubeu).toBeCloseTo(1.85, TOL, 'tubeu');
expect(ptData.tubev).toBeCloseTo(0.73, TOL, 'tubev');
expect(ptData.tubew).toBeCloseTo(0.17, TOL, 'tubew');
expect(ptData.tubeu).toBeCloseTo(1.91, TOL, 'tubeu');
expect(ptData.tubev).toBeCloseTo(0.74, TOL, 'tubev');
expect(ptData.tubew).toBeCloseTo(0.09, TOL, 'tubew');

expect(ptData.norm).toBeCloseTo(2.06, TOL, 'norm');
expect(ptData.norm).toBeCloseTo(2.11, TOL, 'norm');
expect(ptData.divergence).toBeCloseTo(0.47, TOL, 'divergence');

expect(ptData.curveNumber).toBe(0, 'curve number');
Expand Down