Skip to content
This repository has been archived by the owner on Aug 26, 2019. It is now read-only.

Commit

Permalink
Working #282: Renders with NaN bounding boxes
Browse files Browse the repository at this point in the history
Neon now renders without the invalid elements (bounding box == NaN) but we must now find a way to remove the elements with invalid bounding boxes from the Mei file.
  • Loading branch information
zoemcl committed May 7, 2018
1 parent 523072c commit bfc6077
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ docs/*
*.swo
*.jar
app_env/*
MEI_DIRECTORY/*
tutorial.mei
MEI_DIRECTORY/*
/static/js/support/all.js

6 changes: 4 additions & 2 deletions src/nn/neume.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ Toe.Model.Neume.prototype.setSystem = function(aSystem) {
* @param {Array} bb [ulx, uly, lrx, lry]
*/
Toe.Model.Neume.prototype.setBoundingBox = function(bb) {
if(!Toe.validBoundingBox(bb)) {
throw new Error("Neume: invalid bounding box");
var isNotNaN = bb[0] && bb[1] && bb[2] && bb[3];

if(!Toe.validBoundingBox(bb) && isNotNaN) {
throw new Error("Neume: invalid bounding box");
}

bb = $.map(bb, Math.round);
Expand Down
4 changes: 3 additions & 1 deletion src/nn/squarenote/custos.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ Toe.Model.Custos.prototype.constructor = Toe.Model.Custos;
* @param {Array} bb [ulx, uly, lrx, lry]
*/
Toe.Model.Custos.prototype.setBoundingBox = function(bb) {
if(!Toe.validBoundingBox(bb)) {
var isNotNaN = bb[0] && bb[1] && bb[2] && bb[3];

if(!Toe.validBoundingBox(bb) && isNotNaN) {
throw new Error("Division: invalid bounding box");
}

Expand Down
17 changes: 15 additions & 2 deletions src/nn/squarenote/squarenotepage.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Toe.Model.SquareNotePage.prototype.constructor = Toe.SquareNotePage;
* @param {Toe.View.RenderEngine} rendEng the rendering engine
*/
Toe.Model.SquareNotePage.prototype.loadMei = function(mei, rendEng) {
var apiprefix = rendEng.canvas.cacheCanvasEl.baseURI;
// cache page reference
var page = this;

Expand Down Expand Up @@ -159,8 +160,20 @@ Toe.Model.SquareNotePage.prototype.loadMei = function(mei, rendEng) {
var nView = new Toe.View.NeumeView(rendEng, page.documentType);
var nCtrl = new Toe.Ctrl.NeumeController(nModel, nView);

// mount neume on the system
sModel.addNeume(nModel);
var ulx = nModel.zone.ulx;
var uly = nModel.zone.uly;
var lrx = nModel.zone.lrx;
var lry = nModel.zone.lry;

if (ulx && uly && lrx && lry){
// mount neume on the system
sModel.addNeume(nModel);
}
else{
$.post(apiprefix + "delete/neume", {ids: nModel.id})
}


});

// load all divisions in the system
Expand Down

0 comments on commit bfc6077

Please sign in to comment.