Skip to content

Commit

Permalink
comment out cones.(x|y|z) attributes for now
Browse files Browse the repository at this point in the history
  • Loading branch information
etpinard committed May 17, 2018
1 parent b7465fb commit 5a42de0
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 5,153 deletions.
86 changes: 47 additions & 39 deletions src/traces/cone/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ var attrs = {
editType: 'calc+clearAxisTypes',
description: [
'Sets the x coordinates of the vector field',
'If `cones` positions are not provided, this array',
'corresponds to the x coordinates of the cones displayed as well.'
'and of the displayed cones.'
].join(' ')
},
y: {
Expand All @@ -33,8 +32,7 @@ var attrs = {
editType: 'calc+clearAxisTypes',
description: [
'Sets the y coordinates of the vector field',
'If `cones` positions are not provided, this array',
'corresponds to the y coordinates of the cones displayed as well.'
'and of the displayed cones.'
].join(' ')
},
z: {
Expand All @@ -43,8 +41,7 @@ var attrs = {
editType: 'calc+clearAxisTypes',
description: [
'Sets the z coordinates of the vector field',
'If `cones` positions are not provided, this array',
'corresponds to the z coordinates of the cones displayed as well.'
'and of the displayed cones.'
].join(' ')
},

Expand All @@ -64,38 +61,49 @@ var attrs = {
description: 'Sets the z components of the vector field.'
},

cones: {
// potential attributes to add:
//
// - meshmode: 'cartesian-product', 'pts', 'grid'
//
// under `meshmode: 'grid'`
// - (x|y|z)grid.start
// - (x|y|z)grid.end
// - (x|y|z)grid.size

x: {
valType: 'data_array',
editType: 'calc',
description: 'Sets the x coordinates of the cones to be displayed.'
},
y: {
valType: 'data_array',
editType: 'calc',
description: 'Sets the y coordinates of the cones to be displayed.'
},
z: {
valType: 'data_array',
editType: 'calc',
description: 'Sets the z coordinates of the cones to be displayed.'
},

editType: 'calc',
description: [
'By setting `cones.x`, `cones.y` and `cones.z` to 1D arrays,',
'plotly creates a mesh using the cartesian product of those 3 arrays.'
].join(' ')
},
// TODO add way to specify cone positions independently of the vector field
// provided, similar to MATLAB's coneplot Cx/Cy/Cz meshgrids,
// see https://www.mathworks.com/help/matlab/ref/coneplot.html
//
// Alternatively, if our goal is only to 'fill in gaps' in the vector data,
// we could try to extend the heatmap 'connectgaps' algorithm to 3D.
// From AJ: this particular algorithm which amounts to a Poisson equation,
// both for interpolation and extrapolation - is the right one to use for
// cones too. It makes a field with zero divergence, which is a good
// baseline assumption for vector fields.
//
// cones: {
// // potential attributes to add:
// //
// // - meshmode: 'cartesian-product', 'pts', 'grid'
// //
// // under `meshmode: 'grid'`
// // - (x|y|z)grid.start
// // - (x|y|z)grid.end
// // - (x|y|z)grid.size
//
// x: {
// valType: 'data_array',
// editType: 'calc',
// description: 'Sets the x coordinates of the cones to be displayed.'
// },
// y: {
// valType: 'data_array',
// editType: 'calc',
// description: 'Sets the y coordinates of the cones to be displayed.'
// },
// z: {
// valType: 'data_array',
// editType: 'calc',
// description: 'Sets the z coordinates of the cones to be displayed.'
// },
//
// editType: 'calc',
// description: [
// 'By setting `cones.x`, `cones.y` and `cones.z` to 1D arrays,',
// 'plotly creates a mesh using the cartesian product of those 3 arrays.'
// ].join(' ')
// },

sizemode: {
valType: 'enumerated',
Expand Down Expand Up @@ -128,7 +136,7 @@ var attrs = {
dflt: 'cm',
description: [
'Sets the cones\' anchor with respect to their x/y/z positions.',
'Note that *cm* denote the cone\'s center of mass with corresponds to',
'Note that *cm* denote the cone\'s center of mass which corresponds to',
'1/4 from the tail to tip.'
].join(' ')
},
Expand Down
34 changes: 13 additions & 21 deletions src/traces/cone/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@ var proto = Cone.prototype;
proto.handlePick = function(selection) {
if(selection.object === this.pts) {
var selectIndex = selection.index = selection.data.index;
var dataScale = this.scene.dataScale;
var xx = this._positions[selectIndex][0] / dataScale[0];
var yy = this._positions[selectIndex][1] / dataScale[1];
var zz = this._positions[selectIndex][2] / dataScale[2];
var uu = this._vectors[selectIndex][0] / dataScale[0];
var vv = this._vectors[selectIndex][1] / dataScale[1];
var ww = this._vectors[selectIndex][2] / dataScale[2];
var xx = this.data.x[selectIndex];
var yy = this.data.y[selectIndex];
var zz = this.data.z[selectIndex];
var uu = this.data.u[selectIndex];
var vv = this.data.v[selectIndex];
var ww = this.data.w[selectIndex];

selection.traceCoordinate = [
xx, yy, zz,
Expand Down Expand Up @@ -88,21 +87,18 @@ function convert(scene, trace) {
toDataCoords(trace.z, 'zaxis')
);

if(trace.cones && trace.cones.x && trace.cones.y && trace.cones.z) {
coneOpts.meshgrid = [
toDataCoords(trace.cones.x, 'xaxis'),
toDataCoords(trace.cones.y, 'yaxis'),
toDataCoords(trace.cones.z, 'zaxis')
];
}

coneOpts.colormap = parseColorScale(trace.colorscale);
coneOpts.vertexIntensityBounds = [trace.cmin / trace._normMax, trace.cmax / trace._normMax];

coneOpts[sizeMode2sizeKey[trace.sizemode]] = trace.sizeref;
coneOpts.coneOffset = anchor2coneOffset[trace.anchor];

return conePlot(coneOpts);
var meshData = conePlot(coneOpts);

// stash positions for gl-scatter3d 'hover' trace
meshData._pts = coneOpts.positions;

return meshData;
}

proto.update = function(data) {
Expand All @@ -129,7 +125,7 @@ function createConeTrace(scene, data) {

var pts = createScatterPlot({
gl: gl,
position: meshData._positions,
position: meshData._pts,
project: false,
opacity: 0
});
Expand All @@ -141,10 +137,6 @@ function createConeTrace(scene, data) {
mesh._trace = cone;
pts._trace = cone;

// stash these for hover
cone._positions = meshData._positions;
cone._vectors = meshData._vectors;

scene.glplot.add(pts);
scene.glplot.add(mesh);

Expand Down
8 changes: 1 addition & 7 deletions src/traces/cone/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
return;
}

coerce('cones.x');
coerce('cones.y');
coerce('cones.z');

coerce('sizeref');
coerce('sizemode');

Expand All @@ -60,8 +56,6 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout

coerce('text');

// disable 1D transforms
// x/y/z and u/v/w should match lengths, cones.(x|y|z) should match as well, but
// the two sets have different lengths so transforms wouldn't work.
// disable 1D transforms (for now)
traceOut._length = null;
};
7 changes: 2 additions & 5 deletions src/traces/cone/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@ module.exports = {
'Specify a vector field using 6 1D arrays,',
'3 position arrays `x`, `y` and `z`',
'and 3 vector component arrays `u`, `v`, `w`.',
'',
'If nothing else is provided, the cones are drawn exactly at the positions given',
'by `x`, `y` and `z`.',
'To specify the cone positions manually, use arrays attributes',
'`cones.x`, `cones.y` and `cones.z`.'
'The cones are drawn exactly at the positions given',
'by `x`, `y` and `z`.'
].join(' ')
}
};
Binary file removed test/image/baselines/gl3d_cone-sparse.png
Binary file not shown.
Loading

0 comments on commit 5a42de0

Please sign in to comment.