Skip to content
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

Volume - new gl3d trace #3488

Merged
merged 48 commits into from
Apr 8, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
3a39fd8
adding volume4d new trace
archmoj Jan 28, 2019
e3a59da
opacityscale as 2d array
archmoj Jan 28, 2019
c138d9d
correct volume baselines
archmoj Jan 28, 2019
5dbe037
volume4d > volume
archmoj Jan 29, 2019
f141868
new baselines
archmoj Jan 29, 2019
b1170a9
add multi trace mock and add it to mock list
archmoj Jan 30, 2019
1a49fa2
baseline for multiple volume traces
archmoj Jan 30, 2019
e0b786c
revised the colorscale of datacube mock
archmoj Jan 31, 2019
76dae20
updated baseline with revised colorscale
archmoj Jan 31, 2019
fb502bd
bring isosurface draws to front and added a mock with mri data
archmoj Feb 4, 2019
c74daad
enter mri data
archmoj Feb 4, 2019
ea92715
revised mri mock
archmoj Feb 4, 2019
b07aa6a
fixup test
archmoj Feb 4, 2019
48909e0
using new shader and mock with two volume traces in one cube
archmoj Feb 5, 2019
02f171f
correct baseline using new shader
archmoj Feb 5, 2019
3b7320f
added new baseline
archmoj Feb 5, 2019
1ec0941
mock and baseline changes
archmoj Feb 5, 2019
51035f9
exclude mri to run on CI
archmoj Feb 5, 2019
7a13bde
removed mri baseline
archmoj Feb 6, 2019
7249f8f
new volume mock with aspect ratio and opacityscale
archmoj Feb 6, 2019
601baaa
added a draft baseline for new mock
archmoj Feb 6, 2019
3580015
disable more volume mocks to run CI
archmoj Feb 6, 2019
2052e9b
correct baseline
archmoj Feb 6, 2019
3c0dc06
settings to speedup mesh normal calc
archmoj Feb 7, 2019
04aa645
correct baselines using flatshading nomalization algo and try mri to …
archmoj Feb 7, 2019
dce3209
removed mri mock to run CI
archmoj Feb 7, 2019
fe9968e
dont run gl3d_volume_between-ranges to run on CI
archmoj Feb 7, 2019
9681682
resolved conflicts and revised code based on comments
archmoj Feb 20, 2019
1bb5ade
tweak image test to run for volume only
archmoj Feb 20, 2019
94bfc50
fixed filter condition for image test
archmoj Feb 20, 2019
4542518
rm mri mock
archmoj Mar 6, 2019
c2a703f
Merge branch 'master' into volume-dev
archmoj Mar 6, 2019
3511f6c
dont run volume mocks on ci
archmoj Mar 6, 2019
401e390
Merge remote-tracking branch 'origin/master'
archmoj Mar 28, 2019
913c6e6
reduce opacityscale and move to volume folder - pass 1
archmoj Mar 29, 2019
64652f9
revised min opacity in palettes
archmoj Mar 29, 2019
e82a826
reduced opacityscale code - updated baseline - revised jasmine test
archmoj Mar 29, 2019
320485f
add hovertext support
archmoj Mar 29, 2019
5da5cd7
Merge remote-tracking branch 'origin/master' into volume4d to apply n…
archmoj Mar 29, 2019
d35f69a
Merge remote-tracking branch 'origin/master' into volume4d
archmoj Apr 2, 2019
e6b0efd
run volume image test on CI
archmoj Apr 2, 2019
0aa25f0
reset batch wait to 500
archmoj Apr 3, 2019
77f7317
fixup volume default to coerce volume attributes and dflt - switch pr…
archmoj Apr 3, 2019
af17adc
revised isosurface default function exports
archmoj Apr 3, 2019
130da2f
add volume and isosurface to the gl3d partial bundle list
archmoj Apr 3, 2019
01a9426
revert unwanted scattergl changes in the previous commit
archmoj Apr 3, 2019
e23b2c3
reduced volume mock data
archmoj Apr 5, 2019
4a9987d
bump gl-mesh3d 2.1.0
archmoj Apr 8, 2019
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
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Plotly.register([
require('./scatter3d'),
require('./surface'),
require('./isosurface'),
require('./volume4d'),
etpinard marked this conversation as resolved.
Show resolved Hide resolved
require('./mesh3d'),
require('./cone'),
require('./streamtube'),
Expand Down
11 changes: 11 additions & 0 deletions lib/volume4d.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Copyright 2012-2019, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

module.exports = require('../src/traces/volume4d');
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 @@ -77,7 +77,7 @@
"gl-heatmap2d": "^1.0.5",
"gl-line3d": "^1.1.8",
"gl-mat4": "^1.2.0",
"gl-mesh3d": "^2.0.7",
"gl-mesh3d": "git://github.com/gl-vis/gl-mesh3d.git#2ad87fb6d6329638a975a1db003b798e9698b930",
"gl-plot2d": "^1.4.2",
"gl-plot3d": "^1.6.3",
"gl-pointcloud2d": "^1.0.2",
Expand Down
59 changes: 59 additions & 0 deletions src/components/opacityscale/attributes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* Copyright 2012-2019, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

var palettes = require('./scales.js').scales;
var paletteStr = Object.keys(palettes);

/**
* Make opacityscale attribute declarations for
*
* - opacityscale,
*
* @param {string} context (dflt: '', i.e. from trace root):
* the container this is in ('', *marker*, *marker.line* etc)
*
* @param {object} opts:
* - opacityscaleDflt {string}:
* overrides the opacityscale dflt
*
* - editTypeOverride {boolean} (dflt: ''):
* most of these attributes already require a recalc, but the ones that do not
* have editType *style* or *plot* unless you override (presumably with *calc*)
*
* @return {object}
*/
module.exports = function opacityScaleAttrs(context, opts) {
etpinard marked this conversation as resolved.
Show resolved Hide resolved
context = context || '';
opts = opts || {};

var opacityscaleDflt = typeof opts.opacityscaleDflt === 'string' ? palettes[opts.opacityscaleDflt] : null;

var attrs = {};

attrs.opacityscale = {
valType: 'opacityscale',
role: 'style',
editType: 'calc',
dflt: opacityscaleDflt,
description: [
'Sets the opacityscale.',
' The opacityscale must be an array containing',
' arrays mapping a normalized value to an opacity value.',
' At minimum, a mapping for the lowest (0) and highest (1)',
' values are required. For example,',
' `[[0, 1], [0.5, 0.2], [1, 1]]` means that higher/lower values would have',
' higher opacity values and those in the middle would be more transparent',
' Alternatively, `opacityscale` may be a palette name string',
' of the following list: ' + paletteStr + '.'
].join('')
};

return attrs;
};
15 changes: 15 additions & 0 deletions src/components/opacityscale/defaults.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Copyright 2012-2019, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

module.exports = function opacityScaleDefaults(traceIn, traceOut, layout, coerce, opts) {
var prefix = opts.prefix;

coerce(prefix + 'opacityscale');
};
98 changes: 98 additions & 0 deletions src/components/opacityscale/scales.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/**
* Copyright 2012-2019, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

function createWave(n, minOpacity) {
var arr = [];
var steps = 32; // Max: 256
for(var i = 0; i < steps; i++) {
var u = i / (steps - 1);
var v = minOpacity + (1 - minOpacity) * (1 - Math.pow(Math.sin(n * u * Math.PI), 2));
arr.push([
u,
Math.max(1, Math.min(0, v))
]);
}
return arr;
}

var min = 0.2;

var scales = {
'max': [
[0, min], [1, 1]
],

'min': [
[0, 1], [1, min]
],

'extremes': createWave(1, min),

'zigzag': createWave(8, min)
};

var defaultScale = scales.uniform;

function getScale(scl, dflt) {
if(!dflt) dflt = defaultScale;
if(!scl) return dflt;

function parseScale() {
try {
scl = scales[scl] || JSON.parse(scl);
} catch(e) {
scl = dflt;
}
}

if(typeof scl === 'string') {
parseScale();
// occasionally scl is double-JSON encoded...
if(typeof scl === 'string') parseScale();
}

if(!isValidScaleArray(scl)) return dflt;
return scl;
}

function isValidScaleArray(scl) {
var highestVal = 0;

if(!Array.isArray(scl) || scl.length < 2) return false;

if(!scl[0] || !scl[scl.length - 1]) return false;

if(+scl[0][0] !== 0 || +scl[scl.length - 1][0] !== 1) return false;

for(var i = 0; i < scl.length; i++) {
var si = scl[i];

if(si.length !== 2 || +si[0] < highestVal) {
return false;
}

highestVal = +si[0];
}

return true;
}

function isValidScale(scl) {
if(scales[scl] !== undefined) return true;
else return isValidScaleArray(scl);
}

module.exports = {
scales: scales,
defaultScale: defaultScale,

get: getScale,
isValid: isValidScale
};
22 changes: 19 additions & 3 deletions src/lib/coerce.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ var isNumeric = require('fast-isnumeric');
var tinycolor = require('tinycolor2');

var baseTraceAttrs = require('../plots/attributes');
var scales = require('../components/colorscale/scales');
var colorscales = require('../components/colorscale/scales');
var opacityscales = require('../components/opacityscale/scales');
var DESELECTDIM = require('../constants/interactions').DESELECTDIM;

var nestedProperty = require('./nested_property');
Expand Down Expand Up @@ -164,7 +165,7 @@ exports.valObjectMeta = {
colorscale: {
description: [
'A Plotly colorscale either picked by a name:',
'(any of', Object.keys(scales.scales).join(', '), ')',
'(any of', Object.keys(colorscales.scales).join(', '), ')',
'customized as an {array} of 2-element {arrays} where',
'the first element is the normalized color level value',
'(starting at *0* and ending at *1*),',
Expand All @@ -173,7 +174,22 @@ exports.valObjectMeta = {
requiredOpts: [],
otherOpts: ['dflt'],
coerceFunction: function(v, propOut, dflt) {
propOut.set(scales.get(v, dflt));
propOut.set(colorscales.get(v, dflt));
}
},
opacityscale: {
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't a new valType just for opacityscale. In the volume attribute, you can set valType to any and coerce "manually" in the volume/defaults.js.

description: [
'A Plotly opacityscale either picked by a name:',
'(any of', Object.keys(opacityscales.scales).join(', '), ')',
'customized as an {array} of 2-element {arrays} where',
'the first element is the normalized opacity level value',
'(starting at *0* and ending at *1*),',
'and the second item is a valid opacity value between 0 and 1.'
].join(' '),
requiredOpts: [],
otherOpts: ['dflt'],
coerceFunction: function(v, propOut, dflt) {
propOut.set(opacityscales.get(v, dflt));
}
},
angle: {
Expand Down
2 changes: 1 addition & 1 deletion src/plots/gl3d/scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function render(scene) {
vectorTx.push(selection.textLabel);
}
tx = vectorTx.join('<br>');
} else if(trace.type === 'isosurface') {
} else if(trace.type === 'isosurface' || trace.type === 'volume4d') {
vectorTx.push('value: ' + Axes.tickText(scene.mockAxis, scene.mockAxis.d2l(selection.traceCoordinate[3]), 'hover').text);
if(selection.textLabel) {
vectorTx.push(selection.textLabel);
Expand Down
39 changes: 10 additions & 29 deletions src/traces/isosurface/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
'use strict';

var colorscaleAttrs = require('../../components/colorscale/attributes');
var opacityscaleAttrs = require('../../components/opacityscale/attributes');
var colorbarAttrs = require('../../components/colorbar/attributes');
var surfaceAtts = require('../surface/attributes');
var meshAttrs = require('../mesh3d/attributes');
var baseAttrs = require('../../plots/attributes');

Expand Down Expand Up @@ -225,9 +225,13 @@ var attrs = module.exports = overrideAll(extendFlat({
'If trace `hoverinfo` contains a *text* flag and *hovertext* is not set,',
'these elements will be seen in the hover labels.'
].join(' ')
},
}
},

opacityscaleAttrs('', {
etpinard marked this conversation as resolved.
Show resolved Hide resolved
editTypeOverride: 'calc'
}),

colorscaleAttrs('', {
colorAttr: '`value`',
showScaleDflt: true,
Expand All @@ -236,34 +240,11 @@ colorscaleAttrs('', {

colorbar: colorbarAttrs,

// Flat shaded mode
flatshading: {
valType: 'boolean',
role: 'style',
dflt: false,
description: [
'Determines whether or not normal smoothing is applied to the isosurfaces,',
'creating isosurfaces with an angular, low-poly look via flat reflections.'
].join(' ')
},

contour: {
show: extendFlat({}, surfaceAtts.contours.x.show, {
description: [
'Sets whether or not dynamic contours are shown on hover.',
'Contours are more useful when hovering on caps and slices.'
].join(' ')
}),
color: surfaceAtts.contours.x.color,
width: surfaceAtts.contours.x.width
},

lightposition: {
x: extendFlat({}, surfaceAtts.lightposition.x, {dflt: 1e5}),
y: extendFlat({}, surfaceAtts.lightposition.y, {dflt: 1e5}),
z: extendFlat({}, surfaceAtts.lightposition.z, {dflt: 0})
},
opacity: meshAttrs.opacity,
lightposition: meshAttrs.lightposition,
lighting: meshAttrs.lighting,
flatshading: meshAttrs.flatshading,
contour: meshAttrs.contour,

hoverinfo: extendFlat({}, baseAttrs.hoverinfo)
}), 'calc', 'nested');
Expand Down
Loading