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 all 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
2 changes: 2 additions & 0 deletions lib/index-gl3d.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Plotly.register([
require('./scatter3d'),
require('./surface'),
require('./mesh3d'),
require('./isosurface'),
require('./volume'),
require('./cone'),
require('./streamtube')
]);
Expand Down
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Plotly.register([
require('./scatter3d'),
require('./surface'),
require('./isosurface'),
require('./volume'),
require('./mesh3d'),
require('./cone'),
require('./streamtube'),
Expand Down
11 changes: 11 additions & 0 deletions lib/volume.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/volume');
6 changes: 3 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 @@ -78,7 +78,7 @@
"gl-heatmap2d": "^1.0.5",
"gl-line3d": "^1.1.11",
"gl-mat4": "^1.2.0",
"gl-mesh3d": "^2.0.10",
"gl-mesh3d": "^2.1.0",
"gl-plot2d": "^1.4.2",
"gl-plot3d": "^2.2.1",
"gl-pointcloud2d": "^1.0.2",
Expand Down
6 changes: 3 additions & 3 deletions src/lib/coerce.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ 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 DESELECTDIM = require('../constants/interactions').DESELECTDIM;

var nestedProperty = require('./nested_property');
Expand Down Expand Up @@ -164,7 +164,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 +173,7 @@ exports.valObjectMeta = {
requiredOpts: [],
otherOpts: ['dflt'],
coerceFunction: function(v, propOut, dflt) {
propOut.set(scales.get(v, dflt));
propOut.set(colorscales.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 @@ -123,7 +123,7 @@ function render(scene) {
vectorTx.push(selection.textLabel);
}
tx = vectorTx.join('<br>');
} else if(trace.type === 'isosurface') {
} else if(trace.type === 'isosurface' || trace.type === 'volume') {
labels.valueLabel = Axes.tickText(scene.mockAxis, scene.mockAxis.d2l(selection.traceCoordinate[3]), 'hover').text;
vectorTx.push('value: ' + labels.valueLabel);
if(selection.textLabel) {
Expand Down
34 changes: 19 additions & 15 deletions src/traces/isosurface/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,7 @@ function distinctVals(col) {
return Lib.distinctVals(col).vals;
}

function IsosurfaceTrace(scene, mesh, uid) {
this.scene = scene;
this.uid = uid;
this.mesh = mesh;
this.name = '';
this.data = null;
this.showContour = false;
}

var proto = IsosurfaceTrace.prototype;

function findNearestOnAxis(w, arr) {
var findNearestOnAxis = function(w, arr) {
for(var q = arr.length - 1; q > 0; q--) {
var min = Math.min(arr[q], arr[q - 1]);
var max = Math.max(arr[q], arr[q - 1]);
Expand All @@ -46,8 +35,19 @@ function findNearestOnAxis(w, arr) {
id: 0,
distRatio: 0
};
};

function IsosurfaceTrace(scene, mesh, uid) {
this.scene = scene;
this.uid = uid;
this.mesh = mesh;
this.name = '';
this.data = null;
this.showContour = false;
}

var proto = IsosurfaceTrace.prototype;

proto.handlePick = function(selection) {
if(selection.object === this.mesh) {
var rawId = selection.data.index;
Expand Down Expand Up @@ -87,7 +87,7 @@ proto.update = function(data) {
var scene = this.scene;
var layout = scene.fullSceneLayout;

this.data = generateIsosurfaceMesh(data);
this.data = generateIsoMeshes(data);

// Unpack position data
function toDataCoords(axis, coord, scale, calendar) {
Expand Down Expand Up @@ -134,7 +134,7 @@ proto.dispose = function() {
this.mesh.dispose();
};

function generateIsosurfaceMesh(data) {
function generateIsoMeshes(data) {
data._i = [];
data._j = [];
data._k = [];
Expand Down Expand Up @@ -1035,4 +1035,8 @@ function createIsosurfaceTrace(scene, data) {
return result;
}

module.exports = createIsosurfaceTrace;
module.exports = {
findNearestOnAxis: findNearestOnAxis,
generateIsoMeshes: generateIsoMeshes,
createIsosurfaceTrace: createIsosurfaceTrace,
};
15 changes: 12 additions & 3 deletions src/traces/isosurface/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@

'use strict';

var Registry = require('../../registry');
var Lib = require('../../lib');
var colorscaleDefaults = require('../../components/colorscale/defaults');
var Registry = require('../../registry');
var attributes = require('./attributes');
var colorscaleDefaults = require('../../components/colorscale/defaults');

module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
function coerce(attr, dflt) {
return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
}

supplyIsoDefaults(traceIn, traceOut, defaultColor, layout, coerce);
}

function supplyIsoDefaults(traceIn, traceOut, defaultColor, layout, coerce) {
var isomin = coerce('isomin');
var isomax = coerce('isomax');

Expand Down Expand Up @@ -103,4 +107,9 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout

// disable 1D transforms (for now)
traceOut._length = null;
}

module.exports = {
supplyDefaults: supplyDefaults,
supplyIsoDefaults: supplyIsoDefaults
};
4 changes: 2 additions & 2 deletions src/traces/isosurface/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
var Isosurface = {};

Isosurface.attributes = require('./attributes');
Isosurface.supplyDefaults = require('./defaults');
Isosurface.supplyDefaults = require('./defaults').supplyDefaults;
Isosurface.calc = require('./calc');
Isosurface.colorbar = {
min: 'cmin',
max: 'cmax'
};
Isosurface.plot = require('./convert');
Isosurface.plot = require('./convert').createIsosurfaceTrace;

Isosurface.moduleType = 'trace';
Isosurface.name = 'isosurface',
Expand Down
93 changes: 93 additions & 0 deletions src/traces/volume/attributes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/**
* 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 colorscaleAttrs = require('../../components/colorscale/attributes');
var isosurfaceAttrs = require('../isosurface/attributes');
var baseAttrs = require('../../plots/attributes');

var extendFlat = require('../../lib/extend').extendFlat;
var overrideAll = require('../../plot_api/edit_types').overrideAll;

var attrs = module.exports = overrideAll(extendFlat({
x: isosurfaceAttrs.x,
y: isosurfaceAttrs.y,
z: isosurfaceAttrs.z,
value: isosurfaceAttrs.value,
isomin: isosurfaceAttrs.isomin,
isomax: isosurfaceAttrs.isomax,
surface: isosurfaceAttrs.surface,
spaceframe: {
show: {
valType: 'boolean',
role: 'info',
dflt: false,
description: [
'Displays/hides tetrahedron shapes between minimum and',
'maximum iso-values. Often useful when either caps or',
'surfaces are disabled or filled with values less than 1.'
].join(' ')
},
fill: {
valType: 'number',
role: 'style',
min: 0,
max: 1,
dflt: 1,
Copy link
Contributor

Choose a reason for hiding this comment

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

Ha. I see the spaceframe.fill is different for volume. Nice touch!

description: [
'Sets the fill ratio of the `spaceframe` elements. The default fill value',
'is 1 meaning that they are entirely shaded. Applying a `fill` ratio less',
'than one would allow the creation of openings parallel to the edges.'
].join(' ')
}
},

slices: isosurfaceAttrs.slices,
caps: isosurfaceAttrs.caps,
text: isosurfaceAttrs.text,
hovertext: isosurfaceAttrs.hovertext,
hovertemplate: isosurfaceAttrs.hovertemplate
},

colorscaleAttrs('', {
colorAttr: '`value`',
showScaleDflt: true,
editTypeOverride: 'calc'
}), {

colorbar: isosurfaceAttrs.colorbar,
opacity: isosurfaceAttrs.opacity,
opacityscale: {
valType: 'any',
role: 'style',
editType: 'calc',
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: \'min\', \'max\', \'extremes\' and \'uniform\'.',
' The default is \'uniform\'.'
].join('')
},

lightposition: isosurfaceAttrs.lightposition,
lighting: isosurfaceAttrs.lighting,
flatshading: isosurfaceAttrs.flatshading,
contour: isosurfaceAttrs.contour,

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

attrs.x.editType = attrs.y.editType = attrs.z.editType = attrs.value.editType = 'calc+clearAxisTypes';
attrs.transforms = undefined;
Loading