Skip to content

Commit

Permalink
add tests for label/customMesh
Browse files Browse the repository at this point in the history
  • Loading branch information
biasmv committed Jan 24, 2015
1 parent 4f717c6 commit 048fb9c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 14 deletions.
32 changes: 18 additions & 14 deletions src/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -767,12 +767,8 @@ PV.prototype = {
return this[mode](name, structure, opts);
},


_handleStandardOptions : function(opts, structure) {
opts = copy(opts);
opts.float32Allocator = this._float32Allocator;
opts.uint16Allocator = this._uint16Allocator;
opts.idPool = this._objectIdManager;
_handleStandardMolOptions : function(opts, structure) {
opts = this._handleStandardOptions(opts);
opts.showRelated = opts.showRelated || 'asym';
if (opts.showRelated && opts.showRelated !== 'asym') {
if (structure.assembly(opts.showRelated) === null) {
Expand All @@ -784,9 +780,17 @@ PV.prototype = {
return opts;
},

_handleStandardOptions : function(opts) {
opts = copy(opts);
opts.float32Allocator = this._float32Allocator;
opts.uint16Allocator = this._uint16Allocator;
opts.idPool = this._objectIdManager;
return opts;
},


lineTrace : function(name, structure, opts) {
var options = this._handleStandardOptions(opts, structure);
var options = this._handleStandardMolOptions(opts, structure);
options.color = options.color || color.uniform([ 1, 0, 1 ]);
options.lineWidth = options.lineWidth || 4.0;

Expand All @@ -795,7 +799,7 @@ PV.prototype = {
},

spheres : function(name, structure, opts) {
var options = this._handleStandardOptions(opts, structure);
var options = this._handleStandardMolOptions(opts, structure);
options.color = options.color || color.byElement();
options.sphereDetail = this.options('sphereDetail');
options.radiusMultiplier = options.radiusMultiplier || 1.0;
Expand All @@ -805,7 +809,7 @@ PV.prototype = {
},

sline : function(name, structure, opts) {
var options = this._handleStandardOptions(opts, structure);
var options = this._handleStandardMolOptions(opts, structure);
options.color = options.color || color.uniform([ 1, 0, 1 ]);
options.splineDetail = options.splineDetail || this.options('splineDetail');
options.strength = options.strength || 1.0;
Expand Down Expand Up @@ -859,7 +863,7 @@ PV.prototype = {


surface : function(name, data, opts) {
var options = this._handleStandardOptions(opts, structure);
var options = this._handleStandardOptions(opts);
var obj = render.surface(data, this._gl, options);
return this.add(name, obj);
},
Expand All @@ -874,7 +878,7 @@ PV.prototype = {
},

ballsAndSticks : function(name, structure, opts) {
var options = this._handleStandardOptions(opts, structure);
var options = this._handleStandardMolOptions(opts, structure);

options.color = options.color || color.byElement();
options.radius = options.radius || 0.3;
Expand All @@ -886,15 +890,15 @@ PV.prototype = {
},

lines : function(name, structure, opts) {
var options = this._handleStandardOptions(opts, structure);
var options = this._handleStandardMolOptions(opts, structure);
options.color = options.color || color.byElement();
options.lineWidth = options.lineWidth || 4.0;
var obj = render.lines(structure, this._gl, options);
return this.add(name, obj);
},

trace : function(name, structure, opts) {
var options = this._handleStandardOptions(opts, structure);
var options = this._handleStandardMolOptions(opts, structure);
options.color = options.color || color.uniform([ 1, 0, 0 ]);
options.radius = options.radius || 0.3;
options.arcDetail = (options.arcDetail || this.options('arcDetail')) * 2;
Expand Down Expand Up @@ -1011,7 +1015,7 @@ PV.prototype = {
return label;
},
customMesh : function(name, opts) {
var options = this._handleStandardOptions(opts, structure);
var options = this._handleStandardOptions(opts);

var mesh = new CustomMesh(name, this._gl,
options.float32Allocator,
Expand Down
1 change: 1 addition & 0 deletions tests/all.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<script src='/src/slab.js'></script>
<script src='/src/animation.js'></script>
<script src='/src/touch.js'></script>
<script src='/src/custom-mesh.js'></script>
<script src='/src/viewer.js'></script>
<script src='/src/viewpoint.js'></script>
<script src="/tests/binary-search.js"></script>
Expand Down
22 changes: 22 additions & 0 deletions tests/viewer-render.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,25 @@ test("renders molecule assembly 1 in all styles", function(assert) {
});
});

test("renders labels", function(assert) {
var viewer = createViewer();
var label = viewer.label('my.label',
'somewhere over the rainbow', [0,0,0]);
assert.ok(!!label);
viewer.destroy();
});

test("renders custom meshes", function(assert) {
var viewer = createViewer();
var mesh = viewer.customMesh('my.label');
mesh.addTube([0,0,0], [50,0,0], 3, { color : 'red', cap : true });
mesh.addTube([0,0,0], [0,50,0], 3, { color : 'green', cap : true });
mesh.addTube([0,0,0], [0,0,50], 3, { color : 'blue', cap : true });
mesh.addSphere([0,0,0], 5, {color:'yellow'});
assert.ok(!!mesh);
viewer.destroy();
});




0 comments on commit 048fb9c

Please sign in to comment.